1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
6 #ifndef RTE_EXEC_ENV_WINDOWS
10 #include <rte_common.h>
11 #include <rte_hexdump.h>
13 #include <rte_malloc.h>
14 #include <rte_memcpy.h>
15 #include <rte_pause.h>
16 #include <rte_bus_vdev.h>
17 #include <rte_ether.h>
19 #include <rte_crypto.h>
20 #include <rte_cryptodev.h>
22 #include <rte_string_fns.h>
26 #ifdef RTE_CRYPTO_SCHEDULER
27 #include <rte_cryptodev_scheduler.h>
28 #include <rte_cryptodev_scheduler_operations.h>
31 #include <rte_lcore.h>
34 #include "test_cryptodev.h"
36 #include "test_cryptodev_blockcipher.h"
37 #include "test_cryptodev_aes_test_vectors.h"
38 #include "test_cryptodev_des_test_vectors.h"
39 #include "test_cryptodev_hash_test_vectors.h"
40 #include "test_cryptodev_kasumi_test_vectors.h"
41 #include "test_cryptodev_kasumi_hash_test_vectors.h"
42 #include "test_cryptodev_snow3g_test_vectors.h"
43 #include "test_cryptodev_snow3g_hash_test_vectors.h"
44 #include "test_cryptodev_zuc_test_vectors.h"
45 #include "test_cryptodev_aead_test_vectors.h"
46 #include "test_cryptodev_hmac_test_vectors.h"
47 #include "test_cryptodev_mixed_test_vectors.h"
48 #ifdef RTE_LIB_SECURITY
49 #include "test_cryptodev_security_ipsec.h"
50 #include "test_cryptodev_security_ipsec_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_vectors.h"
52 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_test_func.h"
54 #include "test_cryptodev_security_docsis_test_vectors.h"
56 #define SDAP_DISABLED 0
57 #define SDAP_ENABLED 1
60 #define VDEV_ARGS_SIZE 100
61 #define MAX_NB_SESSIONS 4
63 #define MAX_DRV_SERVICE_CTX_SIZE 256
65 #define MAX_RAW_DEQUEUE_COUNT 65535
68 #define OUT_OF_PLACE 1
70 static int gbl_driver_id;
72 static enum rte_security_session_action_type gbl_action_type =
73 RTE_SECURITY_ACTION_TYPE_NONE;
75 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
77 struct crypto_unittest_params {
78 struct rte_crypto_sym_xform cipher_xform;
79 struct rte_crypto_sym_xform auth_xform;
80 struct rte_crypto_sym_xform aead_xform;
81 #ifdef RTE_LIB_SECURITY
82 struct rte_security_docsis_xform docsis_xform;
86 struct rte_cryptodev_sym_session *sess;
87 #ifdef RTE_LIB_SECURITY
88 struct rte_security_session *sec_session;
91 #ifdef RTE_LIB_SECURITY
92 enum rte_security_session_action_type type;
94 struct rte_crypto_op *op;
96 struct rte_mbuf *obuf, *ibuf;
101 #define ALIGN_POW2_ROUNDUP(num, align) \
102 (((num) + (align) - 1) & ~((align) - 1))
104 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
105 for (j = 0; j < num_child_ts; index++, j++) \
106 parent_ts.unit_test_suites[index] = child_ts[j]
108 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
109 for (j = 0; j < num_blk_types; index++, j++) \
110 parent_ts.unit_test_suites[index] = \
111 build_blockcipher_test_suite(blk_types[j])
113 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
114 for (j = index; j < index + num_blk_types; j++) \
115 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
118 * Forward declarations.
121 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
122 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
126 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
127 struct crypto_unittest_params *ut_params,
128 struct crypto_testsuite_params *ts_param,
129 const uint8_t *cipher,
130 const uint8_t *digest,
134 security_proto_supported(enum rte_security_session_action_type action,
135 enum rte_security_session_protocol proto);
138 dev_configure_and_start(uint64_t ff_disable);
140 static struct rte_mbuf *
141 setup_test_string(struct rte_mempool *mpool,
142 const char *string, size_t len, uint8_t blocksize)
144 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
145 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
150 memset(m->buf_addr, 0, m->buf_len);
151 dst = rte_pktmbuf_append(m, t_len);
157 rte_memcpy(dst, string, t_len);
159 memset(dst, 0, t_len);
165 /* Get number of bytes in X bits (rounding up) */
167 ceil_byte_length(uint32_t num_bits)
170 return ((num_bits >> 3) + 1);
172 return (num_bits >> 3);
176 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
177 uint8_t is_op_success)
179 struct rte_crypto_op *op = user_data;
180 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
181 RTE_CRYPTO_OP_STATUS_ERROR;
184 static struct crypto_testsuite_params testsuite_params = { NULL };
185 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
186 static struct crypto_unittest_params unittest_params;
189 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
190 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
191 uint8_t len_in_bits, uint8_t cipher_iv_len)
193 struct rte_crypto_sym_op *sop = op->sym;
194 struct rte_crypto_op *ret_op = NULL;
195 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
196 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
197 union rte_crypto_sym_ofs ofs;
198 struct rte_crypto_sym_vec vec;
199 struct rte_crypto_sgl sgl, dest_sgl;
201 union rte_cryptodev_session_ctx sess;
202 uint64_t auth_end_iova;
204 struct rte_crypto_raw_dp_ctx *ctx;
205 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
209 int ctx_service_size;
211 int enqueue_status, dequeue_status;
212 struct crypto_unittest_params *ut_params = &unittest_params;
213 int is_sgl = sop->m_src->nb_segs > 1;
216 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
217 if (ctx_service_size < 0) {
218 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
222 ctx = malloc(ctx_service_size);
224 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
228 /* Both are enums, setting crypto_sess will suit any session type */
229 sess.crypto_sess = op->sym->session;
231 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
232 op->sess_type, sess, 0) < 0) {
233 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
239 aad_auth_iv.iova = 0;
240 aad_auth_iv.va = NULL;
247 vec.digest = &digest;
248 vec.aad = &aad_auth_iv;
249 vec.status = &status;
253 if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
256 if (is_cipher && is_auth) {
257 cipher_offset = sop->cipher.data.offset;
258 cipher_len = sop->cipher.data.length;
259 auth_offset = sop->auth.data.offset;
260 auth_len = sop->auth.data.length;
261 max_len = RTE_MAX(cipher_offset + cipher_len,
262 auth_offset + auth_len);
264 max_len = max_len >> 3;
265 cipher_offset = cipher_offset >> 3;
266 auth_offset = auth_offset >> 3;
267 cipher_len = cipher_len >> 3;
268 auth_len = auth_len >> 3;
270 ofs.ofs.cipher.head = cipher_offset;
271 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
272 ofs.ofs.auth.head = auth_offset;
273 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
274 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
275 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
276 aad_auth_iv.va = rte_crypto_op_ctod_offset(
277 op, void *, IV_OFFSET + cipher_iv_len);
278 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
280 digest.va = (void *)sop->auth.digest.data;
281 digest.iova = sop->auth.digest.phys_addr;
284 uint32_t remaining_off = auth_offset + auth_len;
285 struct rte_mbuf *sgl_buf = sop->m_src;
287 sgl_buf = sop->m_dst;
289 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
290 && sgl_buf->next != NULL) {
291 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
292 sgl_buf = sgl_buf->next;
295 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
296 sgl_buf, remaining_off);
298 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
299 auth_offset + auth_len;
301 /* Then check if digest-encrypted conditions are met */
302 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
303 (digest.iova == auth_end_iova) && is_sgl)
304 max_len = RTE_MAX(max_len,
305 auth_offset + auth_len +
306 ut_params->auth_xform.auth.digest_length);
308 } else if (is_cipher) {
309 cipher_offset = sop->cipher.data.offset;
310 cipher_len = sop->cipher.data.length;
311 max_len = cipher_len + cipher_offset;
313 max_len = max_len >> 3;
314 cipher_offset = cipher_offset >> 3;
315 cipher_len = cipher_len >> 3;
317 ofs.ofs.cipher.head = cipher_offset;
318 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
319 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
320 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
322 } else if (is_auth) {
323 auth_offset = sop->auth.data.offset;
324 auth_len = sop->auth.data.length;
325 max_len = auth_len + auth_offset;
327 max_len = max_len >> 3;
328 auth_offset = auth_offset >> 3;
329 auth_len = auth_len >> 3;
331 ofs.ofs.auth.head = auth_offset;
332 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
333 aad_auth_iv.va = rte_crypto_op_ctod_offset(
334 op, void *, IV_OFFSET + cipher_iv_len);
335 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
337 digest.va = (void *)sop->auth.digest.data;
338 digest.iova = sop->auth.digest.phys_addr;
341 cipher_offset = sop->aead.data.offset;
342 cipher_len = sop->aead.data.length;
343 max_len = cipher_len + cipher_offset;
345 max_len = max_len >> 3;
346 cipher_offset = cipher_offset >> 3;
347 cipher_len = cipher_len >> 3;
349 ofs.ofs.cipher.head = cipher_offset;
350 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
351 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
352 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
353 aad_auth_iv.va = (void *)sop->aead.aad.data;
354 aad_auth_iv.iova = sop->aead.aad.phys_addr;
355 digest.va = (void *)sop->aead.digest.data;
356 digest.iova = sop->aead.digest.phys_addr;
359 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
360 data_vec, RTE_DIM(data_vec));
361 if (n < 0 || n > sop->m_src->nb_segs) {
362 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
369 dest_sgl.vec = dest_data_vec;
370 vec.dest_sgl = &dest_sgl;
371 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
372 dest_data_vec, RTE_DIM(dest_data_vec));
373 if (n < 0 || n > sop->m_dst->nb_segs) {
374 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
381 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
382 &enqueue_status) < 1) {
383 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
387 if (enqueue_status == 0) {
388 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
390 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
393 } else if (enqueue_status < 0) {
394 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
399 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
400 n = rte_cryptodev_raw_dequeue_burst(ctx,
401 NULL, 1, post_process_raw_dp_op,
402 (void **)&ret_op, 0, &n_success,
404 if (dequeue_status < 0) {
405 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
412 if (n == 1 && dequeue_status == 0) {
413 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
414 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
419 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
420 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
421 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
422 RTE_CRYPTO_OP_STATUS_SUCCESS;
429 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
432 struct rte_crypto_sym_op *sop;
433 union rte_crypto_sym_ofs ofs;
434 struct rte_crypto_sgl sgl;
435 struct rte_crypto_sym_vec symvec;
436 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
437 struct rte_crypto_vec vec[UINT8_MAX];
441 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
442 sop->aead.data.length, vec, RTE_DIM(vec));
444 if (n < 0 || n != sop->m_src->nb_segs) {
445 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
451 symvec.src_sgl = &sgl;
453 symvec.digest = &digest_ptr;
454 symvec.aad = &aad_ptr;
458 /* for CPU crypto the IOVA address is not required */
459 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
460 digest_ptr.va = (void *)sop->aead.digest.data;
461 aad_ptr.va = (void *)sop->aead.aad.data;
465 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
469 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
471 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
475 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
478 struct rte_crypto_sym_op *sop;
479 union rte_crypto_sym_ofs ofs;
480 struct rte_crypto_sgl sgl;
481 struct rte_crypto_sym_vec symvec;
482 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
483 struct rte_crypto_vec vec[UINT8_MAX];
487 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
488 sop->auth.data.length, vec, RTE_DIM(vec));
490 if (n < 0 || n != sop->m_src->nb_segs) {
491 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
497 symvec.src_sgl = &sgl;
499 symvec.digest = &digest_ptr;
503 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
504 digest_ptr.va = (void *)sop->auth.digest.data;
507 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
508 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
509 (sop->cipher.data.offset + sop->cipher.data.length);
511 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
515 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
517 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
520 static struct rte_crypto_op *
521 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
524 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
526 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
527 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
533 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
536 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
537 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
545 testsuite_setup(void)
547 struct crypto_testsuite_params *ts_params = &testsuite_params;
548 struct rte_cryptodev_info info;
549 uint32_t i = 0, nb_devs, dev_id;
552 memset(ts_params, 0, sizeof(*ts_params));
554 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
555 if (ts_params->mbuf_pool == NULL) {
556 /* Not already created so create */
557 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
559 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
561 if (ts_params->mbuf_pool == NULL) {
562 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
567 ts_params->large_mbuf_pool = rte_mempool_lookup(
568 "CRYPTO_LARGE_MBUFPOOL");
569 if (ts_params->large_mbuf_pool == NULL) {
570 /* Not already created so create */
571 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
572 "CRYPTO_LARGE_MBUFPOOL",
575 if (ts_params->large_mbuf_pool == NULL) {
577 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
582 ts_params->op_mpool = rte_crypto_op_pool_create(
583 "MBUF_CRYPTO_SYM_OP_POOL",
584 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
585 NUM_MBUFS, MBUF_CACHE_SIZE,
587 sizeof(struct rte_crypto_sym_xform) +
590 if (ts_params->op_mpool == NULL) {
591 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
595 nb_devs = rte_cryptodev_count();
597 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
601 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
602 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
603 rte_cryptodev_driver_name_get(gbl_driver_id));
607 /* Create list of valid crypto devs */
608 for (i = 0; i < nb_devs; i++) {
609 rte_cryptodev_info_get(i, &info);
610 if (info.driver_id == gbl_driver_id)
611 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
614 if (ts_params->valid_dev_count < 1)
617 /* Set up all the qps on the first of the valid devices found */
619 dev_id = ts_params->valid_devs[0];
621 rte_cryptodev_info_get(dev_id, &info);
623 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
624 ts_params->conf.socket_id = SOCKET_ID_ANY;
625 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
627 unsigned int session_size =
628 rte_cryptodev_sym_get_private_session_size(dev_id);
630 #ifdef RTE_LIB_SECURITY
631 unsigned int security_session_size = rte_security_session_get_size(
632 rte_cryptodev_get_sec_ctx(dev_id));
634 if (session_size < security_session_size)
635 session_size = security_session_size;
638 * Create mempool with maximum number of sessions.
640 if (info.sym.max_nb_sessions != 0 &&
641 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
642 RTE_LOG(ERR, USER1, "Device does not support "
643 "at least %u sessions\n",
648 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
649 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
651 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
652 "session mempool allocation failed");
654 ts_params->session_priv_mpool = rte_mempool_create(
658 0, 0, NULL, NULL, NULL,
661 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
662 "session mempool allocation failed");
666 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
668 "Failed to configure cryptodev %u with %u qps",
669 dev_id, ts_params->conf.nb_queue_pairs);
671 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
672 ts_params->qp_conf.mp_session = ts_params->session_mpool;
673 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
675 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
676 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
677 dev_id, qp_id, &ts_params->qp_conf,
678 rte_cryptodev_socket_id(dev_id)),
679 "Failed to setup queue pair %u on cryptodev %u",
687 testsuite_teardown(void)
689 struct crypto_testsuite_params *ts_params = &testsuite_params;
692 if (ts_params->mbuf_pool != NULL) {
693 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
694 rte_mempool_avail_count(ts_params->mbuf_pool));
697 if (ts_params->op_mpool != NULL) {
698 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
699 rte_mempool_avail_count(ts_params->op_mpool));
702 /* Free session mempools */
703 if (ts_params->session_priv_mpool != NULL) {
704 rte_mempool_free(ts_params->session_priv_mpool);
705 ts_params->session_priv_mpool = NULL;
708 if (ts_params->session_mpool != NULL) {
709 rte_mempool_free(ts_params->session_mpool);
710 ts_params->session_mpool = NULL;
713 res = rte_cryptodev_close(ts_params->valid_devs[0]);
715 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
719 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
720 const int *algs, uint16_t num_algs)
722 uint8_t dev_id = testsuite_params.valid_devs[0];
723 bool some_alg_supported = FALSE;
726 for (i = 0; i < num_algs && !some_alg_supported; i++) {
727 struct rte_cryptodev_sym_capability_idx alg = {
730 if (rte_cryptodev_sym_capability_get(dev_id,
732 some_alg_supported = TRUE;
734 if (!some_alg_supported)
741 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
742 uint16_t num_ciphers)
744 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
745 (const int *) ciphers, num_ciphers);
749 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
752 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
753 (const int *) auths, num_auths);
757 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
760 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
761 (const int *) aeads, num_aeads);
765 null_testsuite_setup(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint8_t dev_id = ts_params->valid_devs[0];
769 struct rte_cryptodev_info dev_info;
770 const enum rte_crypto_cipher_algorithm ciphers[] = {
771 RTE_CRYPTO_CIPHER_NULL
773 const enum rte_crypto_auth_algorithm auths[] = {
777 rte_cryptodev_info_get(dev_id, &dev_info);
779 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
780 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
781 "testsuite not met\n");
785 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
786 && check_auth_capabilities_supported(auths,
787 RTE_DIM(auths)) != 0) {
788 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
789 "testsuite not met\n");
797 crypto_gen_testsuite_setup(void)
799 struct crypto_testsuite_params *ts_params = &testsuite_params;
800 uint8_t dev_id = ts_params->valid_devs[0];
801 struct rte_cryptodev_info dev_info;
803 rte_cryptodev_info_get(dev_id, &dev_info);
805 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
806 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
807 "testsuite not met\n");
814 #ifdef RTE_LIB_SECURITY
816 ipsec_proto_testsuite_setup(void)
818 struct crypto_testsuite_params *ts_params = &testsuite_params;
819 struct crypto_unittest_params *ut_params = &unittest_params;
820 struct rte_cryptodev_info dev_info;
823 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
825 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
826 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
827 "testsuite not met\n");
831 /* Reconfigure to enable security */
832 ret = dev_configure_and_start(0);
833 if (ret != TEST_SUCCESS)
836 /* Set action type */
837 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
839 if (security_proto_supported(
840 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
841 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
842 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
847 test_ipsec_alg_list_populate();
848 test_ipsec_ah_alg_list_populate();
851 * Stop the device. Device would be started again by individual test
852 * case setup routine.
854 rte_cryptodev_stop(ts_params->valid_devs[0]);
860 pdcp_proto_testsuite_setup(void)
862 struct crypto_testsuite_params *ts_params = &testsuite_params;
863 uint8_t dev_id = ts_params->valid_devs[0];
864 struct rte_cryptodev_info dev_info;
865 const enum rte_crypto_cipher_algorithm ciphers[] = {
866 RTE_CRYPTO_CIPHER_NULL,
867 RTE_CRYPTO_CIPHER_AES_CTR,
868 RTE_CRYPTO_CIPHER_ZUC_EEA3,
869 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
871 const enum rte_crypto_auth_algorithm auths[] = {
872 RTE_CRYPTO_AUTH_NULL,
873 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
874 RTE_CRYPTO_AUTH_AES_CMAC,
875 RTE_CRYPTO_AUTH_ZUC_EIA3
878 rte_cryptodev_info_get(dev_id, &dev_info);
880 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
881 !(dev_info.feature_flags &
882 RTE_CRYPTODEV_FF_SECURITY)) {
883 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
884 "testsuite not met\n");
888 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
889 && check_auth_capabilities_supported(auths,
890 RTE_DIM(auths)) != 0) {
891 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
892 "testsuite not met\n");
900 docsis_proto_testsuite_setup(void)
902 struct crypto_testsuite_params *ts_params = &testsuite_params;
903 uint8_t dev_id = ts_params->valid_devs[0];
904 struct rte_cryptodev_info dev_info;
905 const enum rte_crypto_cipher_algorithm ciphers[] = {
906 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
909 rte_cryptodev_info_get(dev_id, &dev_info);
911 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
912 !(dev_info.feature_flags &
913 RTE_CRYPTODEV_FF_SECURITY)) {
914 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
915 "Proto testsuite not met\n");
919 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
920 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
921 "testsuite not met\n");
930 aes_ccm_auth_testsuite_setup(void)
932 struct crypto_testsuite_params *ts_params = &testsuite_params;
933 uint8_t dev_id = ts_params->valid_devs[0];
934 struct rte_cryptodev_info dev_info;
935 const enum rte_crypto_aead_algorithm aeads[] = {
936 RTE_CRYPTO_AEAD_AES_CCM
939 rte_cryptodev_info_get(dev_id, &dev_info);
941 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
942 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
943 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
944 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
945 "testsuite not met\n");
949 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
950 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
951 "testsuite not met\n");
959 aes_gcm_auth_testsuite_setup(void)
961 struct crypto_testsuite_params *ts_params = &testsuite_params;
962 uint8_t dev_id = ts_params->valid_devs[0];
963 struct rte_cryptodev_info dev_info;
964 const enum rte_crypto_aead_algorithm aeads[] = {
965 RTE_CRYPTO_AEAD_AES_GCM
968 rte_cryptodev_info_get(dev_id, &dev_info);
970 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
971 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
972 "testsuite not met\n");
976 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
977 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
978 "testsuite not met\n");
986 aes_gmac_auth_testsuite_setup(void)
988 struct crypto_testsuite_params *ts_params = &testsuite_params;
989 uint8_t dev_id = ts_params->valid_devs[0];
990 struct rte_cryptodev_info dev_info;
991 const enum rte_crypto_auth_algorithm auths[] = {
992 RTE_CRYPTO_AUTH_AES_GMAC
995 rte_cryptodev_info_get(dev_id, &dev_info);
997 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
998 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
999 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1000 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1001 "testsuite not met\n");
1002 return TEST_SKIPPED;
1005 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1006 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1007 "testsuite not met\n");
1008 return TEST_SKIPPED;
1015 chacha20_poly1305_testsuite_setup(void)
1017 struct crypto_testsuite_params *ts_params = &testsuite_params;
1018 uint8_t dev_id = ts_params->valid_devs[0];
1019 struct rte_cryptodev_info dev_info;
1020 const enum rte_crypto_aead_algorithm aeads[] = {
1021 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1024 rte_cryptodev_info_get(dev_id, &dev_info);
1026 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1027 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1028 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1029 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1030 "Chacha20-Poly1305 testsuite not met\n");
1031 return TEST_SKIPPED;
1034 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1035 RTE_LOG(INFO, USER1, "Capability requirements for "
1036 "Chacha20-Poly1305 testsuite not met\n");
1037 return TEST_SKIPPED;
1044 snow3g_testsuite_setup(void)
1046 struct crypto_testsuite_params *ts_params = &testsuite_params;
1047 uint8_t dev_id = ts_params->valid_devs[0];
1048 struct rte_cryptodev_info dev_info;
1049 const enum rte_crypto_cipher_algorithm ciphers[] = {
1050 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1053 const enum rte_crypto_auth_algorithm auths[] = {
1054 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1057 rte_cryptodev_info_get(dev_id, &dev_info);
1059 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1060 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1061 "testsuite not met\n");
1062 return TEST_SKIPPED;
1065 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1066 && check_auth_capabilities_supported(auths,
1067 RTE_DIM(auths)) != 0) {
1068 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1069 "testsuite not met\n");
1070 return TEST_SKIPPED;
1077 zuc_testsuite_setup(void)
1079 struct crypto_testsuite_params *ts_params = &testsuite_params;
1080 uint8_t dev_id = ts_params->valid_devs[0];
1081 struct rte_cryptodev_info dev_info;
1082 const enum rte_crypto_cipher_algorithm ciphers[] = {
1083 RTE_CRYPTO_CIPHER_ZUC_EEA3
1085 const enum rte_crypto_auth_algorithm auths[] = {
1086 RTE_CRYPTO_AUTH_ZUC_EIA3
1089 rte_cryptodev_info_get(dev_id, &dev_info);
1091 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1092 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1093 "testsuite not met\n");
1094 return TEST_SKIPPED;
1097 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1098 && check_auth_capabilities_supported(auths,
1099 RTE_DIM(auths)) != 0) {
1100 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1101 "testsuite not met\n");
1102 return TEST_SKIPPED;
1109 hmac_md5_auth_testsuite_setup(void)
1111 struct crypto_testsuite_params *ts_params = &testsuite_params;
1112 uint8_t dev_id = ts_params->valid_devs[0];
1113 struct rte_cryptodev_info dev_info;
1114 const enum rte_crypto_auth_algorithm auths[] = {
1115 RTE_CRYPTO_AUTH_MD5_HMAC
1118 rte_cryptodev_info_get(dev_id, &dev_info);
1120 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1121 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1122 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1123 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1124 "Auth testsuite not met\n");
1125 return TEST_SKIPPED;
1128 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1129 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1130 "testsuite not met\n");
1131 return TEST_SKIPPED;
1138 kasumi_testsuite_setup(void)
1140 struct crypto_testsuite_params *ts_params = &testsuite_params;
1141 uint8_t dev_id = ts_params->valid_devs[0];
1142 struct rte_cryptodev_info dev_info;
1143 const enum rte_crypto_cipher_algorithm ciphers[] = {
1144 RTE_CRYPTO_CIPHER_KASUMI_F8
1146 const enum rte_crypto_auth_algorithm auths[] = {
1147 RTE_CRYPTO_AUTH_KASUMI_F9
1150 rte_cryptodev_info_get(dev_id, &dev_info);
1152 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1153 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1154 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1155 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1156 "testsuite not met\n");
1157 return TEST_SKIPPED;
1160 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1161 && check_auth_capabilities_supported(auths,
1162 RTE_DIM(auths)) != 0) {
1163 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1164 "testsuite not met\n");
1165 return TEST_SKIPPED;
1172 negative_aes_gcm_testsuite_setup(void)
1174 struct crypto_testsuite_params *ts_params = &testsuite_params;
1175 uint8_t dev_id = ts_params->valid_devs[0];
1176 struct rte_cryptodev_info dev_info;
1177 const enum rte_crypto_aead_algorithm aeads[] = {
1178 RTE_CRYPTO_AEAD_AES_GCM
1181 rte_cryptodev_info_get(dev_id, &dev_info);
1183 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1184 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1185 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1186 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1187 "AES GCM testsuite not met\n");
1188 return TEST_SKIPPED;
1191 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1192 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1193 "AES GCM testsuite not met\n");
1194 return TEST_SKIPPED;
1201 negative_aes_gmac_testsuite_setup(void)
1203 struct crypto_testsuite_params *ts_params = &testsuite_params;
1204 uint8_t dev_id = ts_params->valid_devs[0];
1205 struct rte_cryptodev_info dev_info;
1206 const enum rte_crypto_auth_algorithm auths[] = {
1207 RTE_CRYPTO_AUTH_AES_GMAC
1210 rte_cryptodev_info_get(dev_id, &dev_info);
1212 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1213 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1214 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1215 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1216 "AES GMAC testsuite not met\n");
1217 return TEST_SKIPPED;
1220 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1221 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1222 "AES GMAC testsuite not met\n");
1223 return TEST_SKIPPED;
1230 mixed_cipher_hash_testsuite_setup(void)
1232 struct crypto_testsuite_params *ts_params = &testsuite_params;
1233 uint8_t dev_id = ts_params->valid_devs[0];
1234 struct rte_cryptodev_info dev_info;
1235 uint64_t feat_flags;
1236 const enum rte_crypto_cipher_algorithm ciphers[] = {
1237 RTE_CRYPTO_CIPHER_NULL,
1238 RTE_CRYPTO_CIPHER_AES_CTR,
1239 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1240 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1242 const enum rte_crypto_auth_algorithm auths[] = {
1243 RTE_CRYPTO_AUTH_NULL,
1244 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1245 RTE_CRYPTO_AUTH_AES_CMAC,
1246 RTE_CRYPTO_AUTH_ZUC_EIA3
1249 rte_cryptodev_info_get(dev_id, &dev_info);
1250 feat_flags = dev_info.feature_flags;
1252 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1253 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1254 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1255 "Cipher Hash testsuite not met\n");
1256 return TEST_SKIPPED;
1259 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1260 && check_auth_capabilities_supported(auths,
1261 RTE_DIM(auths)) != 0) {
1262 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1263 "Cipher Hash testsuite not met\n");
1264 return TEST_SKIPPED;
1271 esn_testsuite_setup(void)
1273 struct crypto_testsuite_params *ts_params = &testsuite_params;
1274 uint8_t dev_id = ts_params->valid_devs[0];
1275 struct rte_cryptodev_info dev_info;
1276 const enum rte_crypto_cipher_algorithm ciphers[] = {
1277 RTE_CRYPTO_CIPHER_AES_CBC
1279 const enum rte_crypto_auth_algorithm auths[] = {
1280 RTE_CRYPTO_AUTH_SHA1_HMAC
1283 rte_cryptodev_info_get(dev_id, &dev_info);
1285 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1286 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1287 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1288 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1289 "testsuite not met\n");
1290 return TEST_SKIPPED;
1293 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1294 && check_auth_capabilities_supported(auths,
1295 RTE_DIM(auths)) != 0) {
1296 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1297 "testsuite not met\n");
1298 return TEST_SKIPPED;
1305 multi_session_testsuite_setup(void)
1307 struct crypto_testsuite_params *ts_params = &testsuite_params;
1308 uint8_t dev_id = ts_params->valid_devs[0];
1309 struct rte_cryptodev_info dev_info;
1310 const enum rte_crypto_cipher_algorithm ciphers[] = {
1311 RTE_CRYPTO_CIPHER_AES_CBC
1313 const enum rte_crypto_auth_algorithm auths[] = {
1314 RTE_CRYPTO_AUTH_SHA512_HMAC
1317 rte_cryptodev_info_get(dev_id, &dev_info);
1319 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1320 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1321 "Session testsuite not met\n");
1322 return TEST_SKIPPED;
1325 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1326 && check_auth_capabilities_supported(auths,
1327 RTE_DIM(auths)) != 0) {
1328 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1329 "Session testsuite not met\n");
1330 return TEST_SKIPPED;
1337 negative_hmac_sha1_testsuite_setup(void)
1339 struct crypto_testsuite_params *ts_params = &testsuite_params;
1340 uint8_t dev_id = ts_params->valid_devs[0];
1341 struct rte_cryptodev_info dev_info;
1342 const enum rte_crypto_cipher_algorithm ciphers[] = {
1343 RTE_CRYPTO_CIPHER_AES_CBC
1345 const enum rte_crypto_auth_algorithm auths[] = {
1346 RTE_CRYPTO_AUTH_SHA1_HMAC
1349 rte_cryptodev_info_get(dev_id, &dev_info);
1351 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1352 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1353 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1354 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1355 "HMAC SHA1 testsuite not met\n");
1356 return TEST_SKIPPED;
1359 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1360 && check_auth_capabilities_supported(auths,
1361 RTE_DIM(auths)) != 0) {
1362 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1363 "HMAC SHA1 testsuite not met\n");
1364 return TEST_SKIPPED;
1371 dev_configure_and_start(uint64_t ff_disable)
1373 struct crypto_testsuite_params *ts_params = &testsuite_params;
1374 struct crypto_unittest_params *ut_params = &unittest_params;
1378 /* Clear unit test parameters before running test */
1379 memset(ut_params, 0, sizeof(*ut_params));
1381 /* Reconfigure device to default parameters */
1382 ts_params->conf.socket_id = SOCKET_ID_ANY;
1383 ts_params->conf.ff_disable = ff_disable;
1384 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1385 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1386 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1388 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1390 "Failed to configure cryptodev %u",
1391 ts_params->valid_devs[0]);
1393 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1394 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1395 ts_params->valid_devs[0], qp_id,
1396 &ts_params->qp_conf,
1397 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1398 "Failed to setup queue pair %u on cryptodev %u",
1399 qp_id, ts_params->valid_devs[0]);
1403 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1405 /* Start the device */
1406 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1407 "Failed to start cryptodev %u",
1408 ts_params->valid_devs[0]);
1410 return TEST_SUCCESS;
1416 /* Configure and start the device with security feature disabled */
1417 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1421 ut_setup_security(void)
1423 /* Configure and start the device with no features disabled */
1424 return dev_configure_and_start(0);
1430 struct crypto_testsuite_params *ts_params = &testsuite_params;
1431 struct crypto_unittest_params *ut_params = &unittest_params;
1433 /* free crypto session structure */
1434 #ifdef RTE_LIB_SECURITY
1435 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1436 if (ut_params->sec_session) {
1437 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1438 (ts_params->valid_devs[0]),
1439 ut_params->sec_session);
1440 ut_params->sec_session = NULL;
1445 if (ut_params->sess) {
1446 rte_cryptodev_sym_session_clear(
1447 ts_params->valid_devs[0],
1449 rte_cryptodev_sym_session_free(ut_params->sess);
1450 ut_params->sess = NULL;
1454 /* free crypto operation structure */
1456 rte_crypto_op_free(ut_params->op);
1459 * free mbuf - both obuf and ibuf are usually the same,
1460 * so check if they point at the same address is necessary,
1461 * to avoid freeing the mbuf twice.
1463 if (ut_params->obuf) {
1464 rte_pktmbuf_free(ut_params->obuf);
1465 if (ut_params->ibuf == ut_params->obuf)
1466 ut_params->ibuf = 0;
1467 ut_params->obuf = 0;
1469 if (ut_params->ibuf) {
1470 rte_pktmbuf_free(ut_params->ibuf);
1471 ut_params->ibuf = 0;
1474 if (ts_params->mbuf_pool != NULL)
1475 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1476 rte_mempool_avail_count(ts_params->mbuf_pool));
1478 /* Stop the device */
1479 rte_cryptodev_stop(ts_params->valid_devs[0]);
1483 test_device_configure_invalid_dev_id(void)
1485 struct crypto_testsuite_params *ts_params = &testsuite_params;
1486 uint16_t dev_id, num_devs = 0;
1488 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1489 "Need at least %d devices for test", 1);
1491 /* valid dev_id values */
1492 dev_id = ts_params->valid_devs[0];
1494 /* Stop the device in case it's started so it can be configured */
1495 rte_cryptodev_stop(dev_id);
1497 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1498 "Failed test for rte_cryptodev_configure: "
1499 "invalid dev_num %u", dev_id);
1501 /* invalid dev_id values */
1504 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1505 "Failed test for rte_cryptodev_configure: "
1506 "invalid dev_num %u", dev_id);
1510 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1511 "Failed test for rte_cryptodev_configure:"
1512 "invalid dev_num %u", dev_id);
1514 return TEST_SUCCESS;
1518 test_device_configure_invalid_queue_pair_ids(void)
1520 struct crypto_testsuite_params *ts_params = &testsuite_params;
1521 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1523 /* Stop the device in case it's started so it can be configured */
1524 rte_cryptodev_stop(ts_params->valid_devs[0]);
1526 /* valid - max value queue pairs */
1527 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1529 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1531 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1532 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1534 /* valid - one queue pairs */
1535 ts_params->conf.nb_queue_pairs = 1;
1537 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1539 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1540 ts_params->valid_devs[0],
1541 ts_params->conf.nb_queue_pairs);
1544 /* invalid - zero queue pairs */
1545 ts_params->conf.nb_queue_pairs = 0;
1547 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1549 "Failed test for rte_cryptodev_configure, dev_id %u,"
1551 ts_params->valid_devs[0],
1552 ts_params->conf.nb_queue_pairs);
1555 /* invalid - max value supported by field queue pairs */
1556 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1558 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1560 "Failed test for rte_cryptodev_configure, dev_id %u,"
1562 ts_params->valid_devs[0],
1563 ts_params->conf.nb_queue_pairs);
1566 /* invalid - max value + 1 queue pairs */
1567 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1569 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1571 "Failed test for rte_cryptodev_configure, dev_id %u,"
1573 ts_params->valid_devs[0],
1574 ts_params->conf.nb_queue_pairs);
1576 /* revert to original testsuite value */
1577 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1579 return TEST_SUCCESS;
1583 test_queue_pair_descriptor_setup(void)
1585 struct crypto_testsuite_params *ts_params = &testsuite_params;
1586 struct rte_cryptodev_qp_conf qp_conf = {
1587 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1591 /* Stop the device in case it's started so it can be configured */
1592 rte_cryptodev_stop(ts_params->valid_devs[0]);
1594 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1596 "Failed to configure cryptodev %u",
1597 ts_params->valid_devs[0]);
1600 * Test various ring sizes on this device. memzones can't be
1601 * freed so are re-used if ring is released and re-created.
1603 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1604 qp_conf.mp_session = ts_params->session_mpool;
1605 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1607 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1608 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1609 ts_params->valid_devs[0], qp_id, &qp_conf,
1610 rte_cryptodev_socket_id(
1611 ts_params->valid_devs[0])),
1613 "rte_cryptodev_queue_pair_setup: num_inflights "
1614 "%u on qp %u on cryptodev %u",
1615 qp_conf.nb_descriptors, qp_id,
1616 ts_params->valid_devs[0]);
1619 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1621 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1622 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1623 ts_params->valid_devs[0], qp_id, &qp_conf,
1624 rte_cryptodev_socket_id(
1625 ts_params->valid_devs[0])),
1627 " rte_cryptodev_queue_pair_setup: num_inflights"
1628 " %u on qp %u on cryptodev %u",
1629 qp_conf.nb_descriptors, qp_id,
1630 ts_params->valid_devs[0]);
1633 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1635 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1636 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1637 ts_params->valid_devs[0], qp_id, &qp_conf,
1638 rte_cryptodev_socket_id(
1639 ts_params->valid_devs[0])),
1641 "rte_cryptodev_queue_pair_setup: num_inflights"
1642 " %u on qp %u on cryptodev %u",
1643 qp_conf.nb_descriptors, qp_id,
1644 ts_params->valid_devs[0]);
1647 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1649 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1650 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1651 ts_params->valid_devs[0], qp_id, &qp_conf,
1652 rte_cryptodev_socket_id(
1653 ts_params->valid_devs[0])),
1655 " rte_cryptodev_queue_pair_setup:"
1656 "num_inflights %u on qp %u on cryptodev %u",
1657 qp_conf.nb_descriptors, qp_id,
1658 ts_params->valid_devs[0]);
1661 /* test invalid queue pair id */
1662 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1664 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1666 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1667 ts_params->valid_devs[0],
1669 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1670 "Failed test for rte_cryptodev_queue_pair_setup:"
1671 "invalid qp %u on cryptodev %u",
1672 qp_id, ts_params->valid_devs[0]);
1674 qp_id = 0xffff; /*invalid*/
1676 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1677 ts_params->valid_devs[0],
1679 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1680 "Failed test for rte_cryptodev_queue_pair_setup:"
1681 "invalid qp %u on cryptodev %u",
1682 qp_id, ts_params->valid_devs[0]);
1684 return TEST_SUCCESS;
1687 /* ***** Plaintext data for tests ***** */
1689 const char catch_22_quote_1[] =
1690 "There was only one catch and that was Catch-22, which "
1691 "specified that a concern for one's safety in the face of "
1692 "dangers that were real and immediate was the process of a "
1693 "rational mind. Orr was crazy and could be grounded. All he "
1694 "had to do was ask; and as soon as he did, he would no longer "
1695 "be crazy and would have to fly more missions. Orr would be "
1696 "crazy to fly more missions and sane if he didn't, but if he "
1697 "was sane he had to fly them. If he flew them he was crazy "
1698 "and didn't have to; but if he didn't want to he was sane and "
1699 "had to. Yossarian was moved very deeply by the absolute "
1700 "simplicity of this clause of Catch-22 and let out a "
1701 "respectful whistle. \"That's some catch, that Catch-22\", he "
1702 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1704 const char catch_22_quote[] =
1705 "What a lousy earth! He wondered how many people were "
1706 "destitute that same night even in his own prosperous country, "
1707 "how many homes were shanties, how many husbands were drunk "
1708 "and wives socked, and how many children were bullied, abused, "
1709 "or abandoned. How many families hungered for food they could "
1710 "not afford to buy? How many hearts were broken? How many "
1711 "suicides would take place that same night, how many people "
1712 "would go insane? How many cockroaches and landlords would "
1713 "triumph? How many winners were losers, successes failures, "
1714 "and rich men poor men? How many wise guys were stupid? How "
1715 "many happy endings were unhappy endings? How many honest men "
1716 "were liars, brave men cowards, loyal men traitors, how many "
1717 "sainted men were corrupt, how many people in positions of "
1718 "trust had sold their souls to bodyguards, how many had never "
1719 "had souls? How many straight-and-narrow paths were crooked "
1720 "paths? How many best families were worst families and how "
1721 "many good people were bad people? When you added them all up "
1722 "and then subtracted, you might be left with only the children, "
1723 "and perhaps with Albert Einstein and an old violinist or "
1724 "sculptor somewhere.";
1726 #define QUOTE_480_BYTES (480)
1727 #define QUOTE_512_BYTES (512)
1728 #define QUOTE_768_BYTES (768)
1729 #define QUOTE_1024_BYTES (1024)
1733 /* ***** SHA1 Hash Tests ***** */
1735 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1737 static uint8_t hmac_sha1_key[] = {
1738 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1739 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1740 0xDE, 0xF4, 0xDE, 0xAD };
1742 /* ***** SHA224 Hash Tests ***** */
1744 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1747 /* ***** AES-CBC Cipher Tests ***** */
1749 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1750 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1752 static uint8_t aes_cbc_key[] = {
1753 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1754 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1756 static uint8_t aes_cbc_iv[] = {
1757 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1758 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1761 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1763 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1764 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1765 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1766 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1767 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1768 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1769 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1770 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1771 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1772 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1773 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1774 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1775 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1776 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1777 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1778 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1779 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1780 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1781 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1782 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1783 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1784 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1785 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1786 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1787 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1788 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1789 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1790 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1791 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1792 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1793 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1794 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1795 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1796 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1797 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1798 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1799 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1800 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1801 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1802 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1803 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1804 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1805 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1806 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1807 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1808 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1809 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1810 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1811 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1812 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1813 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1814 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1815 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1816 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1817 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1818 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1819 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1820 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1821 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1822 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1823 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1824 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1825 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1826 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1827 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1830 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1831 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1832 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1833 0x18, 0x8c, 0x1d, 0x32
1837 /* Multisession Vector context Test */
1838 /*Begin Session 0 */
1839 static uint8_t ms_aes_cbc_key0[] = {
1840 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1841 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1844 static uint8_t ms_aes_cbc_iv0[] = {
1845 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1846 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1849 static const uint8_t ms_aes_cbc_cipher0[] = {
1850 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1851 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1852 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1853 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1854 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1855 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1856 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1857 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1858 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1859 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1860 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1861 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1862 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1863 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1864 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1865 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1866 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1867 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1868 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1869 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1870 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1871 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1872 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1873 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1874 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1875 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1876 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1877 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1878 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1879 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1880 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1881 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1882 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1883 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1884 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1885 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1886 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1887 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1888 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1889 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1890 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1891 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1892 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1893 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1894 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1895 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1896 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1897 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1898 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1899 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1900 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1901 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1902 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1903 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1904 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1905 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1906 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1907 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1908 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1909 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1910 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1911 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1912 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1913 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1917 static uint8_t ms_hmac_key0[] = {
1918 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1919 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1920 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1921 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1922 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1923 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1924 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1925 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1928 static const uint8_t ms_hmac_digest0[] = {
1929 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1930 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1931 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1932 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1933 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1934 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1935 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1936 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1940 /* Begin session 1 */
1942 static uint8_t ms_aes_cbc_key1[] = {
1943 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1944 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1947 static uint8_t ms_aes_cbc_iv1[] = {
1948 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1952 static const uint8_t ms_aes_cbc_cipher1[] = {
1953 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1954 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1955 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1956 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1957 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1958 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1959 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1960 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1961 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1962 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1963 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1964 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1965 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1966 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1967 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1968 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1969 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1970 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1971 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1972 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1973 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1974 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1975 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1976 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1977 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1978 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1979 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1980 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1981 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1982 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1983 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1984 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1985 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1986 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1987 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1988 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1989 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1990 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1991 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1992 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1993 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1994 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1995 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1996 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1997 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1998 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1999 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2000 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2001 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2002 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2003 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2004 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2005 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2006 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2007 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2008 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2009 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2010 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2011 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2012 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2013 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2014 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2015 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2016 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2020 static uint8_t ms_hmac_key1[] = {
2021 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2022 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2023 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2024 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2025 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2026 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2027 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2028 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2031 static const uint8_t ms_hmac_digest1[] = {
2032 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2033 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2034 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2035 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2036 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2037 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2038 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2039 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2042 /* Begin Session 2 */
2043 static uint8_t ms_aes_cbc_key2[] = {
2044 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2045 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2048 static uint8_t ms_aes_cbc_iv2[] = {
2049 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2050 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2053 static const uint8_t ms_aes_cbc_cipher2[] = {
2054 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2055 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2056 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2057 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2058 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2059 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2060 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2061 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2062 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2063 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2064 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2065 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2066 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2067 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2068 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2069 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2070 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2071 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2072 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2073 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2074 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2075 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2076 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2077 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2078 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2079 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2080 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2081 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2082 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2083 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2084 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2085 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2086 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2087 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2088 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2089 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2090 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2091 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2092 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2093 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2094 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2095 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2096 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2097 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2098 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2099 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2100 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2101 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2102 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2103 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2104 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2105 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2106 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2107 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2108 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2109 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2110 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2111 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2112 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2113 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2114 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2115 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2116 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2117 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2120 static uint8_t ms_hmac_key2[] = {
2121 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2122 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2123 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2124 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2125 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2126 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2127 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2128 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2131 static const uint8_t ms_hmac_digest2[] = {
2132 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2133 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2134 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2135 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2136 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2137 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2138 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2139 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2146 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2148 struct crypto_testsuite_params *ts_params = &testsuite_params;
2149 struct crypto_unittest_params *ut_params = &unittest_params;
2152 /* Verify the capabilities */
2153 struct rte_cryptodev_sym_capability_idx cap_idx;
2154 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2155 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2156 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2158 return TEST_SKIPPED;
2159 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2160 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2161 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2163 return TEST_SKIPPED;
2165 /* Generate test mbuf data and space for digest */
2166 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2167 catch_22_quote, QUOTE_512_BYTES, 0);
2169 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2170 DIGEST_BYTE_LENGTH_SHA1);
2171 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2173 /* Setup Cipher Parameters */
2174 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2175 ut_params->cipher_xform.next = &ut_params->auth_xform;
2177 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2178 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2179 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2180 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2181 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2182 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2184 /* Setup HMAC Parameters */
2185 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2187 ut_params->auth_xform.next = NULL;
2189 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2190 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2191 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2192 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2193 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2195 ut_params->sess = rte_cryptodev_sym_session_create(
2196 ts_params->session_mpool);
2197 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2199 /* Create crypto session*/
2200 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2201 ut_params->sess, &ut_params->cipher_xform,
2202 ts_params->session_priv_mpool);
2204 if (status == -ENOTSUP)
2205 return TEST_SKIPPED;
2207 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2209 /* Generate crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate symmetric crypto operation struct");
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2222 /* Set crypto operation authentication parameters */
2223 sym_op->auth.digest.data = ut_params->digest;
2224 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2225 ut_params->ibuf, QUOTE_512_BYTES);
2227 sym_op->auth.data.offset = 0;
2228 sym_op->auth.data.length = QUOTE_512_BYTES;
2230 /* Copy IV at the end of the crypto operation */
2231 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2232 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2234 /* Set crypto operation cipher parameters */
2235 sym_op->cipher.data.offset = 0;
2236 sym_op->cipher.data.length = QUOTE_512_BYTES;
2238 /* Process crypto operation */
2239 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2240 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2243 TEST_ASSERT_NOT_NULL(
2244 process_crypto_request(ts_params->valid_devs[0],
2246 "failed to process sym crypto op");
2248 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2249 "crypto op processing failed");
2252 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2255 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2256 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2258 "ciphertext data not as expected");
2260 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2262 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2263 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2264 gbl_driver_id == rte_cryptodev_driver_id_get(
2265 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2266 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2267 DIGEST_BYTE_LENGTH_SHA1,
2268 "Generated digest data not as expected");
2270 return TEST_SUCCESS;
2273 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2275 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2277 static uint8_t hmac_sha512_key[] = {
2278 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2279 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2280 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2281 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2282 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2283 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2284 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2285 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2287 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2288 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2289 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2290 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2291 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2292 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2293 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2294 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2295 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2300 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2301 struct crypto_unittest_params *ut_params,
2302 uint8_t *cipher_key,
2306 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2307 struct crypto_unittest_params *ut_params,
2308 struct crypto_testsuite_params *ts_params,
2309 const uint8_t *cipher,
2310 const uint8_t *digest,
2315 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2316 struct crypto_unittest_params *ut_params,
2317 uint8_t *cipher_key,
2321 /* Setup Cipher Parameters */
2322 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2323 ut_params->cipher_xform.next = NULL;
2325 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2326 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2327 ut_params->cipher_xform.cipher.key.data = cipher_key;
2328 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2329 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2330 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2332 /* Setup HMAC Parameters */
2333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2334 ut_params->auth_xform.next = &ut_params->cipher_xform;
2336 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2337 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2338 ut_params->auth_xform.auth.key.data = hmac_key;
2339 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2340 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2342 return TEST_SUCCESS;
2347 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2348 struct crypto_unittest_params *ut_params,
2349 struct crypto_testsuite_params *ts_params,
2350 const uint8_t *cipher,
2351 const uint8_t *digest,
2354 /* Generate test mbuf data and digest */
2355 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2358 QUOTE_512_BYTES, 0);
2360 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2361 DIGEST_BYTE_LENGTH_SHA512);
2362 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2364 rte_memcpy(ut_params->digest,
2366 DIGEST_BYTE_LENGTH_SHA512);
2368 /* Generate Crypto op data structure */
2369 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2370 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2371 TEST_ASSERT_NOT_NULL(ut_params->op,
2372 "Failed to allocate symmetric crypto operation struct");
2374 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2376 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2378 /* set crypto operation source mbuf */
2379 sym_op->m_src = ut_params->ibuf;
2381 sym_op->auth.digest.data = ut_params->digest;
2382 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2383 ut_params->ibuf, QUOTE_512_BYTES);
2385 sym_op->auth.data.offset = 0;
2386 sym_op->auth.data.length = QUOTE_512_BYTES;
2388 /* Copy IV at the end of the crypto operation */
2389 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2390 iv, CIPHER_IV_LENGTH_AES_CBC);
2392 sym_op->cipher.data.offset = 0;
2393 sym_op->cipher.data.length = QUOTE_512_BYTES;
2395 /* Process crypto operation */
2396 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2397 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2399 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2400 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2401 ut_params->op, 1, 1, 0, 0);
2403 TEST_ASSERT_NOT_NULL(
2404 process_crypto_request(ts_params->valid_devs[0],
2406 "failed to process sym crypto op");
2408 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2409 "crypto op processing failed");
2411 ut_params->obuf = ut_params->op->sym->m_src;
2414 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2415 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2418 "Plaintext data not as expected");
2421 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2422 "Digest verification failed");
2424 return TEST_SUCCESS;
2427 /* ***** SNOW 3G Tests ***** */
2429 create_wireless_algo_hash_session(uint8_t dev_id,
2430 const uint8_t *key, const uint8_t key_len,
2431 const uint8_t iv_len, const uint8_t auth_len,
2432 enum rte_crypto_auth_operation op,
2433 enum rte_crypto_auth_algorithm algo)
2435 uint8_t hash_key[key_len];
2438 struct crypto_testsuite_params *ts_params = &testsuite_params;
2439 struct crypto_unittest_params *ut_params = &unittest_params;
2441 memcpy(hash_key, key, key_len);
2443 debug_hexdump(stdout, "key:", key, key_len);
2445 /* Setup Authentication Parameters */
2446 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2447 ut_params->auth_xform.next = NULL;
2449 ut_params->auth_xform.auth.op = op;
2450 ut_params->auth_xform.auth.algo = algo;
2451 ut_params->auth_xform.auth.key.length = key_len;
2452 ut_params->auth_xform.auth.key.data = hash_key;
2453 ut_params->auth_xform.auth.digest_length = auth_len;
2454 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2455 ut_params->auth_xform.auth.iv.length = iv_len;
2456 ut_params->sess = rte_cryptodev_sym_session_create(
2457 ts_params->session_mpool);
2459 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2460 &ut_params->auth_xform,
2461 ts_params->session_priv_mpool);
2462 if (status == -ENOTSUP)
2463 return TEST_SKIPPED;
2465 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2466 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2471 create_wireless_algo_cipher_session(uint8_t dev_id,
2472 enum rte_crypto_cipher_operation op,
2473 enum rte_crypto_cipher_algorithm algo,
2474 const uint8_t *key, const uint8_t key_len,
2477 uint8_t cipher_key[key_len];
2479 struct crypto_testsuite_params *ts_params = &testsuite_params;
2480 struct crypto_unittest_params *ut_params = &unittest_params;
2482 memcpy(cipher_key, key, key_len);
2484 /* Setup Cipher Parameters */
2485 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2486 ut_params->cipher_xform.next = NULL;
2488 ut_params->cipher_xform.cipher.algo = algo;
2489 ut_params->cipher_xform.cipher.op = op;
2490 ut_params->cipher_xform.cipher.key.data = cipher_key;
2491 ut_params->cipher_xform.cipher.key.length = key_len;
2492 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2493 ut_params->cipher_xform.cipher.iv.length = iv_len;
2495 debug_hexdump(stdout, "key:", key, key_len);
2497 /* Create Crypto session */
2498 ut_params->sess = rte_cryptodev_sym_session_create(
2499 ts_params->session_mpool);
2501 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2502 &ut_params->cipher_xform,
2503 ts_params->session_priv_mpool);
2504 if (status == -ENOTSUP)
2505 return TEST_SKIPPED;
2507 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2508 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2513 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2514 unsigned int cipher_len,
2515 unsigned int cipher_offset)
2517 struct crypto_testsuite_params *ts_params = &testsuite_params;
2518 struct crypto_unittest_params *ut_params = &unittest_params;
2520 /* Generate Crypto op data structure */
2521 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2522 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2523 TEST_ASSERT_NOT_NULL(ut_params->op,
2524 "Failed to allocate pktmbuf offload");
2526 /* Set crypto operation data parameters */
2527 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2529 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2531 /* set crypto operation source mbuf */
2532 sym_op->m_src = ut_params->ibuf;
2535 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2537 sym_op->cipher.data.length = cipher_len;
2538 sym_op->cipher.data.offset = cipher_offset;
2543 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2544 unsigned int cipher_len,
2545 unsigned int cipher_offset)
2547 struct crypto_testsuite_params *ts_params = &testsuite_params;
2548 struct crypto_unittest_params *ut_params = &unittest_params;
2550 /* Generate Crypto op data structure */
2551 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2552 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2553 TEST_ASSERT_NOT_NULL(ut_params->op,
2554 "Failed to allocate pktmbuf offload");
2556 /* Set crypto operation data parameters */
2557 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2559 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2561 /* set crypto operation source mbuf */
2562 sym_op->m_src = ut_params->ibuf;
2563 sym_op->m_dst = ut_params->obuf;
2566 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2568 sym_op->cipher.data.length = cipher_len;
2569 sym_op->cipher.data.offset = cipher_offset;
2574 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2575 enum rte_crypto_cipher_operation cipher_op,
2576 enum rte_crypto_auth_operation auth_op,
2577 enum rte_crypto_auth_algorithm auth_algo,
2578 enum rte_crypto_cipher_algorithm cipher_algo,
2579 const uint8_t *key, uint8_t key_len,
2580 uint8_t auth_iv_len, uint8_t auth_len,
2581 uint8_t cipher_iv_len)
2584 uint8_t cipher_auth_key[key_len];
2587 struct crypto_testsuite_params *ts_params = &testsuite_params;
2588 struct crypto_unittest_params *ut_params = &unittest_params;
2590 memcpy(cipher_auth_key, key, key_len);
2592 /* Setup Authentication Parameters */
2593 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2594 ut_params->auth_xform.next = NULL;
2596 ut_params->auth_xform.auth.op = auth_op;
2597 ut_params->auth_xform.auth.algo = auth_algo;
2598 ut_params->auth_xform.auth.key.length = key_len;
2599 /* Hash key = cipher key */
2600 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2601 ut_params->auth_xform.auth.digest_length = auth_len;
2602 /* Auth IV will be after cipher IV */
2603 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2604 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2606 /* Setup Cipher Parameters */
2607 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2608 ut_params->cipher_xform.next = &ut_params->auth_xform;
2610 ut_params->cipher_xform.cipher.algo = cipher_algo;
2611 ut_params->cipher_xform.cipher.op = cipher_op;
2612 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2613 ut_params->cipher_xform.cipher.key.length = key_len;
2614 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2615 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2617 debug_hexdump(stdout, "key:", key, key_len);
2619 /* Create Crypto session*/
2620 ut_params->sess = rte_cryptodev_sym_session_create(
2621 ts_params->session_mpool);
2622 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2624 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2625 &ut_params->cipher_xform,
2626 ts_params->session_priv_mpool);
2627 if (status == -ENOTSUP)
2628 return TEST_SKIPPED;
2630 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2635 create_wireless_cipher_auth_session(uint8_t dev_id,
2636 enum rte_crypto_cipher_operation cipher_op,
2637 enum rte_crypto_auth_operation auth_op,
2638 enum rte_crypto_auth_algorithm auth_algo,
2639 enum rte_crypto_cipher_algorithm cipher_algo,
2640 const struct wireless_test_data *tdata)
2642 const uint8_t key_len = tdata->key.len;
2643 uint8_t cipher_auth_key[key_len];
2646 struct crypto_testsuite_params *ts_params = &testsuite_params;
2647 struct crypto_unittest_params *ut_params = &unittest_params;
2648 const uint8_t *key = tdata->key.data;
2649 const uint8_t auth_len = tdata->digest.len;
2650 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2651 uint8_t auth_iv_len = tdata->auth_iv.len;
2653 memcpy(cipher_auth_key, key, key_len);
2655 /* Setup Authentication Parameters */
2656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2657 ut_params->auth_xform.next = NULL;
2659 ut_params->auth_xform.auth.op = auth_op;
2660 ut_params->auth_xform.auth.algo = auth_algo;
2661 ut_params->auth_xform.auth.key.length = key_len;
2662 /* Hash key = cipher key */
2663 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2664 ut_params->auth_xform.auth.digest_length = auth_len;
2665 /* Auth IV will be after cipher IV */
2666 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2667 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2669 /* Setup Cipher Parameters */
2670 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2671 ut_params->cipher_xform.next = &ut_params->auth_xform;
2673 ut_params->cipher_xform.cipher.algo = cipher_algo;
2674 ut_params->cipher_xform.cipher.op = cipher_op;
2675 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2676 ut_params->cipher_xform.cipher.key.length = key_len;
2677 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2678 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2681 debug_hexdump(stdout, "key:", key, key_len);
2683 /* Create Crypto session*/
2684 ut_params->sess = rte_cryptodev_sym_session_create(
2685 ts_params->session_mpool);
2687 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2688 &ut_params->cipher_xform,
2689 ts_params->session_priv_mpool);
2690 if (status == -ENOTSUP)
2691 return TEST_SKIPPED;
2693 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2694 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2699 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2700 const struct wireless_test_data *tdata)
2702 return create_wireless_cipher_auth_session(dev_id,
2703 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2704 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2705 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2709 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2710 enum rte_crypto_cipher_operation cipher_op,
2711 enum rte_crypto_auth_operation auth_op,
2712 enum rte_crypto_auth_algorithm auth_algo,
2713 enum rte_crypto_cipher_algorithm cipher_algo,
2714 const uint8_t *key, const uint8_t key_len,
2715 uint8_t auth_iv_len, uint8_t auth_len,
2716 uint8_t cipher_iv_len)
2718 uint8_t auth_cipher_key[key_len];
2720 struct crypto_testsuite_params *ts_params = &testsuite_params;
2721 struct crypto_unittest_params *ut_params = &unittest_params;
2723 memcpy(auth_cipher_key, key, key_len);
2725 /* Setup Authentication Parameters */
2726 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2727 ut_params->auth_xform.auth.op = auth_op;
2728 ut_params->auth_xform.next = &ut_params->cipher_xform;
2729 ut_params->auth_xform.auth.algo = auth_algo;
2730 ut_params->auth_xform.auth.key.length = key_len;
2731 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2732 ut_params->auth_xform.auth.digest_length = auth_len;
2733 /* Auth IV will be after cipher IV */
2734 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2735 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2737 /* Setup Cipher Parameters */
2738 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2739 ut_params->cipher_xform.next = NULL;
2740 ut_params->cipher_xform.cipher.algo = cipher_algo;
2741 ut_params->cipher_xform.cipher.op = cipher_op;
2742 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2743 ut_params->cipher_xform.cipher.key.length = key_len;
2744 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2745 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2747 debug_hexdump(stdout, "key:", key, key_len);
2749 /* Create Crypto session*/
2750 ut_params->sess = rte_cryptodev_sym_session_create(
2751 ts_params->session_mpool);
2752 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2754 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2755 ut_params->auth_xform.next = NULL;
2756 ut_params->cipher_xform.next = &ut_params->auth_xform;
2757 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2758 &ut_params->cipher_xform,
2759 ts_params->session_priv_mpool);
2762 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2763 &ut_params->auth_xform,
2764 ts_params->session_priv_mpool);
2766 if (status == -ENOTSUP)
2767 return TEST_SKIPPED;
2769 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2775 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2776 unsigned int auth_tag_len,
2777 const uint8_t *iv, unsigned int iv_len,
2778 unsigned int data_pad_len,
2779 enum rte_crypto_auth_operation op,
2780 unsigned int auth_len, unsigned int auth_offset)
2782 struct crypto_testsuite_params *ts_params = &testsuite_params;
2784 struct crypto_unittest_params *ut_params = &unittest_params;
2786 /* Generate Crypto op data structure */
2787 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2788 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2789 TEST_ASSERT_NOT_NULL(ut_params->op,
2790 "Failed to allocate pktmbuf offload");
2792 /* Set crypto operation data parameters */
2793 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2795 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2797 /* set crypto operation source mbuf */
2798 sym_op->m_src = ut_params->ibuf;
2801 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2804 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2805 ut_params->ibuf, auth_tag_len);
2807 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2808 "no room to append auth tag");
2809 ut_params->digest = sym_op->auth.digest.data;
2810 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2811 ut_params->ibuf, data_pad_len);
2812 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2813 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2815 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2817 debug_hexdump(stdout, "digest:",
2818 sym_op->auth.digest.data,
2821 sym_op->auth.data.length = auth_len;
2822 sym_op->auth.data.offset = auth_offset;
2828 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2829 enum rte_crypto_auth_operation op)
2831 struct crypto_testsuite_params *ts_params = &testsuite_params;
2832 struct crypto_unittest_params *ut_params = &unittest_params;
2834 const uint8_t *auth_tag = tdata->digest.data;
2835 const unsigned int auth_tag_len = tdata->digest.len;
2836 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2837 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2839 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2840 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2841 const uint8_t *auth_iv = tdata->auth_iv.data;
2842 const uint8_t auth_iv_len = tdata->auth_iv.len;
2843 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2844 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2846 /* Generate Crypto op data structure */
2847 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2848 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2849 TEST_ASSERT_NOT_NULL(ut_params->op,
2850 "Failed to allocate pktmbuf offload");
2851 /* Set crypto operation data parameters */
2852 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2854 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2856 /* set crypto operation source mbuf */
2857 sym_op->m_src = ut_params->ibuf;
2860 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2861 ut_params->ibuf, auth_tag_len);
2863 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2864 "no room to append auth tag");
2865 ut_params->digest = sym_op->auth.digest.data;
2866 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2867 ut_params->ibuf, data_pad_len);
2868 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2869 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2871 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2873 debug_hexdump(stdout, "digest:",
2874 sym_op->auth.digest.data,
2877 /* Copy cipher and auth IVs at the end of the crypto operation */
2878 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2880 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2881 iv_ptr += cipher_iv_len;
2882 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2884 sym_op->cipher.data.length = cipher_len;
2885 sym_op->cipher.data.offset = 0;
2886 sym_op->auth.data.length = auth_len;
2887 sym_op->auth.data.offset = 0;
2893 create_zuc_cipher_hash_generate_operation(
2894 const struct wireless_test_data *tdata)
2896 return create_wireless_cipher_hash_operation(tdata,
2897 RTE_CRYPTO_AUTH_OP_GENERATE);
2901 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2902 const unsigned auth_tag_len,
2903 const uint8_t *auth_iv, uint8_t auth_iv_len,
2904 unsigned data_pad_len,
2905 enum rte_crypto_auth_operation op,
2906 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2907 const unsigned cipher_len, const unsigned cipher_offset,
2908 const unsigned auth_len, const unsigned auth_offset)
2910 struct crypto_testsuite_params *ts_params = &testsuite_params;
2911 struct crypto_unittest_params *ut_params = &unittest_params;
2913 enum rte_crypto_cipher_algorithm cipher_algo =
2914 ut_params->cipher_xform.cipher.algo;
2915 enum rte_crypto_auth_algorithm auth_algo =
2916 ut_params->auth_xform.auth.algo;
2918 /* Generate Crypto op data structure */
2919 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2920 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2921 TEST_ASSERT_NOT_NULL(ut_params->op,
2922 "Failed to allocate pktmbuf offload");
2923 /* Set crypto operation data parameters */
2924 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2926 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2928 /* set crypto operation source mbuf */
2929 sym_op->m_src = ut_params->ibuf;
2932 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2933 ut_params->ibuf, auth_tag_len);
2935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2936 "no room to append auth tag");
2937 ut_params->digest = sym_op->auth.digest.data;
2939 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2940 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2941 ut_params->ibuf, data_pad_len);
2943 struct rte_mbuf *m = ut_params->ibuf;
2944 unsigned int offset = data_pad_len;
2946 while (offset > m->data_len && m->next != NULL) {
2947 offset -= m->data_len;
2950 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2954 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2955 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2957 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2959 debug_hexdump(stdout, "digest:",
2960 sym_op->auth.digest.data,
2963 /* Copy cipher and auth IVs at the end of the crypto operation */
2964 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2966 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2967 iv_ptr += cipher_iv_len;
2968 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2970 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2971 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2972 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2973 sym_op->cipher.data.length = cipher_len;
2974 sym_op->cipher.data.offset = cipher_offset;
2976 sym_op->cipher.data.length = cipher_len >> 3;
2977 sym_op->cipher.data.offset = cipher_offset >> 3;
2980 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2981 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2982 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2983 sym_op->auth.data.length = auth_len;
2984 sym_op->auth.data.offset = auth_offset;
2986 sym_op->auth.data.length = auth_len >> 3;
2987 sym_op->auth.data.offset = auth_offset >> 3;
2994 create_wireless_algo_auth_cipher_operation(
2995 const uint8_t *auth_tag, unsigned int auth_tag_len,
2996 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2997 const uint8_t *auth_iv, uint8_t auth_iv_len,
2998 unsigned int data_pad_len,
2999 unsigned int cipher_len, unsigned int cipher_offset,
3000 unsigned int auth_len, unsigned int auth_offset,
3001 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3003 struct crypto_testsuite_params *ts_params = &testsuite_params;
3004 struct crypto_unittest_params *ut_params = &unittest_params;
3006 enum rte_crypto_cipher_algorithm cipher_algo =
3007 ut_params->cipher_xform.cipher.algo;
3008 enum rte_crypto_auth_algorithm auth_algo =
3009 ut_params->auth_xform.auth.algo;
3011 /* Generate Crypto op data structure */
3012 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3013 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3014 TEST_ASSERT_NOT_NULL(ut_params->op,
3015 "Failed to allocate pktmbuf offload");
3017 /* Set crypto operation data parameters */
3018 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3020 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3022 /* set crypto operation mbufs */
3023 sym_op->m_src = ut_params->ibuf;
3024 if (op_mode == OUT_OF_PLACE)
3025 sym_op->m_dst = ut_params->obuf;
3029 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3030 (op_mode == IN_PLACE ?
3031 ut_params->ibuf : ut_params->obuf),
3032 uint8_t *, data_pad_len);
3033 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3034 (op_mode == IN_PLACE ?
3035 ut_params->ibuf : ut_params->obuf),
3037 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3039 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3040 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3041 sym_op->m_src : sym_op->m_dst);
3042 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3043 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3044 sgl_buf = sgl_buf->next;
3046 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3047 uint8_t *, remaining_off);
3048 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3050 memset(sym_op->auth.digest.data, 0, remaining_off);
3051 while (sgl_buf->next != NULL) {
3052 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3053 0, rte_pktmbuf_data_len(sgl_buf));
3054 sgl_buf = sgl_buf->next;
3058 /* Copy digest for the verification */
3060 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3062 /* Copy cipher and auth IVs at the end of the crypto operation */
3063 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3064 ut_params->op, uint8_t *, IV_OFFSET);
3066 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3067 iv_ptr += cipher_iv_len;
3068 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3070 /* Only copy over the offset data needed from src to dst in OOP,
3071 * if the auth and cipher offsets are not aligned
3073 if (op_mode == OUT_OF_PLACE) {
3074 if (cipher_offset > auth_offset)
3076 rte_pktmbuf_mtod_offset(
3078 uint8_t *, auth_offset >> 3),
3079 rte_pktmbuf_mtod_offset(
3081 uint8_t *, auth_offset >> 3),
3082 ((cipher_offset >> 3) - (auth_offset >> 3)));
3085 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3086 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3087 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3088 sym_op->cipher.data.length = cipher_len;
3089 sym_op->cipher.data.offset = cipher_offset;
3091 sym_op->cipher.data.length = cipher_len >> 3;
3092 sym_op->cipher.data.offset = cipher_offset >> 3;
3095 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3096 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3097 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3098 sym_op->auth.data.length = auth_len;
3099 sym_op->auth.data.offset = auth_offset;
3101 sym_op->auth.data.length = auth_len >> 3;
3102 sym_op->auth.data.offset = auth_offset >> 3;
3109 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3111 struct crypto_testsuite_params *ts_params = &testsuite_params;
3112 struct crypto_unittest_params *ut_params = &unittest_params;
3115 unsigned plaintext_pad_len;
3116 unsigned plaintext_len;
3118 struct rte_cryptodev_info dev_info;
3120 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3121 uint64_t feat_flags = dev_info.feature_flags;
3123 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3124 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3125 printf("Device doesn't support NON-Byte Aligned Data.\n");
3126 return TEST_SKIPPED;
3129 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3130 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3131 printf("Device doesn't support RAW data-path APIs.\n");
3132 return TEST_SKIPPED;
3135 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3136 return TEST_SKIPPED;
3138 /* Verify the capabilities */
3139 struct rte_cryptodev_sym_capability_idx cap_idx;
3140 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3141 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3142 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3144 return TEST_SKIPPED;
3146 /* Create SNOW 3G session */
3147 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3148 tdata->key.data, tdata->key.len,
3149 tdata->auth_iv.len, tdata->digest.len,
3150 RTE_CRYPTO_AUTH_OP_GENERATE,
3151 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3155 /* alloc mbuf and set payload */
3156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3158 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3159 rte_pktmbuf_tailroom(ut_params->ibuf));
3161 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3162 /* Append data which is padded to a multiple of */
3163 /* the algorithms block size */
3164 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3165 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3167 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3169 /* Create SNOW 3G operation */
3170 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3171 tdata->auth_iv.data, tdata->auth_iv.len,
3172 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3173 tdata->validAuthLenInBits.len,
3178 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3179 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3180 ut_params->op, 0, 1, 1, 0);
3182 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3184 ut_params->obuf = ut_params->op->sym->m_src;
3185 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3186 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3187 + plaintext_pad_len;
3190 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3193 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3194 "SNOW 3G Generated auth tag not as expected");
3200 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3202 struct crypto_testsuite_params *ts_params = &testsuite_params;
3203 struct crypto_unittest_params *ut_params = &unittest_params;
3206 unsigned plaintext_pad_len;
3207 unsigned plaintext_len;
3209 struct rte_cryptodev_info dev_info;
3211 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3212 uint64_t feat_flags = dev_info.feature_flags;
3214 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3215 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3216 printf("Device doesn't support NON-Byte Aligned Data.\n");
3217 return TEST_SKIPPED;
3220 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3221 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3222 printf("Device doesn't support RAW data-path APIs.\n");
3223 return TEST_SKIPPED;
3226 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3227 return TEST_SKIPPED;
3229 /* Verify the capabilities */
3230 struct rte_cryptodev_sym_capability_idx cap_idx;
3231 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3232 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3233 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3235 return TEST_SKIPPED;
3237 /* Create SNOW 3G session */
3238 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3239 tdata->key.data, tdata->key.len,
3240 tdata->auth_iv.len, tdata->digest.len,
3241 RTE_CRYPTO_AUTH_OP_VERIFY,
3242 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3245 /* alloc mbuf and set payload */
3246 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3248 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3249 rte_pktmbuf_tailroom(ut_params->ibuf));
3251 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3252 /* Append data which is padded to a multiple of */
3253 /* the algorithms block size */
3254 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3255 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3257 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3259 /* Create SNOW 3G operation */
3260 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3262 tdata->auth_iv.data, tdata->auth_iv.len,
3264 RTE_CRYPTO_AUTH_OP_VERIFY,
3265 tdata->validAuthLenInBits.len,
3270 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3271 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3272 ut_params->op, 0, 1, 1, 0);
3274 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3276 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3277 ut_params->obuf = ut_params->op->sym->m_src;
3278 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3279 + plaintext_pad_len;
3282 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3291 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3293 struct crypto_testsuite_params *ts_params = &testsuite_params;
3294 struct crypto_unittest_params *ut_params = &unittest_params;
3297 unsigned plaintext_pad_len;
3298 unsigned plaintext_len;
3300 struct rte_cryptodev_info dev_info;
3302 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3303 uint64_t feat_flags = dev_info.feature_flags;
3305 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3306 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3307 printf("Device doesn't support RAW data-path APIs.\n");
3308 return TEST_SKIPPED;
3311 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3312 return TEST_SKIPPED;
3314 /* Verify the capabilities */
3315 struct rte_cryptodev_sym_capability_idx cap_idx;
3316 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3317 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3318 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3320 return TEST_SKIPPED;
3322 /* Create KASUMI session */
3323 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3324 tdata->key.data, tdata->key.len,
3325 0, tdata->digest.len,
3326 RTE_CRYPTO_AUTH_OP_GENERATE,
3327 RTE_CRYPTO_AUTH_KASUMI_F9);
3331 /* alloc mbuf and set payload */
3332 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3335 rte_pktmbuf_tailroom(ut_params->ibuf));
3337 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3338 /* Append data which is padded to a multiple of */
3339 /* the algorithms block size */
3340 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3341 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3343 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3345 /* Create KASUMI operation */
3346 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3348 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3349 tdata->plaintext.len,
3354 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3355 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3357 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3358 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3359 ut_params->op, 0, 1, 1, 0);
3361 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3364 ut_params->obuf = ut_params->op->sym->m_src;
3365 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3366 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3367 + plaintext_pad_len;
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3373 DIGEST_BYTE_LENGTH_KASUMI_F9,
3374 "KASUMI Generated auth tag not as expected");
3380 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3382 struct crypto_testsuite_params *ts_params = &testsuite_params;
3383 struct crypto_unittest_params *ut_params = &unittest_params;
3386 unsigned plaintext_pad_len;
3387 unsigned plaintext_len;
3389 struct rte_cryptodev_info dev_info;
3391 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3392 uint64_t feat_flags = dev_info.feature_flags;
3394 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3395 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3396 printf("Device doesn't support RAW data-path APIs.\n");
3397 return TEST_SKIPPED;
3400 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3401 return TEST_SKIPPED;
3403 /* Verify the capabilities */
3404 struct rte_cryptodev_sym_capability_idx cap_idx;
3405 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3406 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3407 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3409 return TEST_SKIPPED;
3411 /* Create KASUMI session */
3412 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3413 tdata->key.data, tdata->key.len,
3414 0, tdata->digest.len,
3415 RTE_CRYPTO_AUTH_OP_VERIFY,
3416 RTE_CRYPTO_AUTH_KASUMI_F9);
3419 /* alloc mbuf and set payload */
3420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3422 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3423 rte_pktmbuf_tailroom(ut_params->ibuf));
3425 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3426 /* Append data which is padded to a multiple */
3427 /* of the algorithms block size */
3428 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3429 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3431 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3433 /* Create KASUMI operation */
3434 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3438 RTE_CRYPTO_AUTH_OP_VERIFY,
3439 tdata->plaintext.len,
3444 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3445 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3446 ut_params->op, 0, 1, 1, 0);
3448 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3451 ut_params->obuf = ut_params->op->sym->m_src;
3452 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3453 + plaintext_pad_len;
3456 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3465 test_snow3g_hash_generate_test_case_1(void)
3467 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3471 test_snow3g_hash_generate_test_case_2(void)
3473 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3477 test_snow3g_hash_generate_test_case_3(void)
3479 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3483 test_snow3g_hash_generate_test_case_4(void)
3485 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3489 test_snow3g_hash_generate_test_case_5(void)
3491 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3495 test_snow3g_hash_generate_test_case_6(void)
3497 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3501 test_snow3g_hash_verify_test_case_1(void)
3503 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3508 test_snow3g_hash_verify_test_case_2(void)
3510 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3514 test_snow3g_hash_verify_test_case_3(void)
3516 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3520 test_snow3g_hash_verify_test_case_4(void)
3522 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3526 test_snow3g_hash_verify_test_case_5(void)
3528 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3532 test_snow3g_hash_verify_test_case_6(void)
3534 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3538 test_kasumi_hash_generate_test_case_1(void)
3540 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3544 test_kasumi_hash_generate_test_case_2(void)
3546 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3550 test_kasumi_hash_generate_test_case_3(void)
3552 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3556 test_kasumi_hash_generate_test_case_4(void)
3558 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3562 test_kasumi_hash_generate_test_case_5(void)
3564 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3568 test_kasumi_hash_generate_test_case_6(void)
3570 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3574 test_kasumi_hash_verify_test_case_1(void)
3576 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3580 test_kasumi_hash_verify_test_case_2(void)
3582 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3586 test_kasumi_hash_verify_test_case_3(void)
3588 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3592 test_kasumi_hash_verify_test_case_4(void)
3594 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3598 test_kasumi_hash_verify_test_case_5(void)
3600 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3604 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3606 struct crypto_testsuite_params *ts_params = &testsuite_params;
3607 struct crypto_unittest_params *ut_params = &unittest_params;
3610 uint8_t *plaintext, *ciphertext;
3611 unsigned plaintext_pad_len;
3612 unsigned plaintext_len;
3613 struct rte_cryptodev_info dev_info;
3615 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3616 uint64_t feat_flags = dev_info.feature_flags;
3618 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3619 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3620 printf("Device doesn't support RAW data-path APIs.\n");
3621 return TEST_SKIPPED;
3624 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3625 return TEST_SKIPPED;
3627 /* Verify the capabilities */
3628 struct rte_cryptodev_sym_capability_idx cap_idx;
3629 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3630 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3631 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3633 return TEST_SKIPPED;
3635 /* Create KASUMI session */
3636 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3637 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3638 RTE_CRYPTO_CIPHER_KASUMI_F8,
3639 tdata->key.data, tdata->key.len,
3640 tdata->cipher_iv.len);
3644 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3646 /* Clear mbuf payload */
3647 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3648 rte_pktmbuf_tailroom(ut_params->ibuf));
3650 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3651 /* Append data which is padded to a multiple */
3652 /* of the algorithms block size */
3653 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3654 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3656 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3658 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3660 /* Create KASUMI operation */
3661 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3662 tdata->cipher_iv.len,
3663 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3664 tdata->validCipherOffsetInBits.len);
3668 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3669 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3670 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3672 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3674 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3676 ut_params->obuf = ut_params->op->sym->m_dst;
3677 if (ut_params->obuf)
3678 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3680 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3682 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3684 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3685 (tdata->validCipherOffsetInBits.len >> 3);
3687 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3689 reference_ciphertext,
3690 tdata->validCipherLenInBits.len,
3691 "KASUMI Ciphertext data not as expected");
3696 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3698 struct crypto_testsuite_params *ts_params = &testsuite_params;
3699 struct crypto_unittest_params *ut_params = &unittest_params;
3703 unsigned int plaintext_pad_len;
3704 unsigned int plaintext_len;
3706 uint8_t buffer[10000];
3707 const uint8_t *ciphertext;
3709 struct rte_cryptodev_info dev_info;
3711 /* Verify the capabilities */
3712 struct rte_cryptodev_sym_capability_idx cap_idx;
3713 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3714 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3715 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3717 return TEST_SKIPPED;
3719 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3721 uint64_t feat_flags = dev_info.feature_flags;
3723 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3724 printf("Device doesn't support in-place scatter-gather. "
3726 return TEST_SKIPPED;
3729 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3730 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3731 printf("Device doesn't support RAW data-path APIs.\n");
3732 return TEST_SKIPPED;
3735 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3736 return TEST_SKIPPED;
3738 /* Create KASUMI session */
3739 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3740 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3741 RTE_CRYPTO_CIPHER_KASUMI_F8,
3742 tdata->key.data, tdata->key.len,
3743 tdata->cipher_iv.len);
3747 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3750 /* Append data which is padded to a multiple */
3751 /* of the algorithms block size */
3752 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3754 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3755 plaintext_pad_len, 10, 0);
3757 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3759 /* Create KASUMI operation */
3760 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3761 tdata->cipher_iv.len,
3762 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3763 tdata->validCipherOffsetInBits.len);
3767 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3768 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3769 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3771 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3773 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3775 ut_params->obuf = ut_params->op->sym->m_dst;
3777 if (ut_params->obuf)
3778 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3779 plaintext_len, buffer);
3781 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3782 tdata->validCipherOffsetInBits.len >> 3,
3783 plaintext_len, buffer);
3786 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3788 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3789 (tdata->validCipherOffsetInBits.len >> 3);
3791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3793 reference_ciphertext,
3794 tdata->validCipherLenInBits.len,
3795 "KASUMI Ciphertext data not as expected");
3800 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3802 struct crypto_testsuite_params *ts_params = &testsuite_params;
3803 struct crypto_unittest_params *ut_params = &unittest_params;
3806 uint8_t *plaintext, *ciphertext;
3807 unsigned plaintext_pad_len;
3808 unsigned plaintext_len;
3810 /* Verify the capabilities */
3811 struct rte_cryptodev_sym_capability_idx cap_idx;
3812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3813 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3814 /* Data-path service does not support OOP */
3815 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3817 return TEST_SKIPPED;
3819 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3820 return TEST_SKIPPED;
3822 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3823 return TEST_SKIPPED;
3825 /* Create KASUMI session */
3826 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3827 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3828 RTE_CRYPTO_CIPHER_KASUMI_F8,
3829 tdata->key.data, tdata->key.len,
3830 tdata->cipher_iv.len);
3834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3835 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837 /* Clear mbuf payload */
3838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3839 rte_pktmbuf_tailroom(ut_params->ibuf));
3841 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3842 /* Append data which is padded to a multiple */
3843 /* of the algorithms block size */
3844 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3845 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3847 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3848 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3850 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3852 /* Create KASUMI operation */
3853 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3854 tdata->cipher_iv.len,
3855 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3856 tdata->validCipherOffsetInBits.len);
3860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3864 ut_params->obuf = ut_params->op->sym->m_dst;
3865 if (ut_params->obuf)
3866 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3868 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3870 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3872 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3873 (tdata->validCipherOffsetInBits.len >> 3);
3875 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3877 reference_ciphertext,
3878 tdata->validCipherLenInBits.len,
3879 "KASUMI Ciphertext data not as expected");
3884 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3886 struct crypto_testsuite_params *ts_params = &testsuite_params;
3887 struct crypto_unittest_params *ut_params = &unittest_params;
3890 unsigned int plaintext_pad_len;
3891 unsigned int plaintext_len;
3893 const uint8_t *ciphertext;
3894 uint8_t buffer[2048];
3896 struct rte_cryptodev_info dev_info;
3898 /* Verify the capabilities */
3899 struct rte_cryptodev_sym_capability_idx cap_idx;
3900 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3901 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3902 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3904 return TEST_SKIPPED;
3906 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3907 return TEST_SKIPPED;
3909 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3910 return TEST_SKIPPED;
3912 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3914 uint64_t feat_flags = dev_info.feature_flags;
3915 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3916 printf("Device doesn't support out-of-place scatter-gather "
3917 "in both input and output mbufs. "
3919 return TEST_SKIPPED;
3922 /* Create KASUMI session */
3923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3924 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3925 RTE_CRYPTO_CIPHER_KASUMI_F8,
3926 tdata->key.data, tdata->key.len,
3927 tdata->cipher_iv.len);
3931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3932 /* Append data which is padded to a multiple */
3933 /* of the algorithms block size */
3934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3936 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3937 plaintext_pad_len, 10, 0);
3938 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3939 plaintext_pad_len, 3, 0);
3941 /* Append data which is padded to a multiple */
3942 /* of the algorithms block size */
3943 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3945 /* Create KASUMI operation */
3946 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3947 tdata->cipher_iv.len,
3948 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3949 tdata->validCipherOffsetInBits.len);
3953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3957 ut_params->obuf = ut_params->op->sym->m_dst;
3958 if (ut_params->obuf)
3959 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3960 plaintext_pad_len, buffer);
3962 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3963 tdata->validCipherOffsetInBits.len >> 3,
3964 plaintext_pad_len, buffer);
3966 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3967 (tdata->validCipherOffsetInBits.len >> 3);
3969 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3971 reference_ciphertext,
3972 tdata->validCipherLenInBits.len,
3973 "KASUMI Ciphertext data not as expected");
3979 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3981 struct crypto_testsuite_params *ts_params = &testsuite_params;
3982 struct crypto_unittest_params *ut_params = &unittest_params;
3985 uint8_t *ciphertext, *plaintext;
3986 unsigned ciphertext_pad_len;
3987 unsigned ciphertext_len;
3989 /* Verify the capabilities */
3990 struct rte_cryptodev_sym_capability_idx cap_idx;
3991 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3992 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3993 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3995 return TEST_SKIPPED;
3997 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3998 return TEST_SKIPPED;
4000 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4001 return TEST_SKIPPED;
4003 /* Create KASUMI session */
4004 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4005 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4006 RTE_CRYPTO_CIPHER_KASUMI_F8,
4007 tdata->key.data, tdata->key.len,
4008 tdata->cipher_iv.len);
4012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4015 /* Clear mbuf payload */
4016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4017 rte_pktmbuf_tailroom(ut_params->ibuf));
4019 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4020 /* Append data which is padded to a multiple */
4021 /* of the algorithms block size */
4022 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4023 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4024 ciphertext_pad_len);
4025 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4026 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4028 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4030 /* Create KASUMI operation */
4031 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4032 tdata->cipher_iv.len,
4033 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4034 tdata->validCipherOffsetInBits.len);
4038 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4040 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4042 ut_params->obuf = ut_params->op->sym->m_dst;
4043 if (ut_params->obuf)
4044 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4046 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4048 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4050 const uint8_t *reference_plaintext = tdata->plaintext.data +
4051 (tdata->validCipherOffsetInBits.len >> 3);
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4055 reference_plaintext,
4056 tdata->validCipherLenInBits.len,
4057 "KASUMI Plaintext data not as expected");
4062 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4064 struct crypto_testsuite_params *ts_params = &testsuite_params;
4065 struct crypto_unittest_params *ut_params = &unittest_params;
4068 uint8_t *ciphertext, *plaintext;
4069 unsigned ciphertext_pad_len;
4070 unsigned ciphertext_len;
4071 struct rte_cryptodev_info dev_info;
4073 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4074 uint64_t feat_flags = dev_info.feature_flags;
4076 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4077 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4078 printf("Device doesn't support RAW data-path APIs.\n");
4079 return TEST_SKIPPED;
4082 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4083 return TEST_SKIPPED;
4085 /* Verify the capabilities */
4086 struct rte_cryptodev_sym_capability_idx cap_idx;
4087 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4088 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4089 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4091 return TEST_SKIPPED;
4093 /* Create KASUMI session */
4094 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4095 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4096 RTE_CRYPTO_CIPHER_KASUMI_F8,
4097 tdata->key.data, tdata->key.len,
4098 tdata->cipher_iv.len);
4102 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4104 /* Clear mbuf payload */
4105 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4106 rte_pktmbuf_tailroom(ut_params->ibuf));
4108 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4109 /* Append data which is padded to a multiple */
4110 /* of the algorithms block size */
4111 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4112 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4113 ciphertext_pad_len);
4114 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4116 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4118 /* Create KASUMI operation */
4119 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4120 tdata->cipher_iv.len,
4121 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4122 tdata->validCipherOffsetInBits.len);
4126 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4127 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4128 ut_params->op, 1, 0, 1, 0);
4130 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4132 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4134 ut_params->obuf = ut_params->op->sym->m_dst;
4135 if (ut_params->obuf)
4136 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4138 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4140 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4142 const uint8_t *reference_plaintext = tdata->plaintext.data +
4143 (tdata->validCipherOffsetInBits.len >> 3);
4145 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4147 reference_plaintext,
4148 tdata->validCipherLenInBits.len,
4149 "KASUMI Plaintext data not as expected");
4154 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4156 struct crypto_testsuite_params *ts_params = &testsuite_params;
4157 struct crypto_unittest_params *ut_params = &unittest_params;
4160 uint8_t *plaintext, *ciphertext;
4161 unsigned plaintext_pad_len;
4162 unsigned plaintext_len;
4163 struct rte_cryptodev_info dev_info;
4165 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4166 uint64_t feat_flags = dev_info.feature_flags;
4168 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4169 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4170 printf("Device doesn't support RAW data-path APIs.\n");
4171 return TEST_SKIPPED;
4174 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4175 return TEST_SKIPPED;
4177 /* Verify the capabilities */
4178 struct rte_cryptodev_sym_capability_idx cap_idx;
4179 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4180 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4181 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4183 return TEST_SKIPPED;
4185 /* Create SNOW 3G session */
4186 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4187 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4188 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4189 tdata->key.data, tdata->key.len,
4190 tdata->cipher_iv.len);
4194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4196 /* Clear mbuf payload */
4197 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4198 rte_pktmbuf_tailroom(ut_params->ibuf));
4200 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4201 /* Append data which is padded to a multiple of */
4202 /* the algorithms block size */
4203 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4204 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4206 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4208 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4210 /* Create SNOW 3G operation */
4211 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4212 tdata->cipher_iv.len,
4213 tdata->validCipherLenInBits.len,
4218 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4219 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4220 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4222 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4224 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4226 ut_params->obuf = ut_params->op->sym->m_dst;
4227 if (ut_params->obuf)
4228 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4230 ciphertext = plaintext;
4232 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4237 tdata->ciphertext.data,
4238 tdata->validDataLenInBits.len,
4239 "SNOW 3G Ciphertext data not as expected");
4245 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4247 struct crypto_testsuite_params *ts_params = &testsuite_params;
4248 struct crypto_unittest_params *ut_params = &unittest_params;
4249 uint8_t *plaintext, *ciphertext;
4252 unsigned plaintext_pad_len;
4253 unsigned plaintext_len;
4254 struct rte_cryptodev_info dev_info;
4256 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4257 uint64_t feat_flags = dev_info.feature_flags;
4259 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4260 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4261 printf("Device does not support RAW data-path APIs.\n");
4265 /* Verify the capabilities */
4266 struct rte_cryptodev_sym_capability_idx cap_idx;
4267 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4268 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4269 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4271 return TEST_SKIPPED;
4273 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4274 return TEST_SKIPPED;
4276 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4277 return TEST_SKIPPED;
4279 /* Create SNOW 3G session */
4280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4282 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4283 tdata->key.data, tdata->key.len,
4284 tdata->cipher_iv.len);
4288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4289 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4291 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4292 "Failed to allocate input buffer in mempool");
4293 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4294 "Failed to allocate output buffer in mempool");
4296 /* Clear mbuf payload */
4297 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4298 rte_pktmbuf_tailroom(ut_params->ibuf));
4300 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4301 /* Append data which is padded to a multiple of */
4302 /* the algorithms block size */
4303 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4304 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4306 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4307 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4309 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4311 /* Create SNOW 3G operation */
4312 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4313 tdata->cipher_iv.len,
4314 tdata->validCipherLenInBits.len,
4319 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4320 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4321 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4323 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4325 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4327 ut_params->obuf = ut_params->op->sym->m_dst;
4328 if (ut_params->obuf)
4329 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4331 ciphertext = plaintext;
4333 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4336 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4338 tdata->ciphertext.data,
4339 tdata->validDataLenInBits.len,
4340 "SNOW 3G Ciphertext data not as expected");
4345 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4347 struct crypto_testsuite_params *ts_params = &testsuite_params;
4348 struct crypto_unittest_params *ut_params = &unittest_params;
4351 unsigned int plaintext_pad_len;
4352 unsigned int plaintext_len;
4353 uint8_t buffer[10000];
4354 const uint8_t *ciphertext;
4356 struct rte_cryptodev_info dev_info;
4358 /* Verify the capabilities */
4359 struct rte_cryptodev_sym_capability_idx cap_idx;
4360 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4361 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4362 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4364 return TEST_SKIPPED;
4366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4367 return TEST_SKIPPED;
4369 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4370 return TEST_SKIPPED;
4372 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4374 uint64_t feat_flags = dev_info.feature_flags;
4376 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4377 printf("Device doesn't support out-of-place scatter-gather "
4378 "in both input and output mbufs. "
4380 return TEST_SKIPPED;
4383 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4384 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4385 printf("Device does not support RAW data-path APIs.\n");
4389 /* Create SNOW 3G session */
4390 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4391 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4392 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4393 tdata->key.data, tdata->key.len,
4394 tdata->cipher_iv.len);
4398 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4399 /* Append data which is padded to a multiple of */
4400 /* the algorithms block size */
4401 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4403 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4404 plaintext_pad_len, 10, 0);
4405 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4406 plaintext_pad_len, 3, 0);
4408 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4409 "Failed to allocate input buffer in mempool");
4410 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4411 "Failed to allocate output buffer in mempool");
4413 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4415 /* Create SNOW 3G operation */
4416 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4417 tdata->cipher_iv.len,
4418 tdata->validCipherLenInBits.len,
4423 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4424 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4425 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4427 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4429 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4431 ut_params->obuf = ut_params->op->sym->m_dst;
4432 if (ut_params->obuf)
4433 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4434 plaintext_len, buffer);
4436 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4437 plaintext_len, buffer);
4439 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4444 tdata->ciphertext.data,
4445 tdata->validDataLenInBits.len,
4446 "SNOW 3G Ciphertext data not as expected");
4451 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4453 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4455 uint8_t curr_byte, prev_byte;
4456 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4457 uint8_t lower_byte_mask = (1 << offset) - 1;
4460 prev_byte = buffer[0];
4461 buffer[0] >>= offset;
4463 for (i = 1; i < length_in_bytes; i++) {
4464 curr_byte = buffer[i];
4465 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4466 (curr_byte >> offset);
4467 prev_byte = curr_byte;
4472 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4474 struct crypto_testsuite_params *ts_params = &testsuite_params;
4475 struct crypto_unittest_params *ut_params = &unittest_params;
4476 uint8_t *plaintext, *ciphertext;
4478 uint32_t plaintext_len;
4479 uint32_t plaintext_pad_len;
4480 uint8_t extra_offset = 4;
4481 uint8_t *expected_ciphertext_shifted;
4482 struct rte_cryptodev_info dev_info;
4484 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4485 uint64_t feat_flags = dev_info.feature_flags;
4487 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4488 ((tdata->validDataLenInBits.len % 8) != 0)) {
4489 printf("Device doesn't support NON-Byte Aligned Data.\n");
4490 return TEST_SKIPPED;
4493 /* Verify the capabilities */
4494 struct rte_cryptodev_sym_capability_idx cap_idx;
4495 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4496 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4497 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4499 return TEST_SKIPPED;
4501 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4502 return TEST_SKIPPED;
4504 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4505 return TEST_SKIPPED;
4507 /* Create SNOW 3G session */
4508 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4509 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4510 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4511 tdata->key.data, tdata->key.len,
4512 tdata->cipher_iv.len);
4516 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4517 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4519 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4520 "Failed to allocate input buffer in mempool");
4521 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4522 "Failed to allocate output buffer in mempool");
4524 /* Clear mbuf payload */
4525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4526 rte_pktmbuf_tailroom(ut_params->ibuf));
4528 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4530 * Append data which is padded to a
4531 * multiple of the algorithms block size
4533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4535 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4538 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4540 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4541 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4543 #ifdef RTE_APP_TEST_DEBUG
4544 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4546 /* Create SNOW 3G operation */
4547 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4548 tdata->cipher_iv.len,
4549 tdata->validCipherLenInBits.len,
4554 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4555 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4556 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4558 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4560 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4562 ut_params->obuf = ut_params->op->sym->m_dst;
4563 if (ut_params->obuf)
4564 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4566 ciphertext = plaintext;
4568 #ifdef RTE_APP_TEST_DEBUG
4569 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4572 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4574 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4575 "failed to reserve memory for ciphertext shifted\n");
4577 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4578 ceil_byte_length(tdata->ciphertext.len));
4579 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4582 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4584 expected_ciphertext_shifted,
4585 tdata->validDataLenInBits.len,
4587 "SNOW 3G Ciphertext data not as expected");
4591 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4593 struct crypto_testsuite_params *ts_params = &testsuite_params;
4594 struct crypto_unittest_params *ut_params = &unittest_params;
4598 uint8_t *plaintext, *ciphertext;
4599 unsigned ciphertext_pad_len;
4600 unsigned ciphertext_len;
4601 struct rte_cryptodev_info dev_info;
4603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4604 uint64_t feat_flags = dev_info.feature_flags;
4606 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4607 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4608 printf("Device doesn't support RAW data-path APIs.\n");
4609 return TEST_SKIPPED;
4612 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4613 return TEST_SKIPPED;
4615 /* Verify the capabilities */
4616 struct rte_cryptodev_sym_capability_idx cap_idx;
4617 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4618 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4619 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4621 return TEST_SKIPPED;
4623 /* Create SNOW 3G session */
4624 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4625 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4626 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4627 tdata->key.data, tdata->key.len,
4628 tdata->cipher_iv.len);
4632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4634 /* Clear mbuf payload */
4635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4636 rte_pktmbuf_tailroom(ut_params->ibuf));
4638 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4639 /* Append data which is padded to a multiple of */
4640 /* the algorithms block size */
4641 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4642 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4643 ciphertext_pad_len);
4644 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4646 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4648 /* Create SNOW 3G operation */
4649 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4650 tdata->cipher_iv.len,
4651 tdata->validCipherLenInBits.len,
4652 tdata->cipher.offset_bits);
4656 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4657 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4658 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4660 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4663 ut_params->obuf = ut_params->op->sym->m_dst;
4664 if (ut_params->obuf)
4665 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4667 plaintext = ciphertext;
4669 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4672 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4673 tdata->plaintext.data,
4674 tdata->validDataLenInBits.len,
4675 "SNOW 3G Plaintext data not as expected");
4679 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4681 struct crypto_testsuite_params *ts_params = &testsuite_params;
4682 struct crypto_unittest_params *ut_params = &unittest_params;
4686 uint8_t *plaintext, *ciphertext;
4687 unsigned ciphertext_pad_len;
4688 unsigned ciphertext_len;
4689 struct rte_cryptodev_info dev_info;
4691 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4692 uint64_t feat_flags = dev_info.feature_flags;
4694 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4695 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4696 printf("Device does not support RAW data-path APIs.\n");
4699 /* Verify the capabilities */
4700 struct rte_cryptodev_sym_capability_idx cap_idx;
4701 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4702 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4703 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4705 return TEST_SKIPPED;
4707 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4708 return TEST_SKIPPED;
4710 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4711 return TEST_SKIPPED;
4713 /* Create SNOW 3G session */
4714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4715 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4716 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4717 tdata->key.data, tdata->key.len,
4718 tdata->cipher_iv.len);
4722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4723 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4725 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4726 "Failed to allocate input buffer");
4727 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4728 "Failed to allocate output buffer");
4730 /* Clear mbuf payload */
4731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4732 rte_pktmbuf_tailroom(ut_params->ibuf));
4734 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4735 rte_pktmbuf_tailroom(ut_params->obuf));
4737 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4738 /* Append data which is padded to a multiple of */
4739 /* the algorithms block size */
4740 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4741 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4742 ciphertext_pad_len);
4743 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4744 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4746 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4748 /* Create SNOW 3G operation */
4749 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4750 tdata->cipher_iv.len,
4751 tdata->validCipherLenInBits.len,
4756 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4757 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4758 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4760 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4762 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4763 ut_params->obuf = ut_params->op->sym->m_dst;
4764 if (ut_params->obuf)
4765 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4767 plaintext = ciphertext;
4769 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4773 tdata->plaintext.data,
4774 tdata->validDataLenInBits.len,
4775 "SNOW 3G Plaintext data not as expected");
4780 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4782 struct crypto_testsuite_params *ts_params = &testsuite_params;
4783 struct crypto_unittest_params *ut_params = &unittest_params;
4787 uint8_t *plaintext, *ciphertext;
4788 unsigned int plaintext_pad_len;
4789 unsigned int plaintext_len;
4791 struct rte_cryptodev_info dev_info;
4792 struct rte_cryptodev_sym_capability_idx cap_idx;
4794 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4795 uint64_t feat_flags = dev_info.feature_flags;
4797 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4798 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4799 (tdata->validDataLenInBits.len % 8 != 0))) {
4800 printf("Device doesn't support NON-Byte Aligned Data.\n");
4801 return TEST_SKIPPED;
4804 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4805 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4806 printf("Device doesn't support RAW data-path APIs.\n");
4807 return TEST_SKIPPED;
4810 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4811 return TEST_SKIPPED;
4813 /* Check if device supports ZUC EEA3 */
4814 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4815 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4819 return TEST_SKIPPED;
4821 /* Check if device supports ZUC EIA3 */
4822 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4823 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4825 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4827 return TEST_SKIPPED;
4829 /* Create ZUC session */
4830 retval = create_zuc_cipher_auth_encrypt_generate_session(
4831 ts_params->valid_devs[0],
4835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4837 /* clear mbuf payload */
4838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4839 rte_pktmbuf_tailroom(ut_params->ibuf));
4841 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4842 /* Append data which is padded to a multiple of */
4843 /* the algorithms block size */
4844 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4845 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4847 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4849 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4851 /* Create ZUC operation */
4852 retval = create_zuc_cipher_hash_generate_operation(tdata);
4856 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4857 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4858 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4863 ut_params->obuf = ut_params->op->sym->m_src;
4864 if (ut_params->obuf)
4865 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4867 ciphertext = plaintext;
4869 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4871 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4873 tdata->ciphertext.data,
4874 tdata->validDataLenInBits.len,
4875 "ZUC Ciphertext data not as expected");
4877 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4878 + plaintext_pad_len;
4881 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4885 "ZUC Generated auth tag not as expected");
4890 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4892 struct crypto_testsuite_params *ts_params = &testsuite_params;
4893 struct crypto_unittest_params *ut_params = &unittest_params;
4897 uint8_t *plaintext, *ciphertext;
4898 unsigned plaintext_pad_len;
4899 unsigned plaintext_len;
4900 struct rte_cryptodev_info dev_info;
4902 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4903 uint64_t feat_flags = dev_info.feature_flags;
4905 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4906 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4907 printf("Device doesn't support RAW data-path APIs.\n");
4908 return TEST_SKIPPED;
4911 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4912 return TEST_SKIPPED;
4914 /* Verify the capabilities */
4915 struct rte_cryptodev_sym_capability_idx cap_idx;
4916 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4917 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4918 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4920 return TEST_SKIPPED;
4921 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4922 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4923 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4925 return TEST_SKIPPED;
4927 /* Create SNOW 3G session */
4928 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4929 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4930 RTE_CRYPTO_AUTH_OP_GENERATE,
4931 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4932 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4933 tdata->key.data, tdata->key.len,
4934 tdata->auth_iv.len, tdata->digest.len,
4935 tdata->cipher_iv.len);
4938 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4940 /* clear mbuf payload */
4941 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4942 rte_pktmbuf_tailroom(ut_params->ibuf));
4944 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4945 /* Append data which is padded to a multiple of */
4946 /* the algorithms block size */
4947 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4948 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4950 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4952 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4954 /* Create SNOW 3G operation */
4955 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4956 tdata->digest.len, tdata->auth_iv.data,
4958 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4959 tdata->cipher_iv.data, tdata->cipher_iv.len,
4960 tdata->validCipherLenInBits.len,
4962 tdata->validAuthLenInBits.len,
4968 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4969 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4970 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4972 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4974 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4975 ut_params->obuf = ut_params->op->sym->m_src;
4976 if (ut_params->obuf)
4977 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4979 ciphertext = plaintext;
4981 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4983 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4985 tdata->ciphertext.data,
4986 tdata->validDataLenInBits.len,
4987 "SNOW 3G Ciphertext data not as expected");
4989 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4990 + plaintext_pad_len;
4993 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4996 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4997 "SNOW 3G Generated auth tag not as expected");
5002 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5003 uint8_t op_mode, uint8_t verify)
5005 struct crypto_testsuite_params *ts_params = &testsuite_params;
5006 struct crypto_unittest_params *ut_params = &unittest_params;
5010 uint8_t *plaintext = NULL, *ciphertext = NULL;
5011 unsigned int plaintext_pad_len;
5012 unsigned int plaintext_len;
5013 unsigned int ciphertext_pad_len;
5014 unsigned int ciphertext_len;
5016 struct rte_cryptodev_info dev_info;
5018 /* Verify the capabilities */
5019 struct rte_cryptodev_sym_capability_idx cap_idx;
5020 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5021 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5022 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5024 return TEST_SKIPPED;
5025 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5026 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5027 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5029 return TEST_SKIPPED;
5031 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5032 return TEST_SKIPPED;
5034 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5036 uint64_t feat_flags = dev_info.feature_flags;
5038 if (op_mode == OUT_OF_PLACE) {
5039 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5040 printf("Device doesn't support digest encrypted.\n");
5041 return TEST_SKIPPED;
5043 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5044 return TEST_SKIPPED;
5047 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5048 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5049 printf("Device doesn't support RAW data-path APIs.\n");
5050 return TEST_SKIPPED;
5053 /* Create SNOW 3G session */
5054 retval = create_wireless_algo_auth_cipher_session(
5055 ts_params->valid_devs[0],
5056 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5057 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5058 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5059 : RTE_CRYPTO_AUTH_OP_GENERATE),
5060 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5061 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5062 tdata->key.data, tdata->key.len,
5063 tdata->auth_iv.len, tdata->digest.len,
5064 tdata->cipher_iv.len);
5068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5069 if (op_mode == OUT_OF_PLACE)
5070 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5072 /* clear mbuf payload */
5073 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5074 rte_pktmbuf_tailroom(ut_params->ibuf));
5075 if (op_mode == OUT_OF_PLACE)
5076 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5077 rte_pktmbuf_tailroom(ut_params->obuf));
5079 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5080 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5081 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5082 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5085 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5086 ciphertext_pad_len);
5087 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5088 if (op_mode == OUT_OF_PLACE)
5089 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5090 debug_hexdump(stdout, "ciphertext:", ciphertext,
5093 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5095 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5096 if (op_mode == OUT_OF_PLACE)
5097 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5098 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5101 /* Create SNOW 3G operation */
5102 retval = create_wireless_algo_auth_cipher_operation(
5103 tdata->digest.data, tdata->digest.len,
5104 tdata->cipher_iv.data, tdata->cipher_iv.len,
5105 tdata->auth_iv.data, tdata->auth_iv.len,
5106 (tdata->digest.offset_bytes == 0 ?
5107 (verify ? ciphertext_pad_len : plaintext_pad_len)
5108 : tdata->digest.offset_bytes),
5109 tdata->validCipherLenInBits.len,
5110 tdata->cipher.offset_bits,
5111 tdata->validAuthLenInBits.len,
5112 tdata->auth.offset_bits,
5113 op_mode, 0, verify);
5118 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5119 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5120 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5122 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5127 ut_params->obuf = (op_mode == IN_PLACE ?
5128 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5131 if (ut_params->obuf)
5132 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5135 plaintext = ciphertext +
5136 (tdata->cipher.offset_bits >> 3);
5138 debug_hexdump(stdout, "plaintext:", plaintext,
5139 (tdata->plaintext.len >> 3) - tdata->digest.len);
5140 debug_hexdump(stdout, "plaintext expected:",
5141 tdata->plaintext.data,
5142 (tdata->plaintext.len >> 3) - tdata->digest.len);
5144 if (ut_params->obuf)
5145 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5148 ciphertext = plaintext;
5150 debug_hexdump(stdout, "ciphertext:", ciphertext,
5152 debug_hexdump(stdout, "ciphertext expected:",
5153 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5155 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5156 + (tdata->digest.offset_bytes == 0 ?
5157 plaintext_pad_len : tdata->digest.offset_bytes);
5159 debug_hexdump(stdout, "digest:", ut_params->digest,
5161 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5167 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5169 tdata->plaintext.data,
5170 (tdata->plaintext.len - tdata->cipher.offset_bits -
5171 (tdata->digest.len << 3)),
5172 tdata->cipher.offset_bits,
5173 "SNOW 3G Plaintext data not as expected");
5175 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5177 tdata->ciphertext.data,
5178 (tdata->validDataLenInBits.len -
5179 tdata->cipher.offset_bits),
5180 tdata->cipher.offset_bits,
5181 "SNOW 3G Ciphertext data not as expected");
5183 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5186 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5187 "SNOW 3G Generated auth tag not as expected");
5193 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5194 uint8_t op_mode, uint8_t verify)
5196 struct crypto_testsuite_params *ts_params = &testsuite_params;
5197 struct crypto_unittest_params *ut_params = &unittest_params;
5201 const uint8_t *plaintext = NULL;
5202 const uint8_t *ciphertext = NULL;
5203 const uint8_t *digest = NULL;
5204 unsigned int plaintext_pad_len;
5205 unsigned int plaintext_len;
5206 unsigned int ciphertext_pad_len;
5207 unsigned int ciphertext_len;
5208 uint8_t buffer[10000];
5209 uint8_t digest_buffer[10000];
5211 struct rte_cryptodev_info dev_info;
5213 /* Verify the capabilities */
5214 struct rte_cryptodev_sym_capability_idx cap_idx;
5215 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5216 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5217 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5219 return TEST_SKIPPED;
5220 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5221 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5222 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5224 return TEST_SKIPPED;
5226 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5227 return TEST_SKIPPED;
5229 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5231 uint64_t feat_flags = dev_info.feature_flags;
5233 if (op_mode == IN_PLACE) {
5234 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5235 printf("Device doesn't support in-place scatter-gather "
5236 "in both input and output mbufs.\n");
5237 return TEST_SKIPPED;
5239 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5240 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5241 printf("Device doesn't support RAW data-path APIs.\n");
5242 return TEST_SKIPPED;
5245 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5246 return TEST_SKIPPED;
5247 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5248 printf("Device doesn't support out-of-place scatter-gather "
5249 "in both input and output mbufs.\n");
5250 return TEST_SKIPPED;
5252 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5253 printf("Device doesn't support digest encrypted.\n");
5254 return TEST_SKIPPED;
5258 /* Create SNOW 3G session */
5259 retval = create_wireless_algo_auth_cipher_session(
5260 ts_params->valid_devs[0],
5261 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5262 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5263 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5264 : RTE_CRYPTO_AUTH_OP_GENERATE),
5265 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5266 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5267 tdata->key.data, tdata->key.len,
5268 tdata->auth_iv.len, tdata->digest.len,
5269 tdata->cipher_iv.len);
5274 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5275 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5276 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5277 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5279 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5280 plaintext_pad_len, 15, 0);
5281 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5282 "Failed to allocate input buffer in mempool");
5284 if (op_mode == OUT_OF_PLACE) {
5285 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5286 plaintext_pad_len, 15, 0);
5287 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5288 "Failed to allocate output buffer in mempool");
5292 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5293 tdata->ciphertext.data);
5294 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5295 ciphertext_len, buffer);
5296 debug_hexdump(stdout, "ciphertext:", ciphertext,
5299 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5300 tdata->plaintext.data);
5301 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5302 plaintext_len, buffer);
5303 debug_hexdump(stdout, "plaintext:", plaintext,
5306 memset(buffer, 0, sizeof(buffer));
5308 /* Create SNOW 3G operation */
5309 retval = create_wireless_algo_auth_cipher_operation(
5310 tdata->digest.data, tdata->digest.len,
5311 tdata->cipher_iv.data, tdata->cipher_iv.len,
5312 tdata->auth_iv.data, tdata->auth_iv.len,
5313 (tdata->digest.offset_bytes == 0 ?
5314 (verify ? ciphertext_pad_len : plaintext_pad_len)
5315 : tdata->digest.offset_bytes),
5316 tdata->validCipherLenInBits.len,
5317 tdata->cipher.offset_bits,
5318 tdata->validAuthLenInBits.len,
5319 tdata->auth.offset_bits,
5320 op_mode, 1, verify);
5325 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5326 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5327 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5329 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5332 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5334 ut_params->obuf = (op_mode == IN_PLACE ?
5335 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5338 if (ut_params->obuf)
5339 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5340 plaintext_len, buffer);
5342 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5343 plaintext_len, buffer);
5345 debug_hexdump(stdout, "plaintext:", plaintext,
5346 (tdata->plaintext.len >> 3) - tdata->digest.len);
5347 debug_hexdump(stdout, "plaintext expected:",
5348 tdata->plaintext.data,
5349 (tdata->plaintext.len >> 3) - tdata->digest.len);
5351 if (ut_params->obuf)
5352 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5353 ciphertext_len, buffer);
5355 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5356 ciphertext_len, buffer);
5358 debug_hexdump(stdout, "ciphertext:", ciphertext,
5360 debug_hexdump(stdout, "ciphertext expected:",
5361 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5363 if (ut_params->obuf)
5364 digest = rte_pktmbuf_read(ut_params->obuf,
5365 (tdata->digest.offset_bytes == 0 ?
5366 plaintext_pad_len : tdata->digest.offset_bytes),
5367 tdata->digest.len, digest_buffer);
5369 digest = rte_pktmbuf_read(ut_params->ibuf,
5370 (tdata->digest.offset_bytes == 0 ?
5371 plaintext_pad_len : tdata->digest.offset_bytes),
5372 tdata->digest.len, digest_buffer);
5374 debug_hexdump(stdout, "digest:", digest,
5376 debug_hexdump(stdout, "digest expected:",
5377 tdata->digest.data, tdata->digest.len);
5382 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5384 tdata->plaintext.data,
5385 (tdata->plaintext.len - tdata->cipher.offset_bits -
5386 (tdata->digest.len << 3)),
5387 tdata->cipher.offset_bits,
5388 "SNOW 3G Plaintext data not as expected");
5390 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5392 tdata->ciphertext.data,
5393 (tdata->validDataLenInBits.len -
5394 tdata->cipher.offset_bits),
5395 tdata->cipher.offset_bits,
5396 "SNOW 3G Ciphertext data not as expected");
5398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5401 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5402 "SNOW 3G Generated auth tag not as expected");
5408 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5409 uint8_t op_mode, uint8_t verify)
5411 struct crypto_testsuite_params *ts_params = &testsuite_params;
5412 struct crypto_unittest_params *ut_params = &unittest_params;
5416 uint8_t *plaintext = NULL, *ciphertext = NULL;
5417 unsigned int plaintext_pad_len;
5418 unsigned int plaintext_len;
5419 unsigned int ciphertext_pad_len;
5420 unsigned int ciphertext_len;
5422 struct rte_cryptodev_info dev_info;
5424 /* Verify the capabilities */
5425 struct rte_cryptodev_sym_capability_idx cap_idx;
5426 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5427 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5428 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5430 return TEST_SKIPPED;
5431 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5432 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5433 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5435 return TEST_SKIPPED;
5437 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5439 uint64_t feat_flags = dev_info.feature_flags;
5441 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5442 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5443 printf("Device doesn't support RAW data-path APIs.\n");
5444 return TEST_SKIPPED;
5447 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5448 return TEST_SKIPPED;
5450 if (op_mode == OUT_OF_PLACE) {
5451 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5452 return TEST_SKIPPED;
5453 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5454 printf("Device doesn't support digest encrypted.\n");
5455 return TEST_SKIPPED;
5459 /* Create KASUMI session */
5460 retval = create_wireless_algo_auth_cipher_session(
5461 ts_params->valid_devs[0],
5462 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5463 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5464 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5465 : RTE_CRYPTO_AUTH_OP_GENERATE),
5466 RTE_CRYPTO_AUTH_KASUMI_F9,
5467 RTE_CRYPTO_CIPHER_KASUMI_F8,
5468 tdata->key.data, tdata->key.len,
5469 0, tdata->digest.len,
5470 tdata->cipher_iv.len);
5475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5476 if (op_mode == OUT_OF_PLACE)
5477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5479 /* clear mbuf payload */
5480 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5481 rte_pktmbuf_tailroom(ut_params->ibuf));
5482 if (op_mode == OUT_OF_PLACE)
5483 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5484 rte_pktmbuf_tailroom(ut_params->obuf));
5486 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5487 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5488 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5489 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5492 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5493 ciphertext_pad_len);
5494 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5495 if (op_mode == OUT_OF_PLACE)
5496 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5497 debug_hexdump(stdout, "ciphertext:", ciphertext,
5500 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5502 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5503 if (op_mode == OUT_OF_PLACE)
5504 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5505 debug_hexdump(stdout, "plaintext:", plaintext,
5509 /* Create KASUMI operation */
5510 retval = create_wireless_algo_auth_cipher_operation(
5511 tdata->digest.data, tdata->digest.len,
5512 tdata->cipher_iv.data, tdata->cipher_iv.len,
5514 (tdata->digest.offset_bytes == 0 ?
5515 (verify ? ciphertext_pad_len : plaintext_pad_len)
5516 : tdata->digest.offset_bytes),
5517 tdata->validCipherLenInBits.len,
5518 tdata->validCipherOffsetInBits.len,
5519 tdata->validAuthLenInBits.len,
5521 op_mode, 0, verify);
5526 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5527 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5528 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5530 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5533 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5535 ut_params->obuf = (op_mode == IN_PLACE ?
5536 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5540 if (ut_params->obuf)
5541 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5544 plaintext = ciphertext;
5546 debug_hexdump(stdout, "plaintext:", plaintext,
5547 (tdata->plaintext.len >> 3) - tdata->digest.len);
5548 debug_hexdump(stdout, "plaintext expected:",
5549 tdata->plaintext.data,
5550 (tdata->plaintext.len >> 3) - tdata->digest.len);
5552 if (ut_params->obuf)
5553 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5556 ciphertext = plaintext;
5558 debug_hexdump(stdout, "ciphertext:", ciphertext,
5560 debug_hexdump(stdout, "ciphertext expected:",
5561 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5563 ut_params->digest = rte_pktmbuf_mtod(
5564 ut_params->obuf, uint8_t *) +
5565 (tdata->digest.offset_bytes == 0 ?
5566 plaintext_pad_len : tdata->digest.offset_bytes);
5568 debug_hexdump(stdout, "digest:", ut_params->digest,
5570 debug_hexdump(stdout, "digest expected:",
5571 tdata->digest.data, tdata->digest.len);
5576 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5578 tdata->plaintext.data,
5579 tdata->plaintext.len >> 3,
5580 "KASUMI Plaintext data not as expected");
5582 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5584 tdata->ciphertext.data,
5585 tdata->ciphertext.len >> 3,
5586 "KASUMI Ciphertext data not as expected");
5588 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5591 DIGEST_BYTE_LENGTH_KASUMI_F9,
5592 "KASUMI Generated auth tag not as expected");
5598 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5599 uint8_t op_mode, uint8_t verify)
5601 struct crypto_testsuite_params *ts_params = &testsuite_params;
5602 struct crypto_unittest_params *ut_params = &unittest_params;
5606 const uint8_t *plaintext = NULL;
5607 const uint8_t *ciphertext = NULL;
5608 const uint8_t *digest = NULL;
5609 unsigned int plaintext_pad_len;
5610 unsigned int plaintext_len;
5611 unsigned int ciphertext_pad_len;
5612 unsigned int ciphertext_len;
5613 uint8_t buffer[10000];
5614 uint8_t digest_buffer[10000];
5616 struct rte_cryptodev_info dev_info;
5618 /* Verify the capabilities */
5619 struct rte_cryptodev_sym_capability_idx cap_idx;
5620 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5621 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5622 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5624 return TEST_SKIPPED;
5625 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5626 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5627 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5629 return TEST_SKIPPED;
5631 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5632 return TEST_SKIPPED;
5634 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5636 uint64_t feat_flags = dev_info.feature_flags;
5638 if (op_mode == IN_PLACE) {
5639 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5640 printf("Device doesn't support in-place scatter-gather "
5641 "in both input and output mbufs.\n");
5642 return TEST_SKIPPED;
5644 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5645 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5646 printf("Device doesn't support RAW data-path APIs.\n");
5647 return TEST_SKIPPED;
5650 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5651 return TEST_SKIPPED;
5652 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5653 printf("Device doesn't support out-of-place scatter-gather "
5654 "in both input and output mbufs.\n");
5655 return TEST_SKIPPED;
5657 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5658 printf("Device doesn't support digest encrypted.\n");
5659 return TEST_SKIPPED;
5663 /* Create KASUMI session */
5664 retval = create_wireless_algo_auth_cipher_session(
5665 ts_params->valid_devs[0],
5666 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5667 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5668 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5669 : RTE_CRYPTO_AUTH_OP_GENERATE),
5670 RTE_CRYPTO_AUTH_KASUMI_F9,
5671 RTE_CRYPTO_CIPHER_KASUMI_F8,
5672 tdata->key.data, tdata->key.len,
5673 0, tdata->digest.len,
5674 tdata->cipher_iv.len);
5679 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5680 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5681 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5682 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5684 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5685 plaintext_pad_len, 15, 0);
5686 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5687 "Failed to allocate input buffer in mempool");
5689 if (op_mode == OUT_OF_PLACE) {
5690 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5691 plaintext_pad_len, 15, 0);
5692 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5693 "Failed to allocate output buffer in mempool");
5697 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5698 tdata->ciphertext.data);
5699 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5700 ciphertext_len, buffer);
5701 debug_hexdump(stdout, "ciphertext:", ciphertext,
5704 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5705 tdata->plaintext.data);
5706 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5707 plaintext_len, buffer);
5708 debug_hexdump(stdout, "plaintext:", plaintext,
5711 memset(buffer, 0, sizeof(buffer));
5713 /* Create KASUMI operation */
5714 retval = create_wireless_algo_auth_cipher_operation(
5715 tdata->digest.data, tdata->digest.len,
5716 tdata->cipher_iv.data, tdata->cipher_iv.len,
5718 (tdata->digest.offset_bytes == 0 ?
5719 (verify ? ciphertext_pad_len : plaintext_pad_len)
5720 : tdata->digest.offset_bytes),
5721 tdata->validCipherLenInBits.len,
5722 tdata->validCipherOffsetInBits.len,
5723 tdata->validAuthLenInBits.len,
5725 op_mode, 1, verify);
5730 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5731 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5732 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5734 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5739 ut_params->obuf = (op_mode == IN_PLACE ?
5740 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5743 if (ut_params->obuf)
5744 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5745 plaintext_len, buffer);
5747 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5748 plaintext_len, buffer);
5750 debug_hexdump(stdout, "plaintext:", plaintext,
5751 (tdata->plaintext.len >> 3) - tdata->digest.len);
5752 debug_hexdump(stdout, "plaintext expected:",
5753 tdata->plaintext.data,
5754 (tdata->plaintext.len >> 3) - tdata->digest.len);
5756 if (ut_params->obuf)
5757 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5758 ciphertext_len, buffer);
5760 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5761 ciphertext_len, buffer);
5763 debug_hexdump(stdout, "ciphertext:", ciphertext,
5765 debug_hexdump(stdout, "ciphertext expected:",
5766 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5768 if (ut_params->obuf)
5769 digest = rte_pktmbuf_read(ut_params->obuf,
5770 (tdata->digest.offset_bytes == 0 ?
5771 plaintext_pad_len : tdata->digest.offset_bytes),
5772 tdata->digest.len, digest_buffer);
5774 digest = rte_pktmbuf_read(ut_params->ibuf,
5775 (tdata->digest.offset_bytes == 0 ?
5776 plaintext_pad_len : tdata->digest.offset_bytes),
5777 tdata->digest.len, digest_buffer);
5779 debug_hexdump(stdout, "digest:", digest,
5781 debug_hexdump(stdout, "digest expected:",
5782 tdata->digest.data, tdata->digest.len);
5787 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5789 tdata->plaintext.data,
5790 tdata->plaintext.len >> 3,
5791 "KASUMI Plaintext data not as expected");
5793 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5795 tdata->ciphertext.data,
5796 tdata->validDataLenInBits.len,
5797 "KASUMI Ciphertext data not as expected");
5799 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5802 DIGEST_BYTE_LENGTH_KASUMI_F9,
5803 "KASUMI Generated auth tag not as expected");
5809 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5811 struct crypto_testsuite_params *ts_params = &testsuite_params;
5812 struct crypto_unittest_params *ut_params = &unittest_params;
5816 uint8_t *plaintext, *ciphertext;
5817 unsigned plaintext_pad_len;
5818 unsigned plaintext_len;
5819 struct rte_cryptodev_info dev_info;
5821 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5822 uint64_t feat_flags = dev_info.feature_flags;
5824 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5825 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5826 printf("Device doesn't support RAW data-path APIs.\n");
5827 return TEST_SKIPPED;
5830 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5831 return TEST_SKIPPED;
5833 /* Verify the capabilities */
5834 struct rte_cryptodev_sym_capability_idx cap_idx;
5835 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5836 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5837 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5839 return TEST_SKIPPED;
5840 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5841 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5842 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5844 return TEST_SKIPPED;
5846 /* Create KASUMI session */
5847 retval = create_wireless_algo_cipher_auth_session(
5848 ts_params->valid_devs[0],
5849 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5850 RTE_CRYPTO_AUTH_OP_GENERATE,
5851 RTE_CRYPTO_AUTH_KASUMI_F9,
5852 RTE_CRYPTO_CIPHER_KASUMI_F8,
5853 tdata->key.data, tdata->key.len,
5854 0, tdata->digest.len,
5855 tdata->cipher_iv.len);
5859 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5861 /* clear mbuf payload */
5862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5863 rte_pktmbuf_tailroom(ut_params->ibuf));
5865 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5866 /* Append data which is padded to a multiple of */
5867 /* the algorithms block size */
5868 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5869 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5871 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5873 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5875 /* Create KASUMI operation */
5876 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5877 tdata->digest.len, NULL, 0,
5878 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5879 tdata->cipher_iv.data, tdata->cipher_iv.len,
5880 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5881 tdata->validCipherOffsetInBits.len,
5882 tdata->validAuthLenInBits.len,
5888 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5889 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5890 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5896 if (ut_params->op->sym->m_dst)
5897 ut_params->obuf = ut_params->op->sym->m_dst;
5899 ut_params->obuf = ut_params->op->sym->m_src;
5901 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5902 tdata->validCipherOffsetInBits.len >> 3);
5904 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5905 + plaintext_pad_len;
5907 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5908 (tdata->validCipherOffsetInBits.len >> 3);
5910 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5912 reference_ciphertext,
5913 tdata->validCipherLenInBits.len,
5914 "KASUMI Ciphertext data not as expected");
5917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5920 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5921 "KASUMI Generated auth tag not as expected");
5926 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5927 const enum rte_crypto_cipher_algorithm cipher_algo,
5928 const uint16_t key_size, const uint16_t iv_size)
5930 struct rte_cryptodev_sym_capability_idx cap_idx;
5931 const struct rte_cryptodev_symmetric_capability *cap;
5933 /* Check if device supports the algorithm */
5934 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5935 cap_idx.algo.cipher = cipher_algo;
5937 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5943 /* Check if device supports key size and IV size */
5944 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5953 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5954 const enum rte_crypto_auth_algorithm auth_algo,
5955 const uint16_t key_size, const uint16_t iv_size,
5956 const uint16_t tag_size)
5958 struct rte_cryptodev_sym_capability_idx cap_idx;
5959 const struct rte_cryptodev_symmetric_capability *cap;
5961 /* Check if device supports the algorithm */
5962 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5963 cap_idx.algo.auth = auth_algo;
5965 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5971 /* Check if device supports key size and IV size */
5972 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5973 tag_size, iv_size) < 0) {
5981 test_zuc_encryption(const struct wireless_test_data *tdata)
5983 struct crypto_testsuite_params *ts_params = &testsuite_params;
5984 struct crypto_unittest_params *ut_params = &unittest_params;
5987 uint8_t *plaintext, *ciphertext;
5988 unsigned plaintext_pad_len;
5989 unsigned plaintext_len;
5990 struct rte_cryptodev_info dev_info;
5992 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5993 uint64_t feat_flags = dev_info.feature_flags;
5995 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5996 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5997 printf("Device doesn't support RAW data-path APIs.\n");
5998 return TEST_SKIPPED;
6001 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6002 return TEST_SKIPPED;
6004 /* Check if device supports ZUC EEA3 */
6005 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6006 tdata->key.len, tdata->cipher_iv.len) < 0)
6007 return TEST_SKIPPED;
6009 /* Create ZUC session */
6010 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6011 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6012 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6013 tdata->key.data, tdata->key.len,
6014 tdata->cipher_iv.len);
6018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6020 /* Clear mbuf payload */
6021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6022 rte_pktmbuf_tailroom(ut_params->ibuf));
6024 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6025 /* Append data which is padded to a multiple */
6026 /* of the algorithms block size */
6027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6028 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6030 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6032 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6034 /* Create ZUC operation */
6035 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6036 tdata->cipher_iv.len,
6037 tdata->plaintext.len,
6042 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6043 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6044 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6046 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6048 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6050 ut_params->obuf = ut_params->op->sym->m_dst;
6051 if (ut_params->obuf)
6052 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6054 ciphertext = plaintext;
6056 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6059 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6061 tdata->ciphertext.data,
6062 tdata->validCipherLenInBits.len,
6063 "ZUC Ciphertext data not as expected");
6068 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6070 struct crypto_testsuite_params *ts_params = &testsuite_params;
6071 struct crypto_unittest_params *ut_params = &unittest_params;
6075 unsigned int plaintext_pad_len;
6076 unsigned int plaintext_len;
6077 const uint8_t *ciphertext;
6078 uint8_t ciphertext_buffer[2048];
6079 struct rte_cryptodev_info dev_info;
6081 /* Check if device supports ZUC EEA3 */
6082 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6083 tdata->key.len, tdata->cipher_iv.len) < 0)
6084 return TEST_SKIPPED;
6086 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6087 return TEST_SKIPPED;
6089 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6091 uint64_t feat_flags = dev_info.feature_flags;
6093 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6094 printf("Device doesn't support in-place scatter-gather. "
6096 return TEST_SKIPPED;
6099 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6100 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6101 printf("Device doesn't support RAW data-path APIs.\n");
6102 return TEST_SKIPPED;
6105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6107 /* Append data which is padded to a multiple */
6108 /* of the algorithms block size */
6109 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6111 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6112 plaintext_pad_len, 10, 0);
6114 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6115 tdata->plaintext.data);
6117 /* Create ZUC session */
6118 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6119 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6120 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6121 tdata->key.data, tdata->key.len,
6122 tdata->cipher_iv.len);
6126 /* Clear mbuf payload */
6128 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6130 /* Create ZUC operation */
6131 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6132 tdata->cipher_iv.len, tdata->plaintext.len,
6137 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6138 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6139 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6141 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6143 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6145 ut_params->obuf = ut_params->op->sym->m_dst;
6146 if (ut_params->obuf)
6147 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6148 0, plaintext_len, ciphertext_buffer);
6150 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6151 0, plaintext_len, ciphertext_buffer);
6154 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6157 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6159 tdata->ciphertext.data,
6160 tdata->validCipherLenInBits.len,
6161 "ZUC Ciphertext data not as expected");
6167 test_zuc_authentication(const struct wireless_test_data *tdata)
6169 struct crypto_testsuite_params *ts_params = &testsuite_params;
6170 struct crypto_unittest_params *ut_params = &unittest_params;
6173 unsigned plaintext_pad_len;
6174 unsigned plaintext_len;
6177 struct rte_cryptodev_info dev_info;
6179 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6180 uint64_t feat_flags = dev_info.feature_flags;
6182 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6183 (tdata->validAuthLenInBits.len % 8 != 0)) {
6184 printf("Device doesn't support NON-Byte Aligned Data.\n");
6185 return TEST_SKIPPED;
6188 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6189 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6190 printf("Device doesn't support RAW data-path APIs.\n");
6191 return TEST_SKIPPED;
6194 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6195 return TEST_SKIPPED;
6197 /* Check if device supports ZUC EIA3 */
6198 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6199 tdata->key.len, tdata->auth_iv.len,
6200 tdata->digest.len) < 0)
6201 return TEST_SKIPPED;
6203 /* Create ZUC session */
6204 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6205 tdata->key.data, tdata->key.len,
6206 tdata->auth_iv.len, tdata->digest.len,
6207 RTE_CRYPTO_AUTH_OP_GENERATE,
6208 RTE_CRYPTO_AUTH_ZUC_EIA3);
6212 /* alloc mbuf and set payload */
6213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6215 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6216 rte_pktmbuf_tailroom(ut_params->ibuf));
6218 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6219 /* Append data which is padded to a multiple of */
6220 /* the algorithms block size */
6221 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6222 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6224 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6226 /* Create ZUC operation */
6227 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6228 tdata->auth_iv.data, tdata->auth_iv.len,
6229 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6230 tdata->validAuthLenInBits.len,
6235 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6236 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6237 ut_params->op, 0, 1, 1, 0);
6239 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6242 ut_params->obuf = ut_params->op->sym->m_src;
6243 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6244 + plaintext_pad_len;
6247 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6251 "ZUC Generated auth tag not as expected");
6257 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6258 uint8_t op_mode, uint8_t verify)
6260 struct crypto_testsuite_params *ts_params = &testsuite_params;
6261 struct crypto_unittest_params *ut_params = &unittest_params;
6265 uint8_t *plaintext = NULL, *ciphertext = NULL;
6266 unsigned int plaintext_pad_len;
6267 unsigned int plaintext_len;
6268 unsigned int ciphertext_pad_len;
6269 unsigned int ciphertext_len;
6271 struct rte_cryptodev_info dev_info;
6273 /* Check if device supports ZUC EEA3 */
6274 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6275 tdata->key.len, tdata->cipher_iv.len) < 0)
6276 return TEST_SKIPPED;
6278 /* Check if device supports ZUC EIA3 */
6279 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6280 tdata->key.len, tdata->auth_iv.len,
6281 tdata->digest.len) < 0)
6282 return TEST_SKIPPED;
6284 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6286 uint64_t feat_flags = dev_info.feature_flags;
6288 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6289 printf("Device doesn't support digest encrypted.\n");
6290 return TEST_SKIPPED;
6292 if (op_mode == IN_PLACE) {
6293 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6294 printf("Device doesn't support in-place scatter-gather "
6295 "in both input and output mbufs.\n");
6296 return TEST_SKIPPED;
6299 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6300 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6301 printf("Device doesn't support RAW data-path APIs.\n");
6302 return TEST_SKIPPED;
6305 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6306 return TEST_SKIPPED;
6307 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6308 printf("Device doesn't support out-of-place scatter-gather "
6309 "in both input and output mbufs.\n");
6310 return TEST_SKIPPED;
6314 /* Create ZUC session */
6315 retval = create_wireless_algo_auth_cipher_session(
6316 ts_params->valid_devs[0],
6317 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6318 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6319 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6320 : RTE_CRYPTO_AUTH_OP_GENERATE),
6321 RTE_CRYPTO_AUTH_ZUC_EIA3,
6322 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6323 tdata->key.data, tdata->key.len,
6324 tdata->auth_iv.len, tdata->digest.len,
6325 tdata->cipher_iv.len);
6330 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6331 if (op_mode == OUT_OF_PLACE)
6332 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6334 /* clear mbuf payload */
6335 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6336 rte_pktmbuf_tailroom(ut_params->ibuf));
6337 if (op_mode == OUT_OF_PLACE)
6338 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6339 rte_pktmbuf_tailroom(ut_params->obuf));
6341 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6342 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6343 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6344 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6347 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6348 ciphertext_pad_len);
6349 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6350 debug_hexdump(stdout, "ciphertext:", ciphertext,
6353 /* make sure enough space to cover partial digest verify case */
6354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6355 ciphertext_pad_len);
6356 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6357 debug_hexdump(stdout, "plaintext:", plaintext,
6361 if (op_mode == OUT_OF_PLACE)
6362 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6364 /* Create ZUC operation */
6365 retval = create_wireless_algo_auth_cipher_operation(
6366 tdata->digest.data, tdata->digest.len,
6367 tdata->cipher_iv.data, tdata->cipher_iv.len,
6368 tdata->auth_iv.data, tdata->auth_iv.len,
6369 (tdata->digest.offset_bytes == 0 ?
6370 (verify ? ciphertext_pad_len : plaintext_pad_len)
6371 : tdata->digest.offset_bytes),
6372 tdata->validCipherLenInBits.len,
6373 tdata->validCipherOffsetInBits.len,
6374 tdata->validAuthLenInBits.len,
6376 op_mode, 0, verify);
6381 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6382 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6383 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6385 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6388 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6390 ut_params->obuf = (op_mode == IN_PLACE ?
6391 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6395 if (ut_params->obuf)
6396 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6399 plaintext = ciphertext;
6401 debug_hexdump(stdout, "plaintext:", plaintext,
6402 (tdata->plaintext.len >> 3) - tdata->digest.len);
6403 debug_hexdump(stdout, "plaintext expected:",
6404 tdata->plaintext.data,
6405 (tdata->plaintext.len >> 3) - tdata->digest.len);
6407 if (ut_params->obuf)
6408 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6411 ciphertext = plaintext;
6413 debug_hexdump(stdout, "ciphertext:", ciphertext,
6415 debug_hexdump(stdout, "ciphertext expected:",
6416 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6418 ut_params->digest = rte_pktmbuf_mtod(
6419 ut_params->obuf, uint8_t *) +
6420 (tdata->digest.offset_bytes == 0 ?
6421 plaintext_pad_len : tdata->digest.offset_bytes);
6423 debug_hexdump(stdout, "digest:", ut_params->digest,
6425 debug_hexdump(stdout, "digest expected:",
6426 tdata->digest.data, tdata->digest.len);
6431 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6433 tdata->plaintext.data,
6434 tdata->plaintext.len >> 3,
6435 "ZUC Plaintext data not as expected");
6437 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6439 tdata->ciphertext.data,
6440 tdata->ciphertext.len >> 3,
6441 "ZUC Ciphertext data not as expected");
6443 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6446 DIGEST_BYTE_LENGTH_KASUMI_F9,
6447 "ZUC Generated auth tag not as expected");
6453 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6454 uint8_t op_mode, uint8_t verify)
6456 struct crypto_testsuite_params *ts_params = &testsuite_params;
6457 struct crypto_unittest_params *ut_params = &unittest_params;
6461 const uint8_t *plaintext = NULL;
6462 const uint8_t *ciphertext = NULL;
6463 const uint8_t *digest = NULL;
6464 unsigned int plaintext_pad_len;
6465 unsigned int plaintext_len;
6466 unsigned int ciphertext_pad_len;
6467 unsigned int ciphertext_len;
6468 uint8_t buffer[10000];
6469 uint8_t digest_buffer[10000];
6471 struct rte_cryptodev_info dev_info;
6473 /* Check if device supports ZUC EEA3 */
6474 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6475 tdata->key.len, tdata->cipher_iv.len) < 0)
6476 return TEST_SKIPPED;
6478 /* Check if device supports ZUC EIA3 */
6479 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6480 tdata->key.len, tdata->auth_iv.len,
6481 tdata->digest.len) < 0)
6482 return TEST_SKIPPED;
6484 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6486 uint64_t feat_flags = dev_info.feature_flags;
6488 if (op_mode == IN_PLACE) {
6489 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6490 printf("Device doesn't support in-place scatter-gather "
6491 "in both input and output mbufs.\n");
6492 return TEST_SKIPPED;
6495 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6496 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6497 printf("Device doesn't support RAW data-path APIs.\n");
6498 return TEST_SKIPPED;
6501 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6502 return TEST_SKIPPED;
6503 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6504 printf("Device doesn't support out-of-place scatter-gather "
6505 "in both input and output mbufs.\n");
6506 return TEST_SKIPPED;
6508 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6509 printf("Device doesn't support digest encrypted.\n");
6510 return TEST_SKIPPED;
6514 /* Create ZUC session */
6515 retval = create_wireless_algo_auth_cipher_session(
6516 ts_params->valid_devs[0],
6517 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6518 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6519 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6520 : RTE_CRYPTO_AUTH_OP_GENERATE),
6521 RTE_CRYPTO_AUTH_ZUC_EIA3,
6522 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6523 tdata->key.data, tdata->key.len,
6524 tdata->auth_iv.len, tdata->digest.len,
6525 tdata->cipher_iv.len);
6530 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6531 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6532 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6535 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6536 plaintext_pad_len, 15, 0);
6537 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6538 "Failed to allocate input buffer in mempool");
6540 if (op_mode == OUT_OF_PLACE) {
6541 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6542 plaintext_pad_len, 15, 0);
6543 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6544 "Failed to allocate output buffer in mempool");
6548 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6549 tdata->ciphertext.data);
6550 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6551 ciphertext_len, buffer);
6552 debug_hexdump(stdout, "ciphertext:", ciphertext,
6555 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6556 tdata->plaintext.data);
6557 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6558 plaintext_len, buffer);
6559 debug_hexdump(stdout, "plaintext:", plaintext,
6562 memset(buffer, 0, sizeof(buffer));
6564 /* Create ZUC operation */
6565 retval = create_wireless_algo_auth_cipher_operation(
6566 tdata->digest.data, tdata->digest.len,
6567 tdata->cipher_iv.data, tdata->cipher_iv.len,
6569 (tdata->digest.offset_bytes == 0 ?
6570 (verify ? ciphertext_pad_len : plaintext_pad_len)
6571 : tdata->digest.offset_bytes),
6572 tdata->validCipherLenInBits.len,
6573 tdata->validCipherOffsetInBits.len,
6574 tdata->validAuthLenInBits.len,
6576 op_mode, 1, verify);
6581 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6582 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6583 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6585 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6588 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6590 ut_params->obuf = (op_mode == IN_PLACE ?
6591 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6594 if (ut_params->obuf)
6595 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6596 plaintext_len, buffer);
6598 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6599 plaintext_len, buffer);
6601 debug_hexdump(stdout, "plaintext:", plaintext,
6602 (tdata->plaintext.len >> 3) - tdata->digest.len);
6603 debug_hexdump(stdout, "plaintext expected:",
6604 tdata->plaintext.data,
6605 (tdata->plaintext.len >> 3) - tdata->digest.len);
6607 if (ut_params->obuf)
6608 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6609 ciphertext_len, buffer);
6611 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6612 ciphertext_len, buffer);
6614 debug_hexdump(stdout, "ciphertext:", ciphertext,
6616 debug_hexdump(stdout, "ciphertext expected:",
6617 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6619 if (ut_params->obuf)
6620 digest = rte_pktmbuf_read(ut_params->obuf,
6621 (tdata->digest.offset_bytes == 0 ?
6622 plaintext_pad_len : tdata->digest.offset_bytes),
6623 tdata->digest.len, digest_buffer);
6625 digest = rte_pktmbuf_read(ut_params->ibuf,
6626 (tdata->digest.offset_bytes == 0 ?
6627 plaintext_pad_len : tdata->digest.offset_bytes),
6628 tdata->digest.len, digest_buffer);
6630 debug_hexdump(stdout, "digest:", digest,
6632 debug_hexdump(stdout, "digest expected:",
6633 tdata->digest.data, tdata->digest.len);
6638 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6640 tdata->plaintext.data,
6641 tdata->plaintext.len >> 3,
6642 "ZUC Plaintext data not as expected");
6644 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6646 tdata->ciphertext.data,
6647 tdata->validDataLenInBits.len,
6648 "ZUC Ciphertext data not as expected");
6650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6653 DIGEST_BYTE_LENGTH_KASUMI_F9,
6654 "ZUC Generated auth tag not as expected");
6660 test_kasumi_encryption_test_case_1(void)
6662 return test_kasumi_encryption(&kasumi_test_case_1);
6666 test_kasumi_encryption_test_case_1_sgl(void)
6668 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6672 test_kasumi_encryption_test_case_1_oop(void)
6674 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6678 test_kasumi_encryption_test_case_1_oop_sgl(void)
6680 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6684 test_kasumi_encryption_test_case_2(void)
6686 return test_kasumi_encryption(&kasumi_test_case_2);
6690 test_kasumi_encryption_test_case_3(void)
6692 return test_kasumi_encryption(&kasumi_test_case_3);
6696 test_kasumi_encryption_test_case_4(void)
6698 return test_kasumi_encryption(&kasumi_test_case_4);
6702 test_kasumi_encryption_test_case_5(void)
6704 return test_kasumi_encryption(&kasumi_test_case_5);
6708 test_kasumi_decryption_test_case_1(void)
6710 return test_kasumi_decryption(&kasumi_test_case_1);
6714 test_kasumi_decryption_test_case_1_oop(void)
6716 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6720 test_kasumi_decryption_test_case_2(void)
6722 return test_kasumi_decryption(&kasumi_test_case_2);
6726 test_kasumi_decryption_test_case_3(void)
6728 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6729 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6730 return TEST_SKIPPED;
6731 return test_kasumi_decryption(&kasumi_test_case_3);
6735 test_kasumi_decryption_test_case_4(void)
6737 return test_kasumi_decryption(&kasumi_test_case_4);
6741 test_kasumi_decryption_test_case_5(void)
6743 return test_kasumi_decryption(&kasumi_test_case_5);
6746 test_snow3g_encryption_test_case_1(void)
6748 return test_snow3g_encryption(&snow3g_test_case_1);
6752 test_snow3g_encryption_test_case_1_oop(void)
6754 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6758 test_snow3g_encryption_test_case_1_oop_sgl(void)
6760 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6765 test_snow3g_encryption_test_case_1_offset_oop(void)
6767 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6771 test_snow3g_encryption_test_case_2(void)
6773 return test_snow3g_encryption(&snow3g_test_case_2);
6777 test_snow3g_encryption_test_case_3(void)
6779 return test_snow3g_encryption(&snow3g_test_case_3);
6783 test_snow3g_encryption_test_case_4(void)
6785 return test_snow3g_encryption(&snow3g_test_case_4);
6789 test_snow3g_encryption_test_case_5(void)
6791 return test_snow3g_encryption(&snow3g_test_case_5);
6795 test_snow3g_decryption_test_case_1(void)
6797 return test_snow3g_decryption(&snow3g_test_case_1);
6801 test_snow3g_decryption_test_case_1_oop(void)
6803 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6807 test_snow3g_decryption_test_case_2(void)
6809 return test_snow3g_decryption(&snow3g_test_case_2);
6813 test_snow3g_decryption_test_case_3(void)
6815 return test_snow3g_decryption(&snow3g_test_case_3);
6819 test_snow3g_decryption_test_case_4(void)
6821 return test_snow3g_decryption(&snow3g_test_case_4);
6825 test_snow3g_decryption_test_case_5(void)
6827 return test_snow3g_decryption(&snow3g_test_case_5);
6831 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6832 * Pattern digest from snow3g_test_data must be allocated as
6833 * 4 last bytes in plaintext.
6836 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6837 struct snow3g_hash_test_data *output)
6839 if ((pattern != NULL) && (output != NULL)) {
6840 output->key.len = pattern->key.len;
6842 memcpy(output->key.data,
6843 pattern->key.data, pattern->key.len);
6845 output->auth_iv.len = pattern->auth_iv.len;
6847 memcpy(output->auth_iv.data,
6848 pattern->auth_iv.data, pattern->auth_iv.len);
6850 output->plaintext.len = pattern->plaintext.len;
6852 memcpy(output->plaintext.data,
6853 pattern->plaintext.data, pattern->plaintext.len >> 3);
6855 output->digest.len = pattern->digest.len;
6857 memcpy(output->digest.data,
6858 &pattern->plaintext.data[pattern->digest.offset_bytes],
6859 pattern->digest.len);
6861 output->validAuthLenInBits.len =
6862 pattern->validAuthLenInBits.len;
6867 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6870 test_snow3g_decryption_with_digest_test_case_1(void)
6872 struct snow3g_hash_test_data snow3g_hash_data;
6873 struct rte_cryptodev_info dev_info;
6874 struct crypto_testsuite_params *ts_params = &testsuite_params;
6876 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6877 uint64_t feat_flags = dev_info.feature_flags;
6879 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6880 printf("Device doesn't support encrypted digest operations.\n");
6881 return TEST_SKIPPED;
6885 * Function prepare data for hash verification test case.
6886 * Digest is allocated in 4 last bytes in plaintext, pattern.
6888 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6890 return test_snow3g_decryption(&snow3g_test_case_7) &
6891 test_snow3g_authentication_verify(&snow3g_hash_data);
6895 test_snow3g_cipher_auth_test_case_1(void)
6897 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6901 test_snow3g_auth_cipher_test_case_1(void)
6903 return test_snow3g_auth_cipher(
6904 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6908 test_snow3g_auth_cipher_test_case_2(void)
6910 return test_snow3g_auth_cipher(
6911 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6915 test_snow3g_auth_cipher_test_case_2_oop(void)
6917 return test_snow3g_auth_cipher(
6918 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6922 test_snow3g_auth_cipher_part_digest_enc(void)
6924 return test_snow3g_auth_cipher(
6925 &snow3g_auth_cipher_partial_digest_encryption,
6930 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6932 return test_snow3g_auth_cipher(
6933 &snow3g_auth_cipher_partial_digest_encryption,
6938 test_snow3g_auth_cipher_test_case_3_sgl(void)
6940 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6941 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6942 return TEST_SKIPPED;
6943 return test_snow3g_auth_cipher_sgl(
6944 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6948 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6950 return test_snow3g_auth_cipher_sgl(
6951 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6955 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6957 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6958 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6959 return TEST_SKIPPED;
6960 return test_snow3g_auth_cipher_sgl(
6961 &snow3g_auth_cipher_partial_digest_encryption,
6966 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6968 return test_snow3g_auth_cipher_sgl(
6969 &snow3g_auth_cipher_partial_digest_encryption,
6974 test_snow3g_auth_cipher_verify_test_case_1(void)
6976 return test_snow3g_auth_cipher(
6977 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6981 test_snow3g_auth_cipher_verify_test_case_2(void)
6983 return test_snow3g_auth_cipher(
6984 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6988 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6990 return test_snow3g_auth_cipher(
6991 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6995 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6997 return test_snow3g_auth_cipher(
6998 &snow3g_auth_cipher_partial_digest_encryption,
7003 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7005 return test_snow3g_auth_cipher(
7006 &snow3g_auth_cipher_partial_digest_encryption,
7011 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7013 return test_snow3g_auth_cipher_sgl(
7014 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7018 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7020 return test_snow3g_auth_cipher_sgl(
7021 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7025 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7027 return test_snow3g_auth_cipher_sgl(
7028 &snow3g_auth_cipher_partial_digest_encryption,
7033 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7035 return test_snow3g_auth_cipher_sgl(
7036 &snow3g_auth_cipher_partial_digest_encryption,
7041 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7043 return test_snow3g_auth_cipher(
7044 &snow3g_test_case_7, IN_PLACE, 0);
7048 test_kasumi_auth_cipher_test_case_1(void)
7050 return test_kasumi_auth_cipher(
7051 &kasumi_test_case_3, IN_PLACE, 0);
7055 test_kasumi_auth_cipher_test_case_2(void)
7057 return test_kasumi_auth_cipher(
7058 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7062 test_kasumi_auth_cipher_test_case_2_oop(void)
7064 return test_kasumi_auth_cipher(
7065 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7069 test_kasumi_auth_cipher_test_case_2_sgl(void)
7071 return test_kasumi_auth_cipher_sgl(
7072 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7076 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7078 return test_kasumi_auth_cipher_sgl(
7079 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7083 test_kasumi_auth_cipher_verify_test_case_1(void)
7085 return test_kasumi_auth_cipher(
7086 &kasumi_test_case_3, IN_PLACE, 1);
7090 test_kasumi_auth_cipher_verify_test_case_2(void)
7092 return test_kasumi_auth_cipher(
7093 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7097 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7099 return test_kasumi_auth_cipher(
7100 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7104 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7106 return test_kasumi_auth_cipher_sgl(
7107 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7111 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7113 return test_kasumi_auth_cipher_sgl(
7114 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7118 test_kasumi_cipher_auth_test_case_1(void)
7120 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7124 test_zuc_encryption_test_case_1(void)
7126 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7130 test_zuc_encryption_test_case_2(void)
7132 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7136 test_zuc_encryption_test_case_3(void)
7138 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7142 test_zuc_encryption_test_case_4(void)
7144 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7148 test_zuc_encryption_test_case_5(void)
7150 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7154 test_zuc_encryption_test_case_6_sgl(void)
7156 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7160 test_zuc_hash_generate_test_case_1(void)
7162 return test_zuc_authentication(&zuc_test_case_auth_1b);
7166 test_zuc_hash_generate_test_case_2(void)
7168 return test_zuc_authentication(&zuc_test_case_auth_90b);
7172 test_zuc_hash_generate_test_case_3(void)
7174 return test_zuc_authentication(&zuc_test_case_auth_577b);
7178 test_zuc_hash_generate_test_case_4(void)
7180 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7184 test_zuc_hash_generate_test_case_5(void)
7186 return test_zuc_authentication(&zuc_test_auth_5670b);
7190 test_zuc_hash_generate_test_case_6(void)
7192 return test_zuc_authentication(&zuc_test_case_auth_128b);
7196 test_zuc_hash_generate_test_case_7(void)
7198 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7202 test_zuc_hash_generate_test_case_8(void)
7204 return test_zuc_authentication(&zuc_test_case_auth_584b);
7208 test_zuc_hash_generate_test_case_9(void)
7210 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7214 test_zuc_hash_generate_test_case_10(void)
7216 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7220 test_zuc_hash_generate_test_case_11(void)
7222 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7226 test_zuc_cipher_auth_test_case_1(void)
7228 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7232 test_zuc_cipher_auth_test_case_2(void)
7234 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7238 test_zuc_auth_cipher_test_case_1(void)
7240 return test_zuc_auth_cipher(
7241 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7245 test_zuc_auth_cipher_test_case_1_oop(void)
7247 return test_zuc_auth_cipher(
7248 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7252 test_zuc_auth_cipher_test_case_1_sgl(void)
7254 return test_zuc_auth_cipher_sgl(
7255 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7259 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7261 return test_zuc_auth_cipher_sgl(
7262 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7266 test_zuc_auth_cipher_verify_test_case_1(void)
7268 return test_zuc_auth_cipher(
7269 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7273 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7275 return test_zuc_auth_cipher(
7276 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7280 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7282 return test_zuc_auth_cipher_sgl(
7283 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7287 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7289 return test_zuc_auth_cipher_sgl(
7290 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7294 test_zuc256_encryption_test_case_1(void)
7296 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7300 test_zuc256_encryption_test_case_2(void)
7302 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7306 test_zuc256_authentication_test_case_1(void)
7308 return test_zuc_authentication(&zuc256_test_case_auth_1);
7312 test_zuc256_authentication_test_case_2(void)
7314 return test_zuc_authentication(&zuc256_test_case_auth_2);
7318 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7320 uint8_t dev_id = testsuite_params.valid_devs[0];
7322 struct rte_cryptodev_sym_capability_idx cap_idx;
7324 /* Check if device supports particular cipher algorithm */
7325 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7326 cap_idx.algo.cipher = tdata->cipher_algo;
7327 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7328 return TEST_SKIPPED;
7330 /* Check if device supports particular hash algorithm */
7331 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7332 cap_idx.algo.auth = tdata->auth_algo;
7333 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7334 return TEST_SKIPPED;
7340 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7341 uint8_t op_mode, uint8_t verify)
7343 struct crypto_testsuite_params *ts_params = &testsuite_params;
7344 struct crypto_unittest_params *ut_params = &unittest_params;
7348 uint8_t *plaintext = NULL, *ciphertext = NULL;
7349 unsigned int plaintext_pad_len;
7350 unsigned int plaintext_len;
7351 unsigned int ciphertext_pad_len;
7352 unsigned int ciphertext_len;
7354 struct rte_cryptodev_info dev_info;
7355 struct rte_crypto_op *op;
7357 /* Check if device supports particular algorithms separately */
7358 if (test_mixed_check_if_unsupported(tdata))
7359 return TEST_SKIPPED;
7360 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7361 return TEST_SKIPPED;
7363 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7365 uint64_t feat_flags = dev_info.feature_flags;
7367 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7368 printf("Device doesn't support digest encrypted.\n");
7369 return TEST_SKIPPED;
7372 /* Create the session */
7374 retval = create_wireless_algo_cipher_auth_session(
7375 ts_params->valid_devs[0],
7376 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7377 RTE_CRYPTO_AUTH_OP_VERIFY,
7380 tdata->auth_key.data, tdata->auth_key.len,
7381 tdata->auth_iv.len, tdata->digest_enc.len,
7382 tdata->cipher_iv.len);
7384 retval = create_wireless_algo_auth_cipher_session(
7385 ts_params->valid_devs[0],
7386 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7387 RTE_CRYPTO_AUTH_OP_GENERATE,
7390 tdata->auth_key.data, tdata->auth_key.len,
7391 tdata->auth_iv.len, tdata->digest_enc.len,
7392 tdata->cipher_iv.len);
7396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7397 if (op_mode == OUT_OF_PLACE)
7398 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7400 /* clear mbuf payload */
7401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7402 rte_pktmbuf_tailroom(ut_params->ibuf));
7403 if (op_mode == OUT_OF_PLACE) {
7405 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7406 rte_pktmbuf_tailroom(ut_params->obuf));
7409 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7410 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7411 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7412 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7415 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7416 ciphertext_pad_len);
7417 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7418 debug_hexdump(stdout, "ciphertext:", ciphertext,
7421 /* make sure enough space to cover partial digest verify case */
7422 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7423 ciphertext_pad_len);
7424 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7425 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7428 if (op_mode == OUT_OF_PLACE)
7429 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7431 /* Create the operation */
7432 retval = create_wireless_algo_auth_cipher_operation(
7433 tdata->digest_enc.data, tdata->digest_enc.len,
7434 tdata->cipher_iv.data, tdata->cipher_iv.len,
7435 tdata->auth_iv.data, tdata->auth_iv.len,
7436 (tdata->digest_enc.offset == 0 ?
7438 : tdata->digest_enc.offset),
7439 tdata->validCipherLen.len_bits,
7440 tdata->cipher.offset_bits,
7441 tdata->validAuthLen.len_bits,
7442 tdata->auth.offset_bits,
7443 op_mode, 0, verify);
7448 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7450 /* Check if the op failed because the device doesn't */
7451 /* support this particular combination of algorithms */
7452 if (op == NULL && ut_params->op->status ==
7453 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7454 printf("Device doesn't support this mixed combination. "
7456 return TEST_SKIPPED;
7460 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7462 ut_params->obuf = (op_mode == IN_PLACE ?
7463 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7466 if (ut_params->obuf)
7467 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7470 plaintext = ciphertext +
7471 (tdata->cipher.offset_bits >> 3);
7473 debug_hexdump(stdout, "plaintext:", plaintext,
7474 tdata->plaintext.len_bits >> 3);
7475 debug_hexdump(stdout, "plaintext expected:",
7476 tdata->plaintext.data,
7477 tdata->plaintext.len_bits >> 3);
7479 if (ut_params->obuf)
7480 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7483 ciphertext = plaintext;
7485 debug_hexdump(stdout, "ciphertext:", ciphertext,
7487 debug_hexdump(stdout, "ciphertext expected:",
7488 tdata->ciphertext.data,
7489 tdata->ciphertext.len_bits >> 3);
7491 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7492 + (tdata->digest_enc.offset == 0 ?
7493 plaintext_pad_len : tdata->digest_enc.offset);
7495 debug_hexdump(stdout, "digest:", ut_params->digest,
7496 tdata->digest_enc.len);
7497 debug_hexdump(stdout, "digest expected:",
7498 tdata->digest_enc.data,
7499 tdata->digest_enc.len);
7503 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7505 tdata->digest_enc.data,
7506 tdata->digest_enc.len,
7507 "Generated auth tag not as expected");
7510 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7512 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7514 tdata->plaintext.data,
7515 tdata->plaintext.len_bits >> 3,
7516 "Plaintext data not as expected");
7518 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7520 tdata->ciphertext.data,
7521 tdata->validDataLen.len_bits,
7522 "Ciphertext data not as expected");
7526 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7527 "crypto op processing failed");
7533 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7534 uint8_t op_mode, uint8_t verify)
7536 struct crypto_testsuite_params *ts_params = &testsuite_params;
7537 struct crypto_unittest_params *ut_params = &unittest_params;
7541 const uint8_t *plaintext = NULL;
7542 const uint8_t *ciphertext = NULL;
7543 const uint8_t *digest = NULL;
7544 unsigned int plaintext_pad_len;
7545 unsigned int plaintext_len;
7546 unsigned int ciphertext_pad_len;
7547 unsigned int ciphertext_len;
7548 uint8_t buffer[10000];
7549 uint8_t digest_buffer[10000];
7551 struct rte_cryptodev_info dev_info;
7552 struct rte_crypto_op *op;
7554 /* Check if device supports particular algorithms */
7555 if (test_mixed_check_if_unsupported(tdata))
7556 return TEST_SKIPPED;
7557 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7558 return TEST_SKIPPED;
7560 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7562 uint64_t feat_flags = dev_info.feature_flags;
7564 if (op_mode == IN_PLACE) {
7565 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7566 printf("Device doesn't support in-place scatter-gather "
7567 "in both input and output mbufs.\n");
7568 return TEST_SKIPPED;
7571 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7572 printf("Device doesn't support out-of-place scatter-gather "
7573 "in both input and output mbufs.\n");
7574 return TEST_SKIPPED;
7576 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7577 printf("Device doesn't support digest encrypted.\n");
7578 return TEST_SKIPPED;
7582 /* Create the session */
7584 retval = create_wireless_algo_cipher_auth_session(
7585 ts_params->valid_devs[0],
7586 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7587 RTE_CRYPTO_AUTH_OP_VERIFY,
7590 tdata->auth_key.data, tdata->auth_key.len,
7591 tdata->auth_iv.len, tdata->digest_enc.len,
7592 tdata->cipher_iv.len);
7594 retval = create_wireless_algo_auth_cipher_session(
7595 ts_params->valid_devs[0],
7596 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7597 RTE_CRYPTO_AUTH_OP_GENERATE,
7600 tdata->auth_key.data, tdata->auth_key.len,
7601 tdata->auth_iv.len, tdata->digest_enc.len,
7602 tdata->cipher_iv.len);
7606 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7607 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7608 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7609 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7611 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7612 ciphertext_pad_len, 15, 0);
7613 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7614 "Failed to allocate input buffer in mempool");
7616 if (op_mode == OUT_OF_PLACE) {
7617 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7618 plaintext_pad_len, 15, 0);
7619 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7620 "Failed to allocate output buffer in mempool");
7624 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7625 tdata->ciphertext.data);
7626 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7627 ciphertext_len, buffer);
7628 debug_hexdump(stdout, "ciphertext:", ciphertext,
7631 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7632 tdata->plaintext.data);
7633 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7634 plaintext_len, buffer);
7635 debug_hexdump(stdout, "plaintext:", plaintext,
7638 memset(buffer, 0, sizeof(buffer));
7640 /* Create the operation */
7641 retval = create_wireless_algo_auth_cipher_operation(
7642 tdata->digest_enc.data, tdata->digest_enc.len,
7643 tdata->cipher_iv.data, tdata->cipher_iv.len,
7644 tdata->auth_iv.data, tdata->auth_iv.len,
7645 (tdata->digest_enc.offset == 0 ?
7647 : tdata->digest_enc.offset),
7648 tdata->validCipherLen.len_bits,
7649 tdata->cipher.offset_bits,
7650 tdata->validAuthLen.len_bits,
7651 tdata->auth.offset_bits,
7652 op_mode, 1, verify);
7657 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7659 /* Check if the op failed because the device doesn't */
7660 /* support this particular combination of algorithms */
7661 if (op == NULL && ut_params->op->status ==
7662 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7663 printf("Device doesn't support this mixed combination. "
7665 return TEST_SKIPPED;
7669 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7671 ut_params->obuf = (op_mode == IN_PLACE ?
7672 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7675 if (ut_params->obuf)
7676 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7677 plaintext_len, buffer);
7679 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7680 plaintext_len, buffer);
7682 debug_hexdump(stdout, "plaintext:", plaintext,
7683 (tdata->plaintext.len_bits >> 3) -
7684 tdata->digest_enc.len);
7685 debug_hexdump(stdout, "plaintext expected:",
7686 tdata->plaintext.data,
7687 (tdata->plaintext.len_bits >> 3) -
7688 tdata->digest_enc.len);
7690 if (ut_params->obuf)
7691 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7692 ciphertext_len, buffer);
7694 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7695 ciphertext_len, buffer);
7697 debug_hexdump(stdout, "ciphertext:", ciphertext,
7699 debug_hexdump(stdout, "ciphertext expected:",
7700 tdata->ciphertext.data,
7701 tdata->ciphertext.len_bits >> 3);
7703 if (ut_params->obuf)
7704 digest = rte_pktmbuf_read(ut_params->obuf,
7705 (tdata->digest_enc.offset == 0 ?
7707 tdata->digest_enc.offset),
7708 tdata->digest_enc.len, digest_buffer);
7710 digest = rte_pktmbuf_read(ut_params->ibuf,
7711 (tdata->digest_enc.offset == 0 ?
7713 tdata->digest_enc.offset),
7714 tdata->digest_enc.len, digest_buffer);
7716 debug_hexdump(stdout, "digest:", digest,
7717 tdata->digest_enc.len);
7718 debug_hexdump(stdout, "digest expected:",
7719 tdata->digest_enc.data, tdata->digest_enc.len);
7723 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7725 tdata->digest_enc.data,
7726 tdata->digest_enc.len,
7727 "Generated auth tag not as expected");
7730 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7732 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7734 tdata->plaintext.data,
7735 tdata->plaintext.len_bits >> 3,
7736 "Plaintext data not as expected");
7738 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7740 tdata->ciphertext.data,
7741 tdata->validDataLen.len_bits,
7742 "Ciphertext data not as expected");
7746 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7747 "crypto op processing failed");
7752 /** AUTH AES CMAC + CIPHER AES CTR */
7755 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7757 return test_mixed_auth_cipher(
7758 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7762 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7764 return test_mixed_auth_cipher(
7765 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7769 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7771 return test_mixed_auth_cipher_sgl(
7772 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7776 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7778 return test_mixed_auth_cipher_sgl(
7779 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7783 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7785 return test_mixed_auth_cipher(
7786 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7790 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7792 return test_mixed_auth_cipher(
7793 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7797 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7799 return test_mixed_auth_cipher_sgl(
7800 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7804 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7806 return test_mixed_auth_cipher_sgl(
7807 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7810 /** MIXED AUTH + CIPHER */
7813 test_auth_zuc_cipher_snow_test_case_1(void)
7815 return test_mixed_auth_cipher(
7816 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7820 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7822 return test_mixed_auth_cipher(
7823 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7827 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7829 return test_mixed_auth_cipher(
7830 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7834 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7836 return test_mixed_auth_cipher(
7837 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7841 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7843 return test_mixed_auth_cipher(
7844 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7848 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7850 return test_mixed_auth_cipher(
7851 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7855 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7857 return test_mixed_auth_cipher(
7858 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7862 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7864 return test_mixed_auth_cipher(
7865 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7869 test_auth_snow_cipher_zuc_test_case_1(void)
7871 return test_mixed_auth_cipher(
7872 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7876 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7878 return test_mixed_auth_cipher(
7879 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7883 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7885 return test_mixed_auth_cipher(
7886 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7890 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7892 return test_mixed_auth_cipher(
7893 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7897 test_auth_null_cipher_snow_test_case_1(void)
7899 return test_mixed_auth_cipher(
7900 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7904 test_verify_auth_null_cipher_snow_test_case_1(void)
7906 return test_mixed_auth_cipher(
7907 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7911 test_auth_null_cipher_zuc_test_case_1(void)
7913 return test_mixed_auth_cipher(
7914 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7918 test_verify_auth_null_cipher_zuc_test_case_1(void)
7920 return test_mixed_auth_cipher(
7921 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7925 test_auth_snow_cipher_null_test_case_1(void)
7927 return test_mixed_auth_cipher(
7928 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7932 test_verify_auth_snow_cipher_null_test_case_1(void)
7934 return test_mixed_auth_cipher(
7935 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7939 test_auth_zuc_cipher_null_test_case_1(void)
7941 return test_mixed_auth_cipher(
7942 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7946 test_verify_auth_zuc_cipher_null_test_case_1(void)
7948 return test_mixed_auth_cipher(
7949 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7953 test_auth_null_cipher_aes_ctr_test_case_1(void)
7955 return test_mixed_auth_cipher(
7956 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7960 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7962 return test_mixed_auth_cipher(
7963 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7967 test_auth_aes_cmac_cipher_null_test_case_1(void)
7969 return test_mixed_auth_cipher(
7970 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7974 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7976 return test_mixed_auth_cipher(
7977 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7980 /* ***** AEAD algorithm Tests ***** */
7983 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7984 enum rte_crypto_aead_operation op,
7985 const uint8_t *key, const uint8_t key_len,
7986 const uint16_t aad_len, const uint8_t auth_len,
7989 uint8_t aead_key[key_len];
7992 struct crypto_testsuite_params *ts_params = &testsuite_params;
7993 struct crypto_unittest_params *ut_params = &unittest_params;
7995 memcpy(aead_key, key, key_len);
7997 /* Setup AEAD Parameters */
7998 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7999 ut_params->aead_xform.next = NULL;
8000 ut_params->aead_xform.aead.algo = algo;
8001 ut_params->aead_xform.aead.op = op;
8002 ut_params->aead_xform.aead.key.data = aead_key;
8003 ut_params->aead_xform.aead.key.length = key_len;
8004 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8005 ut_params->aead_xform.aead.iv.length = iv_len;
8006 ut_params->aead_xform.aead.digest_length = auth_len;
8007 ut_params->aead_xform.aead.aad_length = aad_len;
8009 debug_hexdump(stdout, "key:", key, key_len);
8011 /* Create Crypto session*/
8012 ut_params->sess = rte_cryptodev_sym_session_create(
8013 ts_params->session_mpool);
8014 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8016 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8017 &ut_params->aead_xform,
8018 ts_params->session_priv_mpool);
8024 create_aead_xform(struct rte_crypto_op *op,
8025 enum rte_crypto_aead_algorithm algo,
8026 enum rte_crypto_aead_operation aead_op,
8027 uint8_t *key, const uint8_t key_len,
8028 const uint8_t aad_len, const uint8_t auth_len,
8031 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8032 "failed to allocate space for crypto transform");
8034 struct rte_crypto_sym_op *sym_op = op->sym;
8036 /* Setup AEAD Parameters */
8037 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8038 sym_op->xform->next = NULL;
8039 sym_op->xform->aead.algo = algo;
8040 sym_op->xform->aead.op = aead_op;
8041 sym_op->xform->aead.key.data = key;
8042 sym_op->xform->aead.key.length = key_len;
8043 sym_op->xform->aead.iv.offset = IV_OFFSET;
8044 sym_op->xform->aead.iv.length = iv_len;
8045 sym_op->xform->aead.digest_length = auth_len;
8046 sym_op->xform->aead.aad_length = aad_len;
8048 debug_hexdump(stdout, "key:", key, key_len);
8054 create_aead_operation(enum rte_crypto_aead_operation op,
8055 const struct aead_test_data *tdata)
8057 struct crypto_testsuite_params *ts_params = &testsuite_params;
8058 struct crypto_unittest_params *ut_params = &unittest_params;
8060 uint8_t *plaintext, *ciphertext;
8061 unsigned int aad_pad_len, plaintext_pad_len;
8063 /* Generate Crypto op data structure */
8064 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8065 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8066 TEST_ASSERT_NOT_NULL(ut_params->op,
8067 "Failed to allocate symmetric crypto operation struct");
8069 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8071 /* Append aad data */
8072 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8073 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8074 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8076 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8077 "no room to append aad");
8079 sym_op->aead.aad.phys_addr =
8080 rte_pktmbuf_iova(ut_params->ibuf);
8081 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8082 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8083 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8086 /* Append IV at the end of the crypto operation*/
8087 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8088 uint8_t *, IV_OFFSET);
8090 /* Copy IV 1 byte after the IV pointer, according to the API */
8091 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8092 debug_hexdump(stdout, "iv:", iv_ptr,
8095 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8096 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8098 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8099 "no room to append aad");
8101 sym_op->aead.aad.phys_addr =
8102 rte_pktmbuf_iova(ut_params->ibuf);
8103 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8104 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8107 /* Append IV at the end of the crypto operation*/
8108 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8109 uint8_t *, IV_OFFSET);
8111 if (tdata->iv.len == 0) {
8112 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8113 debug_hexdump(stdout, "iv:", iv_ptr,
8116 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8117 debug_hexdump(stdout, "iv:", iv_ptr,
8122 /* Append plaintext/ciphertext */
8123 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8124 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8125 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8127 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8129 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8130 debug_hexdump(stdout, "plaintext:", plaintext,
8131 tdata->plaintext.len);
8133 if (ut_params->obuf) {
8134 ciphertext = (uint8_t *)rte_pktmbuf_append(
8136 plaintext_pad_len + aad_pad_len);
8137 TEST_ASSERT_NOT_NULL(ciphertext,
8138 "no room to append ciphertext");
8140 memset(ciphertext + aad_pad_len, 0,
8141 tdata->ciphertext.len);
8144 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8145 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8147 TEST_ASSERT_NOT_NULL(ciphertext,
8148 "no room to append ciphertext");
8150 memcpy(ciphertext, tdata->ciphertext.data,
8151 tdata->ciphertext.len);
8152 debug_hexdump(stdout, "ciphertext:", ciphertext,
8153 tdata->ciphertext.len);
8155 if (ut_params->obuf) {
8156 plaintext = (uint8_t *)rte_pktmbuf_append(
8158 plaintext_pad_len + aad_pad_len);
8159 TEST_ASSERT_NOT_NULL(plaintext,
8160 "no room to append plaintext");
8162 memset(plaintext + aad_pad_len, 0,
8163 tdata->plaintext.len);
8167 /* Append digest data */
8168 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8169 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8170 ut_params->obuf ? ut_params->obuf :
8172 tdata->auth_tag.len);
8173 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8174 "no room to append digest");
8175 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8176 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8177 ut_params->obuf ? ut_params->obuf :
8182 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8183 ut_params->ibuf, tdata->auth_tag.len);
8184 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8185 "no room to append digest");
8186 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8188 plaintext_pad_len + aad_pad_len);
8190 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8191 tdata->auth_tag.len);
8192 debug_hexdump(stdout, "digest:",
8193 sym_op->aead.digest.data,
8194 tdata->auth_tag.len);
8197 sym_op->aead.data.length = tdata->plaintext.len;
8198 sym_op->aead.data.offset = aad_pad_len;
8204 test_authenticated_encryption(const struct aead_test_data *tdata)
8206 struct crypto_testsuite_params *ts_params = &testsuite_params;
8207 struct crypto_unittest_params *ut_params = &unittest_params;
8210 uint8_t *ciphertext, *auth_tag;
8211 uint16_t plaintext_pad_len;
8213 struct rte_cryptodev_info dev_info;
8215 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8216 uint64_t feat_flags = dev_info.feature_flags;
8218 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8219 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8220 printf("Device doesn't support RAW data-path APIs.\n");
8221 return TEST_SKIPPED;
8224 /* Verify the capabilities */
8225 struct rte_cryptodev_sym_capability_idx cap_idx;
8226 const struct rte_cryptodev_symmetric_capability *capability;
8227 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8228 cap_idx.algo.aead = tdata->algo;
8229 capability = rte_cryptodev_sym_capability_get(
8230 ts_params->valid_devs[0], &cap_idx);
8231 if (capability == NULL)
8232 return TEST_SKIPPED;
8233 if (rte_cryptodev_sym_capability_check_aead(
8234 capability, tdata->key.len, tdata->auth_tag.len,
8235 tdata->aad.len, tdata->iv.len))
8236 return TEST_SKIPPED;
8238 /* Create AEAD session */
8239 retval = create_aead_session(ts_params->valid_devs[0],
8241 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8242 tdata->key.data, tdata->key.len,
8243 tdata->aad.len, tdata->auth_tag.len,
8248 if (tdata->aad.len > MBUF_SIZE) {
8249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8250 /* Populate full size of add data */
8251 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8252 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8254 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8256 /* clear mbuf payload */
8257 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8258 rte_pktmbuf_tailroom(ut_params->ibuf));
8260 /* Create AEAD operation */
8261 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8265 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8267 ut_params->op->sym->m_src = ut_params->ibuf;
8269 /* Process crypto operation */
8270 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8271 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8272 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8273 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8274 ut_params->op, 0, 0, 0, 0);
8276 TEST_ASSERT_NOT_NULL(
8277 process_crypto_request(ts_params->valid_devs[0],
8278 ut_params->op), "failed to process sym crypto op");
8280 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8281 "crypto op processing failed");
8283 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8285 if (ut_params->op->sym->m_dst) {
8286 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8288 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8289 uint8_t *, plaintext_pad_len);
8291 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8293 ut_params->op->sym->cipher.data.offset);
8294 auth_tag = ciphertext + plaintext_pad_len;
8297 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8298 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8303 tdata->ciphertext.data,
8304 tdata->ciphertext.len,
8305 "Ciphertext data not as expected");
8307 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8309 tdata->auth_tag.data,
8310 tdata->auth_tag.len,
8311 "Generated auth tag not as expected");
8317 #ifdef RTE_LIB_SECURITY
8319 security_proto_supported(enum rte_security_session_action_type action,
8320 enum rte_security_session_protocol proto)
8322 struct crypto_testsuite_params *ts_params = &testsuite_params;
8324 const struct rte_security_capability *capabilities;
8325 const struct rte_security_capability *capability;
8328 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8329 rte_cryptodev_get_sec_ctx(
8330 ts_params->valid_devs[0]);
8333 capabilities = rte_security_capabilities_get(ctx);
8335 if (capabilities == NULL)
8338 while ((capability = &capabilities[i++])->action !=
8339 RTE_SECURITY_ACTION_TYPE_NONE) {
8340 if (capability->action == action &&
8341 capability->protocol == proto)
8348 /* Basic algorithm run function for async inplace mode.
8349 * Creates a session from input parameters and runs one operation
8350 * on input_vec. Checks the output of the crypto operation against
8353 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8354 enum rte_crypto_auth_operation opa,
8355 const uint8_t *input_vec, unsigned int input_vec_len,
8356 const uint8_t *output_vec,
8357 unsigned int output_vec_len,
8358 enum rte_crypto_cipher_algorithm cipher_alg,
8359 const uint8_t *cipher_key, uint32_t cipher_key_len,
8360 enum rte_crypto_auth_algorithm auth_alg,
8361 const uint8_t *auth_key, uint32_t auth_key_len,
8362 uint8_t bearer, enum rte_security_pdcp_domain domain,
8363 uint8_t packet_direction, uint8_t sn_size,
8364 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8366 struct crypto_testsuite_params *ts_params = &testsuite_params;
8367 struct crypto_unittest_params *ut_params = &unittest_params;
8369 int ret = TEST_SUCCESS;
8370 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8371 rte_cryptodev_get_sec_ctx(
8372 ts_params->valid_devs[0]);
8373 struct rte_cryptodev_info dev_info;
8374 uint64_t feat_flags;
8376 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8377 feat_flags = dev_info.feature_flags;
8379 /* Verify the capabilities */
8380 struct rte_security_capability_idx sec_cap_idx;
8382 sec_cap_idx.action = ut_params->type;
8383 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8384 sec_cap_idx.pdcp.domain = domain;
8385 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8386 return TEST_SKIPPED;
8388 /* Generate test mbuf data */
8389 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8391 /* clear mbuf payload */
8392 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8393 rte_pktmbuf_tailroom(ut_params->ibuf));
8395 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8397 memcpy(plaintext, input_vec, input_vec_len);
8399 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8400 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8401 printf("Device does not support RAW data-path APIs.\n");
8402 return TEST_SKIPPED;
8404 /* Out of place support */
8407 * For out-op-place we need to alloc another mbuf
8409 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8410 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8413 /* Setup Cipher Parameters */
8414 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8415 ut_params->cipher_xform.cipher.algo = cipher_alg;
8416 ut_params->cipher_xform.cipher.op = opc;
8417 ut_params->cipher_xform.cipher.key.data = cipher_key;
8418 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8419 ut_params->cipher_xform.cipher.iv.length =
8420 packet_direction ? 4 : 0;
8421 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8423 /* Setup HMAC Parameters if ICV header is required */
8424 if (auth_alg != 0) {
8425 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8426 ut_params->auth_xform.next = NULL;
8427 ut_params->auth_xform.auth.algo = auth_alg;
8428 ut_params->auth_xform.auth.op = opa;
8429 ut_params->auth_xform.auth.key.data = auth_key;
8430 ut_params->auth_xform.auth.key.length = auth_key_len;
8432 ut_params->cipher_xform.next = &ut_params->auth_xform;
8434 ut_params->cipher_xform.next = NULL;
8437 struct rte_security_session_conf sess_conf = {
8438 .action_type = ut_params->type,
8439 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8443 .pkt_dir = packet_direction,
8445 .hfn = packet_direction ? 0 : hfn,
8447 * hfn can be set as pdcp_test_hfn[i]
8448 * if hfn_ovrd is not set. Here, PDCP
8449 * packet direction is just used to
8450 * run half of the cases with session
8451 * HFN and other half with per packet
8454 .hfn_threshold = hfn_threshold,
8455 .hfn_ovrd = packet_direction ? 1 : 0,
8456 .sdap_enabled = sdap,
8458 .crypto_xform = &ut_params->cipher_xform
8461 /* Create security session */
8462 ut_params->sec_session = rte_security_session_create(ctx,
8463 &sess_conf, ts_params->session_mpool,
8464 ts_params->session_priv_mpool);
8466 if (!ut_params->sec_session) {
8467 printf("TestCase %s()-%d line %d failed %s: ",
8468 __func__, i, __LINE__, "Failed to allocate session");
8473 /* Generate crypto op data structure */
8474 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8475 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8476 if (!ut_params->op) {
8477 printf("TestCase %s()-%d line %d failed %s: ",
8478 __func__, i, __LINE__,
8479 "Failed to allocate symmetric crypto operation struct");
8484 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8485 uint32_t *, IV_OFFSET);
8486 *per_pkt_hfn = packet_direction ? hfn : 0;
8488 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8490 /* set crypto operation source mbuf */
8491 ut_params->op->sym->m_src = ut_params->ibuf;
8493 ut_params->op->sym->m_dst = ut_params->obuf;
8495 /* Process crypto operation */
8496 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8497 /* filling lengths */
8498 ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
8499 ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
8500 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8501 ut_params->op, 1, 1, 0, 0);
8503 ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8505 if (ut_params->op == NULL) {
8506 printf("TestCase %s()-%d line %d failed %s: ",
8507 __func__, i, __LINE__,
8508 "failed to process sym crypto op");
8513 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8514 printf("TestCase %s()-%d line %d failed %s: ",
8515 __func__, i, __LINE__, "crypto op processing failed");
8521 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8524 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8528 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8529 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8530 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8531 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8537 rte_crypto_op_free(ut_params->op);
8538 ut_params->op = NULL;
8540 if (ut_params->sec_session)
8541 rte_security_session_destroy(ctx, ut_params->sec_session);
8542 ut_params->sec_session = NULL;
8544 rte_pktmbuf_free(ut_params->ibuf);
8545 ut_params->ibuf = NULL;
8547 rte_pktmbuf_free(ut_params->obuf);
8548 ut_params->obuf = NULL;
8555 test_pdcp_proto_SGL(int i, int oop,
8556 enum rte_crypto_cipher_operation opc,
8557 enum rte_crypto_auth_operation opa,
8559 unsigned int input_vec_len,
8560 uint8_t *output_vec,
8561 unsigned int output_vec_len,
8563 uint32_t fragsz_oop)
8565 struct crypto_testsuite_params *ts_params = &testsuite_params;
8566 struct crypto_unittest_params *ut_params = &unittest_params;
8568 struct rte_mbuf *buf, *buf_oop = NULL;
8569 int ret = TEST_SUCCESS;
8573 unsigned int trn_data = 0;
8574 struct rte_cryptodev_info dev_info;
8575 uint64_t feat_flags;
8576 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8577 rte_cryptodev_get_sec_ctx(
8578 ts_params->valid_devs[0]);
8579 struct rte_mbuf *temp_mbuf;
8581 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8582 feat_flags = dev_info.feature_flags;
8584 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8585 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8586 printf("Device does not support RAW data-path APIs.\n");
8589 /* Verify the capabilities */
8590 struct rte_security_capability_idx sec_cap_idx;
8592 sec_cap_idx.action = ut_params->type;
8593 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8594 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8595 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8596 return TEST_SKIPPED;
8598 if (fragsz > input_vec_len)
8599 fragsz = input_vec_len;
8601 uint16_t plaintext_len = fragsz;
8602 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8604 if (fragsz_oop > output_vec_len)
8605 frag_size_oop = output_vec_len;
8608 if (input_vec_len % fragsz != 0) {
8609 if (input_vec_len / fragsz + 1 > 16)
8611 } else if (input_vec_len / fragsz > 16)
8614 /* Out of place support */
8617 * For out-op-place we need to alloc another mbuf
8619 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8620 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8621 buf_oop = ut_params->obuf;
8624 /* Generate test mbuf data */
8625 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8627 /* clear mbuf payload */
8628 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8629 rte_pktmbuf_tailroom(ut_params->ibuf));
8631 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8633 memcpy(plaintext, input_vec, plaintext_len);
8634 trn_data += plaintext_len;
8636 buf = ut_params->ibuf;
8639 * Loop until no more fragments
8642 while (trn_data < input_vec_len) {
8644 to_trn = (input_vec_len - trn_data < fragsz) ?
8645 (input_vec_len - trn_data) : fragsz;
8647 to_trn_tbl[ecx++] = to_trn;
8649 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8652 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8653 rte_pktmbuf_tailroom(buf));
8656 if (oop && !fragsz_oop) {
8658 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8659 buf_oop = buf_oop->next;
8660 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8661 0, rte_pktmbuf_tailroom(buf_oop));
8662 rte_pktmbuf_append(buf_oop, to_trn);
8665 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8668 memcpy(plaintext, input_vec + trn_data, to_trn);
8672 ut_params->ibuf->nb_segs = segs;
8675 if (fragsz_oop && oop) {
8679 trn_data = frag_size_oop;
8680 while (trn_data < output_vec_len) {
8683 (output_vec_len - trn_data <
8685 (output_vec_len - trn_data) :
8688 to_trn_tbl[ecx++] = to_trn;
8691 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8692 buf_oop = buf_oop->next;
8693 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8694 0, rte_pktmbuf_tailroom(buf_oop));
8695 rte_pktmbuf_append(buf_oop, to_trn);
8699 ut_params->obuf->nb_segs = segs;
8702 /* Setup Cipher Parameters */
8703 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8704 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8705 ut_params->cipher_xform.cipher.op = opc;
8706 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8707 ut_params->cipher_xform.cipher.key.length =
8708 pdcp_test_params[i].cipher_key_len;
8709 ut_params->cipher_xform.cipher.iv.length = 0;
8711 /* Setup HMAC Parameters if ICV header is required */
8712 if (pdcp_test_params[i].auth_alg != 0) {
8713 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8714 ut_params->auth_xform.next = NULL;
8715 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8716 ut_params->auth_xform.auth.op = opa;
8717 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8718 ut_params->auth_xform.auth.key.length =
8719 pdcp_test_params[i].auth_key_len;
8721 ut_params->cipher_xform.next = &ut_params->auth_xform;
8723 ut_params->cipher_xform.next = NULL;
8726 struct rte_security_session_conf sess_conf = {
8727 .action_type = ut_params->type,
8728 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8730 .bearer = pdcp_test_bearer[i],
8731 .domain = pdcp_test_params[i].domain,
8732 .pkt_dir = pdcp_test_packet_direction[i],
8733 .sn_size = pdcp_test_data_sn_size[i],
8734 .hfn = pdcp_test_hfn[i],
8735 .hfn_threshold = pdcp_test_hfn_threshold[i],
8738 .crypto_xform = &ut_params->cipher_xform
8741 /* Create security session */
8742 ut_params->sec_session = rte_security_session_create(ctx,
8743 &sess_conf, ts_params->session_mpool,
8744 ts_params->session_priv_mpool);
8746 if (!ut_params->sec_session) {
8747 printf("TestCase %s()-%d line %d failed %s: ",
8748 __func__, i, __LINE__, "Failed to allocate session");
8753 /* Generate crypto op data structure */
8754 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8755 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8756 if (!ut_params->op) {
8757 printf("TestCase %s()-%d line %d failed %s: ",
8758 __func__, i, __LINE__,
8759 "Failed to allocate symmetric crypto operation struct");
8764 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8766 /* set crypto operation source mbuf */
8767 ut_params->op->sym->m_src = ut_params->ibuf;
8769 ut_params->op->sym->m_dst = ut_params->obuf;
8771 /* Process crypto operation */
8772 temp_mbuf = ut_params->op->sym->m_src;
8773 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8774 /* filling lengths */
8776 ut_params->op->sym->cipher.data.length
8777 += temp_mbuf->pkt_len;
8778 ut_params->op->sym->auth.data.length
8779 += temp_mbuf->pkt_len;
8780 temp_mbuf = temp_mbuf->next;
8782 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8783 ut_params->op, 1, 1, 0, 0);
8785 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8788 if (ut_params->op == NULL) {
8789 printf("TestCase %s()-%d line %d failed %s: ",
8790 __func__, i, __LINE__,
8791 "failed to process sym crypto op");
8796 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8797 printf("TestCase %s()-%d line %d failed %s: ",
8798 __func__, i, __LINE__, "crypto op processing failed");
8804 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8807 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8811 fragsz = frag_size_oop;
8812 if (memcmp(ciphertext, output_vec, fragsz)) {
8813 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8814 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8815 rte_hexdump(stdout, "reference", output_vec, fragsz);
8820 buf = ut_params->op->sym->m_src->next;
8822 buf = ut_params->op->sym->m_dst->next;
8824 unsigned int off = fragsz;
8828 ciphertext = rte_pktmbuf_mtod(buf,
8830 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8831 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8832 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8833 rte_hexdump(stdout, "reference", output_vec + off,
8838 off += to_trn_tbl[ecx++];
8842 rte_crypto_op_free(ut_params->op);
8843 ut_params->op = NULL;
8845 if (ut_params->sec_session)
8846 rte_security_session_destroy(ctx, ut_params->sec_session);
8847 ut_params->sec_session = NULL;
8849 rte_pktmbuf_free(ut_params->ibuf);
8850 ut_params->ibuf = NULL;
8852 rte_pktmbuf_free(ut_params->obuf);
8853 ut_params->obuf = NULL;
8860 test_pdcp_proto_cplane_encap(int i)
8862 return test_pdcp_proto(
8863 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8864 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8865 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8866 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8867 pdcp_test_params[i].cipher_key_len,
8868 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8869 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8870 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8871 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8872 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8876 test_pdcp_proto_uplane_encap(int i)
8878 return test_pdcp_proto(
8879 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8880 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8881 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8882 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8883 pdcp_test_params[i].cipher_key_len,
8884 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8885 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8886 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8887 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8888 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8892 test_pdcp_proto_uplane_encap_with_int(int i)
8894 return test_pdcp_proto(
8895 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8896 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8897 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8898 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8899 pdcp_test_params[i].cipher_key_len,
8900 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8901 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8902 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8903 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8904 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8908 test_pdcp_proto_cplane_decap(int i)
8910 return test_pdcp_proto(
8911 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8912 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8913 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8914 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8915 pdcp_test_params[i].cipher_key_len,
8916 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8917 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8918 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8919 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8920 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8924 test_pdcp_proto_uplane_decap(int i)
8926 return test_pdcp_proto(
8927 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8928 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8929 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8930 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8931 pdcp_test_params[i].cipher_key_len,
8932 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8933 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8934 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8935 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8936 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8940 test_pdcp_proto_uplane_decap_with_int(int i)
8942 return test_pdcp_proto(
8943 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8944 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8945 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8946 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8947 pdcp_test_params[i].cipher_key_len,
8948 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8949 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8950 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8951 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8952 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8956 test_PDCP_PROTO_SGL_in_place_32B(void)
8958 /* i can be used for running any PDCP case
8959 * In this case it is uplane 12-bit AES-SNOW DL encap
8961 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8962 return test_pdcp_proto_SGL(i, IN_PLACE,
8963 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8964 RTE_CRYPTO_AUTH_OP_GENERATE,
8965 pdcp_test_data_in[i],
8966 pdcp_test_data_in_len[i],
8967 pdcp_test_data_out[i],
8968 pdcp_test_data_in_len[i]+4,
8972 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8974 /* i can be used for running any PDCP case
8975 * In this case it is uplane 18-bit NULL-NULL DL encap
8977 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8978 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8979 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8980 RTE_CRYPTO_AUTH_OP_GENERATE,
8981 pdcp_test_data_in[i],
8982 pdcp_test_data_in_len[i],
8983 pdcp_test_data_out[i],
8984 pdcp_test_data_in_len[i]+4,
8988 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8990 /* i can be used for running any PDCP case
8991 * In this case it is uplane 18-bit AES DL encap
8993 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8995 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8996 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8997 RTE_CRYPTO_AUTH_OP_GENERATE,
8998 pdcp_test_data_in[i],
8999 pdcp_test_data_in_len[i],
9000 pdcp_test_data_out[i],
9001 pdcp_test_data_in_len[i],
9005 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9007 /* i can be used for running any PDCP case
9008 * In this case it is cplane 12-bit AES-ZUC DL encap
9010 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9011 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9012 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9013 RTE_CRYPTO_AUTH_OP_GENERATE,
9014 pdcp_test_data_in[i],
9015 pdcp_test_data_in_len[i],
9016 pdcp_test_data_out[i],
9017 pdcp_test_data_in_len[i]+4,
9022 test_PDCP_SDAP_PROTO_encap_all(void)
9024 int i = 0, size = 0;
9025 int err, all_err = TEST_SUCCESS;
9026 const struct pdcp_sdap_test *cur_test;
9028 size = RTE_DIM(list_pdcp_sdap_tests);
9030 for (i = 0; i < size; i++) {
9031 cur_test = &list_pdcp_sdap_tests[i];
9032 err = test_pdcp_proto(
9033 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9034 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9035 cur_test->in_len, cur_test->data_out,
9036 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9037 cur_test->param.cipher_alg, cur_test->cipher_key,
9038 cur_test->param.cipher_key_len,
9039 cur_test->param.auth_alg,
9040 cur_test->auth_key, cur_test->param.auth_key_len,
9041 cur_test->bearer, cur_test->param.domain,
9042 cur_test->packet_direction, cur_test->sn_size,
9044 cur_test->hfn_threshold, SDAP_ENABLED);
9046 printf("\t%d) %s: Encapsulation failed\n",
9048 cur_test->param.name);
9051 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9052 cur_test->param.name);
9058 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9060 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9064 test_PDCP_PROTO_short_mac(void)
9066 int i = 0, size = 0;
9067 int err, all_err = TEST_SUCCESS;
9068 const struct pdcp_short_mac_test *cur_test;
9070 size = RTE_DIM(list_pdcp_smac_tests);
9072 for (i = 0; i < size; i++) {
9073 cur_test = &list_pdcp_smac_tests[i];
9074 err = test_pdcp_proto(
9075 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9076 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9077 cur_test->in_len, cur_test->data_out,
9078 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9079 RTE_CRYPTO_CIPHER_NULL, NULL,
9080 0, cur_test->param.auth_alg,
9081 cur_test->auth_key, cur_test->param.auth_key_len,
9082 0, cur_test->param.domain, 0, 0,
9085 printf("\t%d) %s: Short MAC test failed\n",
9087 cur_test->param.name);
9090 printf("\t%d) %s: Short MAC test PASS\n",
9092 cur_test->param.name);
9093 rte_hexdump(stdout, "MAC I",
9094 cur_test->data_out + cur_test->in_len + 2,
9101 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9103 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9108 test_PDCP_SDAP_PROTO_decap_all(void)
9110 int i = 0, size = 0;
9111 int err, all_err = TEST_SUCCESS;
9112 const struct pdcp_sdap_test *cur_test;
9114 size = RTE_DIM(list_pdcp_sdap_tests);
9116 for (i = 0; i < size; i++) {
9117 cur_test = &list_pdcp_sdap_tests[i];
9118 err = test_pdcp_proto(
9119 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9120 RTE_CRYPTO_AUTH_OP_VERIFY,
9122 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9123 cur_test->data_in, cur_test->in_len,
9124 cur_test->param.cipher_alg,
9125 cur_test->cipher_key, cur_test->param.cipher_key_len,
9126 cur_test->param.auth_alg, cur_test->auth_key,
9127 cur_test->param.auth_key_len, cur_test->bearer,
9128 cur_test->param.domain, cur_test->packet_direction,
9129 cur_test->sn_size, cur_test->hfn,
9130 cur_test->hfn_threshold, SDAP_ENABLED);
9132 printf("\t%d) %s: Decapsulation failed\n",
9134 cur_test->param.name);
9137 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9138 cur_test->param.name);
9144 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9146 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9150 test_ipsec_proto_process(const struct ipsec_test_data td[],
9151 struct ipsec_test_data res_d[],
9154 const struct ipsec_test_flags *flags)
9156 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9158 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9160 const struct rte_ipv4_hdr *ipv4 =
9161 (const struct rte_ipv4_hdr *)td[0].output_text.data;
9162 struct crypto_testsuite_params *ts_params = &testsuite_params;
9163 struct crypto_unittest_params *ut_params = &unittest_params;
9164 struct rte_security_capability_idx sec_cap_idx;
9165 const struct rte_security_capability *sec_cap;
9166 struct rte_security_ipsec_xform ipsec_xform;
9167 uint8_t dev_id = ts_params->valid_devs[0];
9168 enum rte_security_ipsec_sa_direction dir;
9169 struct ipsec_test_data *res_d_tmp = NULL;
9170 int salt_len, i, ret = TEST_SUCCESS;
9171 struct rte_security_ctx *ctx;
9172 uint8_t *input_text;
9176 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9177 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9179 /* Use first test data to create session */
9181 /* Copy IPsec xform */
9182 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9184 dir = ipsec_xform.direction;
9185 verify = flags->tunnel_hdr_verify;
9187 memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
9188 memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
9190 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9191 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9193 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9197 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9198 if (td->ipsec_xform.tunnel.type ==
9199 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9200 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9202 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9205 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9206 ipsec_xform.tunnel.ipv4.df = 0;
9208 if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9209 ipsec_xform.tunnel.ipv4.df = 1;
9211 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9212 ipsec_xform.tunnel.ipv4.dscp = 0;
9214 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9215 ipsec_xform.tunnel.ipv4.dscp =
9216 TEST_IPSEC_DSCP_VAL;
9219 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9220 ipsec_xform.tunnel.ipv6.dscp = 0;
9222 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9223 ipsec_xform.tunnel.ipv6.dscp =
9224 TEST_IPSEC_DSCP_VAL;
9226 memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9228 memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9233 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9235 sec_cap_idx.action = ut_params->type;
9236 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9237 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9238 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9239 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9241 if (flags->udp_encap)
9242 ipsec_xform.options.udp_encap = 1;
9244 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9245 if (sec_cap == NULL)
9246 return TEST_SKIPPED;
9248 /* Copy cipher session parameters */
9250 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9251 sizeof(ut_params->aead_xform));
9252 ut_params->aead_xform.aead.key.data = td[0].key.data;
9253 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9255 /* Verify crypto capabilities */
9256 if (test_ipsec_crypto_caps_aead_verify(
9258 &ut_params->aead_xform) != 0) {
9260 RTE_LOG(INFO, USER1,
9261 "Crypto capabilities not supported\n");
9262 return TEST_SKIPPED;
9264 } else if (td[0].auth_only) {
9265 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9266 sizeof(ut_params->auth_xform));
9267 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9269 if (test_ipsec_crypto_caps_auth_verify(
9271 &ut_params->auth_xform) != 0) {
9273 RTE_LOG(INFO, USER1,
9274 "Auth crypto capabilities not supported\n");
9275 return TEST_SKIPPED;
9278 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9279 sizeof(ut_params->cipher_xform));
9280 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9281 sizeof(ut_params->auth_xform));
9282 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9283 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9284 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9286 /* Verify crypto capabilities */
9288 if (test_ipsec_crypto_caps_cipher_verify(
9290 &ut_params->cipher_xform) != 0) {
9292 RTE_LOG(INFO, USER1,
9293 "Cipher crypto capabilities not supported\n");
9294 return TEST_SKIPPED;
9297 if (test_ipsec_crypto_caps_auth_verify(
9299 &ut_params->auth_xform) != 0) {
9301 RTE_LOG(INFO, USER1,
9302 "Auth crypto capabilities not supported\n");
9303 return TEST_SKIPPED;
9307 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9308 return TEST_SKIPPED;
9310 struct rte_security_session_conf sess_conf = {
9311 .action_type = ut_params->type,
9312 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9315 if (td[0].aead || td[0].aes_gmac) {
9316 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9317 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9321 sess_conf.ipsec = ipsec_xform;
9322 sess_conf.crypto_xform = &ut_params->aead_xform;
9323 } else if (td[0].auth_only) {
9324 sess_conf.ipsec = ipsec_xform;
9325 sess_conf.crypto_xform = &ut_params->auth_xform;
9327 sess_conf.ipsec = ipsec_xform;
9328 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9329 sess_conf.crypto_xform = &ut_params->cipher_xform;
9330 ut_params->cipher_xform.next = &ut_params->auth_xform;
9332 sess_conf.crypto_xform = &ut_params->auth_xform;
9333 ut_params->auth_xform.next = &ut_params->cipher_xform;
9337 /* Create security session */
9338 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9339 ts_params->session_mpool,
9340 ts_params->session_priv_mpool);
9342 if (ut_params->sec_session == NULL)
9343 return TEST_SKIPPED;
9345 for (i = 0; i < nb_td; i++) {
9346 if (flags->antireplay &&
9347 (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
9348 sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
9349 ret = rte_security_session_update(ctx,
9350 ut_params->sec_session, &sess_conf);
9352 printf("Could not update sequence number in "
9354 return TEST_SKIPPED;
9358 /* Setup source mbuf payload */
9359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9360 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9361 rte_pktmbuf_tailroom(ut_params->ibuf));
9363 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9364 td[i].input_text.len);
9366 memcpy(input_text, td[i].input_text.data,
9367 td[i].input_text.len);
9369 if (test_ipsec_pkt_update(input_text, flags))
9372 /* Generate crypto op data structure */
9373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9375 if (!ut_params->op) {
9376 printf("TestCase %s line %d: %s\n",
9378 "failed to allocate crypto op");
9380 goto crypto_op_free;
9383 /* Attach session to operation */
9384 rte_security_attach_session(ut_params->op,
9385 ut_params->sec_session);
9387 /* Set crypto operation mbufs */
9388 ut_params->op->sym->m_src = ut_params->ibuf;
9389 ut_params->op->sym->m_dst = NULL;
9391 /* Copy IV in crypto operation when IV generation is disabled */
9392 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9393 ipsec_xform.options.iv_gen_disable == 1) {
9394 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9400 len = td[i].xform.aead.aead.iv.length;
9401 else if (td[i].aes_gmac)
9402 len = td[i].xform.chain.auth.auth.iv.length;
9404 len = td[i].xform.chain.cipher.cipher.iv.length;
9406 memcpy(iv, td[i].iv.data, len);
9409 /* Process crypto operation */
9410 process_crypto_request(dev_id, ut_params->op);
9412 ret = test_ipsec_status_check(&td[i], ut_params->op, flags, dir,
9414 if (ret != TEST_SUCCESS)
9415 goto crypto_op_free;
9418 res_d_tmp = &res_d[i];
9420 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9421 res_d_tmp, silent, flags);
9422 if (ret != TEST_SUCCESS)
9423 goto crypto_op_free;
9425 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9427 if (ret != TEST_SUCCESS)
9428 goto crypto_op_free;
9430 rte_crypto_op_free(ut_params->op);
9431 ut_params->op = NULL;
9433 rte_pktmbuf_free(ut_params->ibuf);
9434 ut_params->ibuf = NULL;
9438 rte_crypto_op_free(ut_params->op);
9439 ut_params->op = NULL;
9441 rte_pktmbuf_free(ut_params->ibuf);
9442 ut_params->ibuf = NULL;
9444 if (ut_params->sec_session)
9445 rte_security_session_destroy(ctx, ut_params->sec_session);
9446 ut_params->sec_session = NULL;
9452 test_ipsec_proto_known_vec(const void *test_data)
9454 struct ipsec_test_data td_outb;
9455 struct ipsec_test_flags flags;
9457 memset(&flags, 0, sizeof(flags));
9459 memcpy(&td_outb, test_data, sizeof(td_outb));
9461 if (td_outb.aes_gmac || td_outb.aead ||
9462 ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
9463 (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
9464 /* Disable IV gen to be able to test with known vectors */
9465 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9468 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9472 test_ipsec_proto_known_vec_inb(const void *test_data)
9474 const struct ipsec_test_data *td = test_data;
9475 struct ipsec_test_flags flags;
9476 struct ipsec_test_data td_inb;
9478 memset(&flags, 0, sizeof(flags));
9480 if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9481 test_ipsec_td_in_from_out(td, &td_inb);
9483 memcpy(&td_inb, td, sizeof(td_inb));
9485 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9489 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9491 struct ipsec_test_data td_outb;
9492 struct ipsec_test_flags flags;
9494 memset(&flags, 0, sizeof(flags));
9495 flags.fragment = true;
9497 memcpy(&td_outb, test_data, sizeof(td_outb));
9499 /* Disable IV gen to be able to test with known vectors */
9500 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9502 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9506 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9508 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9509 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9510 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9513 if (flags->iv_gen ||
9514 flags->sa_expiry_pkts_soft ||
9515 flags->sa_expiry_pkts_hard)
9516 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9518 for (i = 0; i < RTE_DIM(alg_list); i++) {
9519 test_ipsec_td_prepare(alg_list[i].param1,
9525 if (!td_outb->aead) {
9526 enum rte_crypto_cipher_algorithm cipher_alg;
9527 enum rte_crypto_auth_algorithm auth_alg;
9529 cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9530 auth_alg = td_outb->xform.chain.auth.auth.algo;
9532 if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
9535 /* ICV is not applicable for NULL auth */
9536 if (flags->icv_corrupt &&
9537 auth_alg == RTE_CRYPTO_AUTH_NULL)
9540 /* IV is not applicable for NULL cipher */
9541 if (flags->iv_gen &&
9542 cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9546 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9548 if (ret == TEST_SKIPPED)
9551 if (ret == TEST_FAILED)
9554 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9556 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9558 if (ret == TEST_SKIPPED)
9561 if (ret == TEST_FAILED)
9564 if (flags->display_alg)
9565 test_ipsec_display_alg(alg_list[i].param1,
9566 alg_list[i].param2);
9572 return TEST_SUCCESS;
9574 return TEST_SKIPPED;
9578 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
9580 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9581 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9582 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9585 for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
9586 test_ipsec_td_prepare(ah_alg_list[i].param1,
9587 ah_alg_list[i].param2,
9592 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9594 if (ret == TEST_SKIPPED)
9597 if (ret == TEST_FAILED)
9600 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9602 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9604 if (ret == TEST_SKIPPED)
9607 if (ret == TEST_FAILED)
9610 if (flags->display_alg)
9611 test_ipsec_display_alg(ah_alg_list[i].param1,
9612 ah_alg_list[i].param2);
9618 return TEST_SUCCESS;
9620 return TEST_SKIPPED;
9624 test_ipsec_proto_display_list(const void *data __rte_unused)
9626 struct ipsec_test_flags flags;
9628 memset(&flags, 0, sizeof(flags));
9630 flags.display_alg = true;
9632 return test_ipsec_proto_all(&flags);
9636 test_ipsec_proto_ah_tunnel_ipv4(const void *data __rte_unused)
9638 struct ipsec_test_flags flags;
9640 memset(&flags, 0, sizeof(flags));
9643 flags.display_alg = true;
9645 return test_ipsec_ah_proto_all(&flags);
9649 test_ipsec_proto_ah_transport_ipv4(const void *data __rte_unused)
9651 struct ipsec_test_flags flags;
9653 memset(&flags, 0, sizeof(flags));
9656 flags.transport = true;
9658 return test_ipsec_ah_proto_all(&flags);
9662 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9664 struct ipsec_test_flags flags;
9666 memset(&flags, 0, sizeof(flags));
9668 flags.iv_gen = true;
9670 return test_ipsec_proto_all(&flags);
9674 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9676 struct ipsec_test_flags flags;
9678 memset(&flags, 0, sizeof(flags));
9680 flags.sa_expiry_pkts_soft = true;
9682 return test_ipsec_proto_all(&flags);
9686 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9688 struct ipsec_test_flags flags;
9690 memset(&flags, 0, sizeof(flags));
9692 flags.sa_expiry_pkts_hard = true;
9694 return test_ipsec_proto_all(&flags);
9698 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9700 struct ipsec_test_flags flags;
9702 memset(&flags, 0, sizeof(flags));
9704 flags.icv_corrupt = true;
9706 return test_ipsec_proto_all(&flags);
9710 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9712 struct ipsec_test_flags flags;
9714 memset(&flags, 0, sizeof(flags));
9716 flags.udp_encap = true;
9718 return test_ipsec_proto_all(&flags);
9722 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9724 struct ipsec_test_flags flags;
9726 memset(&flags, 0, sizeof(flags));
9728 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9730 return test_ipsec_proto_all(&flags);
9734 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9736 struct ipsec_test_flags flags;
9738 memset(&flags, 0, sizeof(flags));
9740 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9742 return test_ipsec_proto_all(&flags);
9746 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9748 struct ipsec_test_flags flags;
9750 memset(&flags, 0, sizeof(flags));
9752 flags.udp_encap = true;
9753 flags.udp_ports_verify = true;
9755 return test_ipsec_proto_all(&flags);
9759 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9761 struct ipsec_test_flags flags;
9763 memset(&flags, 0, sizeof(flags));
9765 flags.ip_csum = true;
9767 return test_ipsec_proto_all(&flags);
9771 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9773 struct ipsec_test_flags flags;
9775 memset(&flags, 0, sizeof(flags));
9777 flags.l4_csum = true;
9779 return test_ipsec_proto_all(&flags);
9783 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9785 struct ipsec_test_flags flags;
9787 memset(&flags, 0, sizeof(flags));
9790 flags.tunnel_ipv6 = false;
9792 return test_ipsec_proto_all(&flags);
9796 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9798 struct ipsec_test_flags flags;
9800 memset(&flags, 0, sizeof(flags));
9803 flags.tunnel_ipv6 = true;
9805 return test_ipsec_proto_all(&flags);
9809 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9811 struct ipsec_test_flags flags;
9813 memset(&flags, 0, sizeof(flags));
9816 flags.tunnel_ipv6 = true;
9818 return test_ipsec_proto_all(&flags);
9822 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9824 struct ipsec_test_flags flags;
9826 memset(&flags, 0, sizeof(flags));
9829 flags.tunnel_ipv6 = false;
9831 return test_ipsec_proto_all(&flags);
9835 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9837 struct ipsec_test_flags flags;
9839 memset(&flags, 0, sizeof(flags));
9842 flags.transport = true;
9844 return test_ipsec_proto_all(&flags);
9848 test_ipsec_proto_transport_l4_csum(const void *data __rte_unused)
9850 struct ipsec_test_flags flags = {
9855 return test_ipsec_proto_all(&flags);
9859 test_ipsec_proto_stats(const void *data __rte_unused)
9861 struct ipsec_test_flags flags;
9863 memset(&flags, 0, sizeof(flags));
9865 flags.stats_success = true;
9867 return test_ipsec_proto_all(&flags);
9871 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9873 struct ipsec_test_flags flags;
9875 memset(&flags, 0, sizeof(flags));
9877 flags.fragment = true;
9879 return test_ipsec_proto_all(&flags);
9884 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9886 struct ipsec_test_flags flags;
9888 memset(&flags, 0, sizeof(flags));
9890 flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9892 return test_ipsec_proto_all(&flags);
9896 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9898 struct ipsec_test_flags flags;
9900 memset(&flags, 0, sizeof(flags));
9902 flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9904 return test_ipsec_proto_all(&flags);
9908 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9910 struct ipsec_test_flags flags;
9912 memset(&flags, 0, sizeof(flags));
9914 flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9916 return test_ipsec_proto_all(&flags);
9920 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9922 struct ipsec_test_flags flags;
9924 memset(&flags, 0, sizeof(flags));
9926 flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9928 return test_ipsec_proto_all(&flags);
9932 test_ipsec_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
9934 struct ipsec_test_flags flags;
9936 memset(&flags, 0, sizeof(flags));
9938 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9940 return test_ipsec_proto_all(&flags);
9944 test_ipsec_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
9946 struct ipsec_test_flags flags;
9948 memset(&flags, 0, sizeof(flags));
9950 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
9952 return test_ipsec_proto_all(&flags);
9956 test_ipsec_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
9958 struct ipsec_test_flags flags;
9960 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9961 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9962 return TEST_SKIPPED;
9964 memset(&flags, 0, sizeof(flags));
9966 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
9968 return test_ipsec_proto_all(&flags);
9972 test_ipsec_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
9974 struct ipsec_test_flags flags;
9976 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9977 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9978 return TEST_SKIPPED;
9980 memset(&flags, 0, sizeof(flags));
9982 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
9984 return test_ipsec_proto_all(&flags);
9988 test_ipsec_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
9990 struct ipsec_test_flags flags;
9992 memset(&flags, 0, sizeof(flags));
9995 flags.tunnel_ipv6 = true;
9996 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9998 return test_ipsec_proto_all(&flags);
10002 test_ipsec_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
10004 struct ipsec_test_flags flags;
10006 memset(&flags, 0, sizeof(flags));
10009 flags.tunnel_ipv6 = true;
10010 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10012 return test_ipsec_proto_all(&flags);
10016 test_ipsec_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
10018 struct ipsec_test_flags flags;
10020 if (gbl_driver_id == rte_cryptodev_driver_id_get(
10021 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10022 return TEST_SKIPPED;
10024 memset(&flags, 0, sizeof(flags));
10027 flags.tunnel_ipv6 = true;
10028 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10030 return test_ipsec_proto_all(&flags);
10034 test_ipsec_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
10036 struct ipsec_test_flags flags;
10038 if (gbl_driver_id == rte_cryptodev_driver_id_get(
10039 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10040 return TEST_SKIPPED;
10042 memset(&flags, 0, sizeof(flags));
10045 flags.tunnel_ipv6 = true;
10046 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10048 return test_ipsec_proto_all(&flags);
10052 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
10053 bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
10056 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10057 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10058 struct ipsec_test_flags flags;
10059 uint32_t i = 0, ret = 0;
10061 memset(&flags, 0, sizeof(flags));
10062 flags.antireplay = true;
10064 for (i = 0; i < nb_pkts; i++) {
10065 memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
10066 td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
10067 td_outb[i].ipsec_xform.replay_win_sz = winsz;
10068 td_outb[i].ipsec_xform.options.esn = esn_en;
10071 for (i = 0; i < nb_pkts; i++)
10072 td_outb[i].ipsec_xform.esn.value = esn[i];
10074 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10076 if (ret != TEST_SUCCESS)
10079 test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
10081 for (i = 0; i < nb_pkts; i++) {
10082 td_inb[i].ipsec_xform.options.esn = esn_en;
10083 /* Set antireplay flag for packets to be dropped */
10084 td_inb[i].ar_packet = replayed_pkt[i];
10087 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10094 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
10097 uint32_t nb_pkts = 5;
10098 bool replayed_pkt[5];
10101 /* 1. Advance the TOP of the window to WS * 2 */
10102 esn[0] = winsz * 2;
10103 /* 2. Test sequence number within the new window(WS + 1) */
10104 esn[1] = winsz + 1;
10105 /* 3. Test sequence number less than the window BOTTOM */
10107 /* 4. Test sequence number in the middle of the window */
10108 esn[3] = winsz + (winsz / 2);
10109 /* 5. Test replay of the packet in the middle of the window */
10110 esn[4] = winsz + (winsz / 2);
10112 replayed_pkt[0] = false;
10113 replayed_pkt[1] = false;
10114 replayed_pkt[2] = true;
10115 replayed_pkt[3] = false;
10116 replayed_pkt[4] = true;
10118 return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10123 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
10125 return test_ipsec_proto_pkt_antireplay(test_data, 1024);
10129 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
10131 return test_ipsec_proto_pkt_antireplay(test_data, 2048);
10135 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
10137 return test_ipsec_proto_pkt_antireplay(test_data, 4096);
10141 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
10144 uint32_t nb_pkts = 7;
10145 bool replayed_pkt[7];
10148 /* Set the initial sequence number */
10149 esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
10150 /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
10151 esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
10152 /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
10153 esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
10154 /* 3. Test with sequence number within window (1<<32 - 1) */
10155 esn[3] = (uint64_t)((1ULL << 32) - 1);
10156 /* 4. Test with sequence number within window (1<<32 - 1) */
10157 esn[4] = (uint64_t)(1ULL << 32);
10158 /* 5. Test with duplicate sequence number within
10159 * new window (1<<32 - 1)
10161 esn[5] = (uint64_t)((1ULL << 32) - 1);
10162 /* 6. Test with duplicate sequence number within new window (1<<32) */
10163 esn[6] = (uint64_t)(1ULL << 32);
10165 replayed_pkt[0] = false;
10166 replayed_pkt[1] = false;
10167 replayed_pkt[2] = false;
10168 replayed_pkt[3] = false;
10169 replayed_pkt[4] = false;
10170 replayed_pkt[5] = true;
10171 replayed_pkt[6] = true;
10173 return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10178 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
10180 return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
10184 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
10186 return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
10190 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
10192 return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
10196 test_PDCP_PROTO_all(void)
10198 struct crypto_testsuite_params *ts_params = &testsuite_params;
10199 struct crypto_unittest_params *ut_params = &unittest_params;
10200 struct rte_cryptodev_info dev_info;
10203 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10204 uint64_t feat_flags = dev_info.feature_flags;
10206 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
10207 return TEST_SKIPPED;
10209 /* Set action type */
10210 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10211 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10214 if (security_proto_supported(ut_params->type,
10215 RTE_SECURITY_PROTOCOL_PDCP) < 0)
10216 return TEST_SKIPPED;
10218 status = test_PDCP_PROTO_cplane_encap_all();
10219 status += test_PDCP_PROTO_cplane_decap_all();
10220 status += test_PDCP_PROTO_uplane_encap_all();
10221 status += test_PDCP_PROTO_uplane_decap_all();
10222 status += test_PDCP_PROTO_SGL_in_place_32B();
10223 status += test_PDCP_PROTO_SGL_oop_32B_128B();
10224 status += test_PDCP_PROTO_SGL_oop_32B_40B();
10225 status += test_PDCP_PROTO_SGL_oop_128B_32B();
10226 status += test_PDCP_SDAP_PROTO_encap_all();
10227 status += test_PDCP_SDAP_PROTO_decap_all();
10228 status += test_PDCP_PROTO_short_mac();
10231 return TEST_FAILED;
10233 return TEST_SUCCESS;
10237 test_ipsec_proto_ipv4_ttl_decrement(const void *data __rte_unused)
10239 struct ipsec_test_flags flags = {
10240 .dec_ttl_or_hop_limit = true
10243 return test_ipsec_proto_all(&flags);
10247 test_ipsec_proto_ipv6_hop_limit_decrement(const void *data __rte_unused)
10249 struct ipsec_test_flags flags = {
10251 .dec_ttl_or_hop_limit = true
10254 return test_ipsec_proto_all(&flags);
10258 test_docsis_proto_uplink(const void *data)
10260 const struct docsis_test_data *d_td = data;
10261 struct crypto_testsuite_params *ts_params = &testsuite_params;
10262 struct crypto_unittest_params *ut_params = &unittest_params;
10263 uint8_t *plaintext = NULL;
10264 uint8_t *ciphertext = NULL;
10266 int32_t cipher_len, crc_len;
10267 uint32_t crc_data_len;
10268 int ret = TEST_SUCCESS;
10270 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10271 rte_cryptodev_get_sec_ctx(
10272 ts_params->valid_devs[0]);
10274 /* Verify the capabilities */
10275 struct rte_security_capability_idx sec_cap_idx;
10276 const struct rte_security_capability *sec_cap;
10277 const struct rte_cryptodev_capabilities *crypto_cap;
10278 const struct rte_cryptodev_symmetric_capability *sym_cap;
10281 /* Set action type */
10282 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10283 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10286 if (security_proto_supported(ut_params->type,
10287 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10288 return TEST_SKIPPED;
10290 sec_cap_idx.action = ut_params->type;
10291 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10292 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
10294 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10295 if (sec_cap == NULL)
10296 return TEST_SKIPPED;
10298 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10299 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10300 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10301 crypto_cap->sym.xform_type ==
10302 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10303 crypto_cap->sym.cipher.algo ==
10304 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10305 sym_cap = &crypto_cap->sym;
10306 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10308 d_td->iv.len) == 0)
10313 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10314 return TEST_SKIPPED;
10316 /* Setup source mbuf payload */
10317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10318 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10319 rte_pktmbuf_tailroom(ut_params->ibuf));
10321 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10322 d_td->ciphertext.len);
10324 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
10326 /* Setup cipher session parameters */
10327 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10328 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10329 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10330 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10331 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10332 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10333 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10334 ut_params->cipher_xform.next = NULL;
10336 /* Setup DOCSIS session parameters */
10337 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
10339 struct rte_security_session_conf sess_conf = {
10340 .action_type = ut_params->type,
10341 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10342 .docsis = ut_params->docsis_xform,
10343 .crypto_xform = &ut_params->cipher_xform,
10346 /* Create security session */
10347 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10348 ts_params->session_mpool,
10349 ts_params->session_priv_mpool);
10351 if (!ut_params->sec_session) {
10352 printf("Test function %s line %u: failed to allocate session\n",
10353 __func__, __LINE__);
10358 /* Generate crypto op data structure */
10359 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10360 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10361 if (!ut_params->op) {
10362 printf("Test function %s line %u: failed to allocate symmetric "
10363 "crypto operation\n", __func__, __LINE__);
10368 /* Setup CRC operation parameters */
10369 crc_len = d_td->ciphertext.no_crc == false ?
10370 (d_td->ciphertext.len -
10371 d_td->ciphertext.crc_offset -
10372 RTE_ETHER_CRC_LEN) :
10374 crc_len = crc_len > 0 ? crc_len : 0;
10375 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
10376 ut_params->op->sym->auth.data.length = crc_len;
10377 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
10379 /* Setup cipher operation parameters */
10380 cipher_len = d_td->ciphertext.no_cipher == false ?
10381 (d_td->ciphertext.len -
10382 d_td->ciphertext.cipher_offset) :
10384 cipher_len = cipher_len > 0 ? cipher_len : 0;
10385 ut_params->op->sym->cipher.data.length = cipher_len;
10386 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
10388 /* Setup cipher IV */
10389 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10390 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10392 /* Attach session to operation */
10393 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10395 /* Set crypto operation mbufs */
10396 ut_params->op->sym->m_src = ut_params->ibuf;
10397 ut_params->op->sym->m_dst = NULL;
10399 /* Process crypto operation */
10400 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10402 printf("Test function %s line %u: failed to process security "
10403 "crypto op\n", __func__, __LINE__);
10408 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10409 printf("Test function %s line %u: failed to process crypto op\n",
10410 __func__, __LINE__);
10415 /* Validate plaintext */
10416 plaintext = ciphertext;
10418 if (memcmp(plaintext, d_td->plaintext.data,
10419 d_td->plaintext.len - crc_data_len)) {
10420 printf("Test function %s line %u: plaintext not as expected\n",
10421 __func__, __LINE__);
10422 rte_hexdump(stdout, "expected", d_td->plaintext.data,
10423 d_td->plaintext.len);
10424 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
10430 rte_crypto_op_free(ut_params->op);
10431 ut_params->op = NULL;
10433 if (ut_params->sec_session)
10434 rte_security_session_destroy(ctx, ut_params->sec_session);
10435 ut_params->sec_session = NULL;
10437 rte_pktmbuf_free(ut_params->ibuf);
10438 ut_params->ibuf = NULL;
10444 test_docsis_proto_downlink(const void *data)
10446 const struct docsis_test_data *d_td = data;
10447 struct crypto_testsuite_params *ts_params = &testsuite_params;
10448 struct crypto_unittest_params *ut_params = &unittest_params;
10449 uint8_t *plaintext = NULL;
10450 uint8_t *ciphertext = NULL;
10452 int32_t cipher_len, crc_len;
10453 int ret = TEST_SUCCESS;
10455 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10456 rte_cryptodev_get_sec_ctx(
10457 ts_params->valid_devs[0]);
10459 /* Verify the capabilities */
10460 struct rte_security_capability_idx sec_cap_idx;
10461 const struct rte_security_capability *sec_cap;
10462 const struct rte_cryptodev_capabilities *crypto_cap;
10463 const struct rte_cryptodev_symmetric_capability *sym_cap;
10466 /* Set action type */
10467 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10468 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10471 if (security_proto_supported(ut_params->type,
10472 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10473 return TEST_SKIPPED;
10475 sec_cap_idx.action = ut_params->type;
10476 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10477 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10479 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10480 if (sec_cap == NULL)
10481 return TEST_SKIPPED;
10483 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10484 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10485 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10486 crypto_cap->sym.xform_type ==
10487 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10488 crypto_cap->sym.cipher.algo ==
10489 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10490 sym_cap = &crypto_cap->sym;
10491 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10493 d_td->iv.len) == 0)
10498 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10499 return TEST_SKIPPED;
10501 /* Setup source mbuf payload */
10502 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10503 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10504 rte_pktmbuf_tailroom(ut_params->ibuf));
10506 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10507 d_td->plaintext.len);
10509 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10511 /* Setup cipher session parameters */
10512 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10513 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10514 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10515 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10516 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10517 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10518 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10519 ut_params->cipher_xform.next = NULL;
10521 /* Setup DOCSIS session parameters */
10522 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10524 struct rte_security_session_conf sess_conf = {
10525 .action_type = ut_params->type,
10526 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10527 .docsis = ut_params->docsis_xform,
10528 .crypto_xform = &ut_params->cipher_xform,
10531 /* Create security session */
10532 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10533 ts_params->session_mpool,
10534 ts_params->session_priv_mpool);
10536 if (!ut_params->sec_session) {
10537 printf("Test function %s line %u: failed to allocate session\n",
10538 __func__, __LINE__);
10543 /* Generate crypto op data structure */
10544 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10545 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10546 if (!ut_params->op) {
10547 printf("Test function %s line %u: failed to allocate symmetric "
10548 "crypto operation\n", __func__, __LINE__);
10553 /* Setup CRC operation parameters */
10554 crc_len = d_td->plaintext.no_crc == false ?
10555 (d_td->plaintext.len -
10556 d_td->plaintext.crc_offset -
10557 RTE_ETHER_CRC_LEN) :
10559 crc_len = crc_len > 0 ? crc_len : 0;
10560 ut_params->op->sym->auth.data.length = crc_len;
10561 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10563 /* Setup cipher operation parameters */
10564 cipher_len = d_td->plaintext.no_cipher == false ?
10565 (d_td->plaintext.len -
10566 d_td->plaintext.cipher_offset) :
10568 cipher_len = cipher_len > 0 ? cipher_len : 0;
10569 ut_params->op->sym->cipher.data.length = cipher_len;
10570 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10572 /* Setup cipher IV */
10573 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10574 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10576 /* Attach session to operation */
10577 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10579 /* Set crypto operation mbufs */
10580 ut_params->op->sym->m_src = ut_params->ibuf;
10581 ut_params->op->sym->m_dst = NULL;
10583 /* Process crypto operation */
10584 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10586 printf("Test function %s line %u: failed to process crypto op\n",
10587 __func__, __LINE__);
10592 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10593 printf("Test function %s line %u: crypto op processing failed\n",
10594 __func__, __LINE__);
10599 /* Validate ciphertext */
10600 ciphertext = plaintext;
10602 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10603 printf("Test function %s line %u: plaintext not as expected\n",
10604 __func__, __LINE__);
10605 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10606 d_td->ciphertext.len);
10607 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10613 rte_crypto_op_free(ut_params->op);
10614 ut_params->op = NULL;
10616 if (ut_params->sec_session)
10617 rte_security_session_destroy(ctx, ut_params->sec_session);
10618 ut_params->sec_session = NULL;
10620 rte_pktmbuf_free(ut_params->ibuf);
10621 ut_params->ibuf = NULL;
10628 test_AES_GCM_authenticated_encryption_test_case_1(void)
10630 return test_authenticated_encryption(&gcm_test_case_1);
10634 test_AES_GCM_authenticated_encryption_test_case_2(void)
10636 return test_authenticated_encryption(&gcm_test_case_2);
10640 test_AES_GCM_authenticated_encryption_test_case_3(void)
10642 return test_authenticated_encryption(&gcm_test_case_3);
10646 test_AES_GCM_authenticated_encryption_test_case_4(void)
10648 return test_authenticated_encryption(&gcm_test_case_4);
10652 test_AES_GCM_authenticated_encryption_test_case_5(void)
10654 return test_authenticated_encryption(&gcm_test_case_5);
10658 test_AES_GCM_authenticated_encryption_test_case_6(void)
10660 return test_authenticated_encryption(&gcm_test_case_6);
10664 test_AES_GCM_authenticated_encryption_test_case_7(void)
10666 return test_authenticated_encryption(&gcm_test_case_7);
10670 test_AES_GCM_authenticated_encryption_test_case_8(void)
10672 return test_authenticated_encryption(&gcm_test_case_8);
10676 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10678 return test_authenticated_encryption(&gcm_J0_test_case_1);
10682 test_AES_GCM_auth_encryption_test_case_192_1(void)
10684 return test_authenticated_encryption(&gcm_test_case_192_1);
10688 test_AES_GCM_auth_encryption_test_case_192_2(void)
10690 return test_authenticated_encryption(&gcm_test_case_192_2);
10694 test_AES_GCM_auth_encryption_test_case_192_3(void)
10696 return test_authenticated_encryption(&gcm_test_case_192_3);
10700 test_AES_GCM_auth_encryption_test_case_192_4(void)
10702 return test_authenticated_encryption(&gcm_test_case_192_4);
10706 test_AES_GCM_auth_encryption_test_case_192_5(void)
10708 return test_authenticated_encryption(&gcm_test_case_192_5);
10712 test_AES_GCM_auth_encryption_test_case_192_6(void)
10714 return test_authenticated_encryption(&gcm_test_case_192_6);
10718 test_AES_GCM_auth_encryption_test_case_192_7(void)
10720 return test_authenticated_encryption(&gcm_test_case_192_7);
10724 test_AES_GCM_auth_encryption_test_case_256_1(void)
10726 return test_authenticated_encryption(&gcm_test_case_256_1);
10730 test_AES_GCM_auth_encryption_test_case_256_2(void)
10732 return test_authenticated_encryption(&gcm_test_case_256_2);
10736 test_AES_GCM_auth_encryption_test_case_256_3(void)
10738 return test_authenticated_encryption(&gcm_test_case_256_3);
10742 test_AES_GCM_auth_encryption_test_case_256_4(void)
10744 return test_authenticated_encryption(&gcm_test_case_256_4);
10748 test_AES_GCM_auth_encryption_test_case_256_5(void)
10750 return test_authenticated_encryption(&gcm_test_case_256_5);
10754 test_AES_GCM_auth_encryption_test_case_256_6(void)
10756 return test_authenticated_encryption(&gcm_test_case_256_6);
10760 test_AES_GCM_auth_encryption_test_case_256_7(void)
10762 return test_authenticated_encryption(&gcm_test_case_256_7);
10766 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10768 return test_authenticated_encryption(&gcm_test_case_aad_1);
10772 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10774 return test_authenticated_encryption(&gcm_test_case_aad_2);
10778 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10780 struct aead_test_data tdata;
10783 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10784 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10785 tdata.iv.data[0] += 1;
10786 res = test_authenticated_encryption(&tdata);
10787 if (res == TEST_SKIPPED)
10789 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10790 return TEST_SUCCESS;
10794 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10796 struct aead_test_data tdata;
10799 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10800 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10801 tdata.plaintext.data[0] += 1;
10802 res = test_authenticated_encryption(&tdata);
10803 if (res == TEST_SKIPPED)
10805 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10806 return TEST_SUCCESS;
10810 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10812 struct aead_test_data tdata;
10815 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10816 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10817 tdata.ciphertext.data[0] += 1;
10818 res = test_authenticated_encryption(&tdata);
10819 if (res == TEST_SKIPPED)
10821 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10822 return TEST_SUCCESS;
10826 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10828 struct aead_test_data tdata;
10831 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10832 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10833 tdata.aad.len += 1;
10834 res = test_authenticated_encryption(&tdata);
10835 if (res == TEST_SKIPPED)
10837 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10838 return TEST_SUCCESS;
10842 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10844 struct aead_test_data tdata;
10845 uint8_t aad[gcm_test_case_7.aad.len];
10848 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10849 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10850 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10852 tdata.aad.data = aad;
10853 res = test_authenticated_encryption(&tdata);
10854 if (res == TEST_SKIPPED)
10856 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10857 return TEST_SUCCESS;
10861 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10863 struct aead_test_data tdata;
10866 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10867 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10868 tdata.auth_tag.data[0] += 1;
10869 res = test_authenticated_encryption(&tdata);
10870 if (res == TEST_SKIPPED)
10872 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10873 return TEST_SUCCESS;
10877 test_authenticated_decryption(const struct aead_test_data *tdata)
10879 struct crypto_testsuite_params *ts_params = &testsuite_params;
10880 struct crypto_unittest_params *ut_params = &unittest_params;
10883 uint8_t *plaintext;
10885 struct rte_cryptodev_info dev_info;
10887 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10888 uint64_t feat_flags = dev_info.feature_flags;
10890 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10891 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10892 printf("Device doesn't support RAW data-path APIs.\n");
10893 return TEST_SKIPPED;
10896 /* Verify the capabilities */
10897 struct rte_cryptodev_sym_capability_idx cap_idx;
10898 const struct rte_cryptodev_symmetric_capability *capability;
10899 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10900 cap_idx.algo.aead = tdata->algo;
10901 capability = rte_cryptodev_sym_capability_get(
10902 ts_params->valid_devs[0], &cap_idx);
10903 if (capability == NULL)
10904 return TEST_SKIPPED;
10905 if (rte_cryptodev_sym_capability_check_aead(
10906 capability, tdata->key.len, tdata->auth_tag.len,
10907 tdata->aad.len, tdata->iv.len))
10908 return TEST_SKIPPED;
10910 /* Create AEAD session */
10911 retval = create_aead_session(ts_params->valid_devs[0],
10913 RTE_CRYPTO_AEAD_OP_DECRYPT,
10914 tdata->key.data, tdata->key.len,
10915 tdata->aad.len, tdata->auth_tag.len,
10920 /* alloc mbuf and set payload */
10921 if (tdata->aad.len > MBUF_SIZE) {
10922 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10923 /* Populate full size of add data */
10924 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10925 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10927 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10929 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10930 rte_pktmbuf_tailroom(ut_params->ibuf));
10932 /* Create AEAD operation */
10933 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10937 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10939 ut_params->op->sym->m_src = ut_params->ibuf;
10941 /* Process crypto operation */
10942 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10943 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10944 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10945 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10946 ut_params->op, 0, 0, 0, 0);
10948 TEST_ASSERT_NOT_NULL(
10949 process_crypto_request(ts_params->valid_devs[0],
10950 ut_params->op), "failed to process sym crypto op");
10952 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10953 "crypto op processing failed");
10955 if (ut_params->op->sym->m_dst)
10956 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10959 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10961 ut_params->op->sym->cipher.data.offset);
10963 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10965 /* Validate obuf */
10966 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10968 tdata->plaintext.data,
10969 tdata->plaintext.len,
10970 "Plaintext data not as expected");
10972 TEST_ASSERT_EQUAL(ut_params->op->status,
10973 RTE_CRYPTO_OP_STATUS_SUCCESS,
10974 "Authentication failed");
10980 test_AES_GCM_authenticated_decryption_test_case_1(void)
10982 return test_authenticated_decryption(&gcm_test_case_1);
10986 test_AES_GCM_authenticated_decryption_test_case_2(void)
10988 return test_authenticated_decryption(&gcm_test_case_2);
10992 test_AES_GCM_authenticated_decryption_test_case_3(void)
10994 return test_authenticated_decryption(&gcm_test_case_3);
10998 test_AES_GCM_authenticated_decryption_test_case_4(void)
11000 return test_authenticated_decryption(&gcm_test_case_4);
11004 test_AES_GCM_authenticated_decryption_test_case_5(void)
11006 return test_authenticated_decryption(&gcm_test_case_5);
11010 test_AES_GCM_authenticated_decryption_test_case_6(void)
11012 return test_authenticated_decryption(&gcm_test_case_6);
11016 test_AES_GCM_authenticated_decryption_test_case_7(void)
11018 return test_authenticated_decryption(&gcm_test_case_7);
11022 test_AES_GCM_authenticated_decryption_test_case_8(void)
11024 return test_authenticated_decryption(&gcm_test_case_8);
11028 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
11030 return test_authenticated_decryption(&gcm_J0_test_case_1);
11034 test_AES_GCM_auth_decryption_test_case_192_1(void)
11036 return test_authenticated_decryption(&gcm_test_case_192_1);
11040 test_AES_GCM_auth_decryption_test_case_192_2(void)
11042 return test_authenticated_decryption(&gcm_test_case_192_2);
11046 test_AES_GCM_auth_decryption_test_case_192_3(void)
11048 return test_authenticated_decryption(&gcm_test_case_192_3);
11052 test_AES_GCM_auth_decryption_test_case_192_4(void)
11054 return test_authenticated_decryption(&gcm_test_case_192_4);
11058 test_AES_GCM_auth_decryption_test_case_192_5(void)
11060 return test_authenticated_decryption(&gcm_test_case_192_5);
11064 test_AES_GCM_auth_decryption_test_case_192_6(void)
11066 return test_authenticated_decryption(&gcm_test_case_192_6);
11070 test_AES_GCM_auth_decryption_test_case_192_7(void)
11072 return test_authenticated_decryption(&gcm_test_case_192_7);
11076 test_AES_GCM_auth_decryption_test_case_256_1(void)
11078 return test_authenticated_decryption(&gcm_test_case_256_1);
11082 test_AES_GCM_auth_decryption_test_case_256_2(void)
11084 return test_authenticated_decryption(&gcm_test_case_256_2);
11088 test_AES_GCM_auth_decryption_test_case_256_3(void)
11090 return test_authenticated_decryption(&gcm_test_case_256_3);
11094 test_AES_GCM_auth_decryption_test_case_256_4(void)
11096 return test_authenticated_decryption(&gcm_test_case_256_4);
11100 test_AES_GCM_auth_decryption_test_case_256_5(void)
11102 return test_authenticated_decryption(&gcm_test_case_256_5);
11106 test_AES_GCM_auth_decryption_test_case_256_6(void)
11108 return test_authenticated_decryption(&gcm_test_case_256_6);
11112 test_AES_GCM_auth_decryption_test_case_256_7(void)
11114 return test_authenticated_decryption(&gcm_test_case_256_7);
11118 test_AES_GCM_auth_decryption_test_case_aad_1(void)
11120 return test_authenticated_decryption(&gcm_test_case_aad_1);
11124 test_AES_GCM_auth_decryption_test_case_aad_2(void)
11126 return test_authenticated_decryption(&gcm_test_case_aad_2);
11130 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
11132 struct aead_test_data tdata;
11135 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11136 tdata.iv.data[0] += 1;
11137 res = test_authenticated_decryption(&tdata);
11138 if (res == TEST_SKIPPED)
11140 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11141 return TEST_SUCCESS;
11145 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
11147 struct aead_test_data tdata;
11150 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11151 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11152 tdata.plaintext.data[0] += 1;
11153 res = test_authenticated_decryption(&tdata);
11154 if (res == TEST_SKIPPED)
11156 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11157 return TEST_SUCCESS;
11161 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
11163 struct aead_test_data tdata;
11166 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11167 tdata.ciphertext.data[0] += 1;
11168 res = test_authenticated_decryption(&tdata);
11169 if (res == TEST_SKIPPED)
11171 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11172 return TEST_SUCCESS;
11176 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
11178 struct aead_test_data tdata;
11181 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11182 tdata.aad.len += 1;
11183 res = test_authenticated_decryption(&tdata);
11184 if (res == TEST_SKIPPED)
11186 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11187 return TEST_SUCCESS;
11191 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
11193 struct aead_test_data tdata;
11194 uint8_t aad[gcm_test_case_7.aad.len];
11197 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11198 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11200 tdata.aad.data = aad;
11201 res = test_authenticated_decryption(&tdata);
11202 if (res == TEST_SKIPPED)
11204 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11205 return TEST_SUCCESS;
11209 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
11211 struct aead_test_data tdata;
11214 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11215 tdata.auth_tag.data[0] += 1;
11216 res = test_authenticated_decryption(&tdata);
11217 if (res == TEST_SKIPPED)
11219 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
11220 return TEST_SUCCESS;
11224 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
11226 struct crypto_testsuite_params *ts_params = &testsuite_params;
11227 struct crypto_unittest_params *ut_params = &unittest_params;
11230 uint8_t *ciphertext, *auth_tag;
11231 uint16_t plaintext_pad_len;
11232 struct rte_cryptodev_info dev_info;
11234 /* Verify the capabilities */
11235 struct rte_cryptodev_sym_capability_idx cap_idx;
11236 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11237 cap_idx.algo.aead = tdata->algo;
11238 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11240 return TEST_SKIPPED;
11242 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11243 uint64_t feat_flags = dev_info.feature_flags;
11245 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11246 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
11247 return TEST_SKIPPED;
11249 /* not supported with CPU crypto */
11250 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11251 return TEST_SKIPPED;
11253 /* Create AEAD session */
11254 retval = create_aead_session(ts_params->valid_devs[0],
11256 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11257 tdata->key.data, tdata->key.len,
11258 tdata->aad.len, tdata->auth_tag.len,
11263 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11264 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11266 /* clear mbuf payload */
11267 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11268 rte_pktmbuf_tailroom(ut_params->ibuf));
11269 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11270 rte_pktmbuf_tailroom(ut_params->obuf));
11272 /* Create AEAD operation */
11273 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11277 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11279 ut_params->op->sym->m_src = ut_params->ibuf;
11280 ut_params->op->sym->m_dst = ut_params->obuf;
11282 /* Process crypto operation */
11283 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11284 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11285 ut_params->op, 0, 0, 0, 0);
11287 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11288 ut_params->op), "failed to process sym crypto op");
11290 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11291 "crypto op processing failed");
11293 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11295 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11296 ut_params->op->sym->cipher.data.offset);
11297 auth_tag = ciphertext + plaintext_pad_len;
11299 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11300 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11302 /* Validate obuf */
11303 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11305 tdata->ciphertext.data,
11306 tdata->ciphertext.len,
11307 "Ciphertext data not as expected");
11309 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11311 tdata->auth_tag.data,
11312 tdata->auth_tag.len,
11313 "Generated auth tag not as expected");
11320 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
11322 return test_authenticated_encryption_oop(&gcm_test_case_5);
11326 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
11328 struct crypto_testsuite_params *ts_params = &testsuite_params;
11329 struct crypto_unittest_params *ut_params = &unittest_params;
11332 uint8_t *plaintext;
11333 struct rte_cryptodev_info dev_info;
11335 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11336 uint64_t feat_flags = dev_info.feature_flags;
11338 /* Verify the capabilities */
11339 struct rte_cryptodev_sym_capability_idx cap_idx;
11340 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11341 cap_idx.algo.aead = tdata->algo;
11342 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11344 return TEST_SKIPPED;
11346 /* not supported with CPU crypto and raw data-path APIs*/
11347 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
11348 global_api_test_type == CRYPTODEV_RAW_API_TEST)
11349 return TEST_SKIPPED;
11351 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11352 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11353 printf("Device does not support RAW data-path APIs.\n");
11354 return TEST_SKIPPED;
11357 /* Create AEAD session */
11358 retval = create_aead_session(ts_params->valid_devs[0],
11360 RTE_CRYPTO_AEAD_OP_DECRYPT,
11361 tdata->key.data, tdata->key.len,
11362 tdata->aad.len, tdata->auth_tag.len,
11367 /* alloc mbuf and set payload */
11368 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11369 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11371 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11372 rte_pktmbuf_tailroom(ut_params->ibuf));
11373 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11374 rte_pktmbuf_tailroom(ut_params->obuf));
11376 /* Create AEAD operation */
11377 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11383 ut_params->op->sym->m_src = ut_params->ibuf;
11384 ut_params->op->sym->m_dst = ut_params->obuf;
11386 /* Process crypto operation */
11387 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11388 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11389 ut_params->op, 0, 0, 0, 0);
11391 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11392 ut_params->op), "failed to process sym crypto op");
11394 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11395 "crypto op processing failed");
11397 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11398 ut_params->op->sym->cipher.data.offset);
11400 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11402 /* Validate obuf */
11403 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11405 tdata->plaintext.data,
11406 tdata->plaintext.len,
11407 "Plaintext data not as expected");
11409 TEST_ASSERT_EQUAL(ut_params->op->status,
11410 RTE_CRYPTO_OP_STATUS_SUCCESS,
11411 "Authentication failed");
11416 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
11418 return test_authenticated_decryption_oop(&gcm_test_case_5);
11422 test_authenticated_encryption_sessionless(
11423 const struct aead_test_data *tdata)
11425 struct crypto_testsuite_params *ts_params = &testsuite_params;
11426 struct crypto_unittest_params *ut_params = &unittest_params;
11429 uint8_t *ciphertext, *auth_tag;
11430 uint16_t plaintext_pad_len;
11431 uint8_t key[tdata->key.len + 1];
11432 struct rte_cryptodev_info dev_info;
11434 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11435 uint64_t feat_flags = dev_info.feature_flags;
11437 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11438 printf("Device doesn't support Sessionless ops.\n");
11439 return TEST_SKIPPED;
11442 /* not supported with CPU crypto */
11443 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11444 return TEST_SKIPPED;
11446 /* Verify the capabilities */
11447 struct rte_cryptodev_sym_capability_idx cap_idx;
11448 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11449 cap_idx.algo.aead = tdata->algo;
11450 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11452 return TEST_SKIPPED;
11454 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11456 /* clear mbuf payload */
11457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11458 rte_pktmbuf_tailroom(ut_params->ibuf));
11460 /* Create AEAD operation */
11461 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11465 /* Create GCM xform */
11466 memcpy(key, tdata->key.data, tdata->key.len);
11467 retval = create_aead_xform(ut_params->op,
11469 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11470 key, tdata->key.len,
11471 tdata->aad.len, tdata->auth_tag.len,
11476 ut_params->op->sym->m_src = ut_params->ibuf;
11478 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11479 RTE_CRYPTO_OP_SESSIONLESS,
11480 "crypto op session type not sessionless");
11482 /* Process crypto operation */
11483 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11484 ut_params->op), "failed to process sym crypto op");
11486 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11488 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11489 "crypto op status not success");
11491 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11493 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11494 ut_params->op->sym->cipher.data.offset);
11495 auth_tag = ciphertext + plaintext_pad_len;
11497 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11498 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11500 /* Validate obuf */
11501 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11503 tdata->ciphertext.data,
11504 tdata->ciphertext.len,
11505 "Ciphertext data not as expected");
11507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11509 tdata->auth_tag.data,
11510 tdata->auth_tag.len,
11511 "Generated auth tag not as expected");
11518 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11520 return test_authenticated_encryption_sessionless(
11525 test_authenticated_decryption_sessionless(
11526 const struct aead_test_data *tdata)
11528 struct crypto_testsuite_params *ts_params = &testsuite_params;
11529 struct crypto_unittest_params *ut_params = &unittest_params;
11532 uint8_t *plaintext;
11533 uint8_t key[tdata->key.len + 1];
11534 struct rte_cryptodev_info dev_info;
11536 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11537 uint64_t feat_flags = dev_info.feature_flags;
11539 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11540 printf("Device doesn't support Sessionless ops.\n");
11541 return TEST_SKIPPED;
11544 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11545 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11546 printf("Device doesn't support RAW data-path APIs.\n");
11547 return TEST_SKIPPED;
11550 /* not supported with CPU crypto */
11551 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11552 return TEST_SKIPPED;
11554 /* Verify the capabilities */
11555 struct rte_cryptodev_sym_capability_idx cap_idx;
11556 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11557 cap_idx.algo.aead = tdata->algo;
11558 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11560 return TEST_SKIPPED;
11562 /* alloc mbuf and set payload */
11563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11565 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11566 rte_pktmbuf_tailroom(ut_params->ibuf));
11568 /* Create AEAD operation */
11569 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11573 /* Create AEAD xform */
11574 memcpy(key, tdata->key.data, tdata->key.len);
11575 retval = create_aead_xform(ut_params->op,
11577 RTE_CRYPTO_AEAD_OP_DECRYPT,
11578 key, tdata->key.len,
11579 tdata->aad.len, tdata->auth_tag.len,
11584 ut_params->op->sym->m_src = ut_params->ibuf;
11586 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11587 RTE_CRYPTO_OP_SESSIONLESS,
11588 "crypto op session type not sessionless");
11590 /* Process crypto operation */
11591 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11592 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11593 ut_params->op, 0, 0, 0, 0);
11595 TEST_ASSERT_NOT_NULL(process_crypto_request(
11596 ts_params->valid_devs[0], ut_params->op),
11597 "failed to process sym crypto op");
11599 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11601 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11602 "crypto op status not success");
11604 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11605 ut_params->op->sym->cipher.data.offset);
11607 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11609 /* Validate obuf */
11610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11612 tdata->plaintext.data,
11613 tdata->plaintext.len,
11614 "Plaintext data not as expected");
11616 TEST_ASSERT_EQUAL(ut_params->op->status,
11617 RTE_CRYPTO_OP_STATUS_SUCCESS,
11618 "Authentication failed");
11623 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11625 return test_authenticated_decryption_sessionless(
11630 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11632 return test_authenticated_encryption(&ccm_test_case_128_1);
11636 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11638 return test_authenticated_encryption(&ccm_test_case_128_2);
11642 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11644 return test_authenticated_encryption(&ccm_test_case_128_3);
11648 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11650 return test_authenticated_decryption(&ccm_test_case_128_1);
11654 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11656 return test_authenticated_decryption(&ccm_test_case_128_2);
11660 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11662 return test_authenticated_decryption(&ccm_test_case_128_3);
11666 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11668 return test_authenticated_encryption(&ccm_test_case_192_1);
11672 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11674 return test_authenticated_encryption(&ccm_test_case_192_2);
11678 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11680 return test_authenticated_encryption(&ccm_test_case_192_3);
11684 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11686 return test_authenticated_decryption(&ccm_test_case_192_1);
11690 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11692 return test_authenticated_decryption(&ccm_test_case_192_2);
11696 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11698 return test_authenticated_decryption(&ccm_test_case_192_3);
11702 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11704 return test_authenticated_encryption(&ccm_test_case_256_1);
11708 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11710 return test_authenticated_encryption(&ccm_test_case_256_2);
11714 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11716 return test_authenticated_encryption(&ccm_test_case_256_3);
11720 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11722 return test_authenticated_decryption(&ccm_test_case_256_1);
11726 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11728 return test_authenticated_decryption(&ccm_test_case_256_2);
11732 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11734 return test_authenticated_decryption(&ccm_test_case_256_3);
11740 struct crypto_testsuite_params *ts_params = &testsuite_params;
11741 struct rte_cryptodev_stats stats;
11743 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11744 return TEST_SKIPPED;
11746 /* Verify the capabilities */
11747 struct rte_cryptodev_sym_capability_idx cap_idx;
11748 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11749 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11750 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11752 return TEST_SKIPPED;
11753 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11754 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11755 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11757 return TEST_SKIPPED;
11759 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11761 return TEST_SKIPPED;
11763 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11764 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11765 &stats) == -ENODEV),
11766 "rte_cryptodev_stats_get invalid dev failed");
11767 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11768 "rte_cryptodev_stats_get invalid Param failed");
11770 /* Test expected values */
11771 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11772 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11774 "rte_cryptodev_stats_get failed");
11775 TEST_ASSERT((stats.enqueued_count == 1),
11776 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11777 TEST_ASSERT((stats.dequeued_count == 1),
11778 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11779 TEST_ASSERT((stats.enqueue_err_count == 0),
11780 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11781 TEST_ASSERT((stats.dequeue_err_count == 0),
11782 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11784 /* invalid device but should ignore and not reset device stats*/
11785 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11786 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11788 "rte_cryptodev_stats_get failed");
11789 TEST_ASSERT((stats.enqueued_count == 1),
11790 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11792 /* check that a valid reset clears stats */
11793 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11794 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11796 "rte_cryptodev_stats_get failed");
11797 TEST_ASSERT((stats.enqueued_count == 0),
11798 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11799 TEST_ASSERT((stats.dequeued_count == 0),
11800 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11802 return TEST_SUCCESS;
11805 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11806 struct crypto_unittest_params *ut_params,
11807 enum rte_crypto_auth_operation op,
11808 const struct HMAC_MD5_vector *test_case)
11813 memcpy(key, test_case->key.data, test_case->key.len);
11815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11816 ut_params->auth_xform.next = NULL;
11817 ut_params->auth_xform.auth.op = op;
11819 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11821 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11822 ut_params->auth_xform.auth.key.length = test_case->key.len;
11823 ut_params->auth_xform.auth.key.data = key;
11825 ut_params->sess = rte_cryptodev_sym_session_create(
11826 ts_params->session_mpool);
11827 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11828 if (ut_params->sess == NULL)
11829 return TEST_FAILED;
11831 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11832 ut_params->sess, &ut_params->auth_xform,
11833 ts_params->session_priv_mpool);
11834 if (status == -ENOTSUP)
11835 return TEST_SKIPPED;
11837 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11839 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11840 rte_pktmbuf_tailroom(ut_params->ibuf));
11845 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11846 const struct HMAC_MD5_vector *test_case,
11847 uint8_t **plaintext)
11849 uint16_t plaintext_pad_len;
11851 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11853 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11856 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11857 plaintext_pad_len);
11858 memcpy(*plaintext, test_case->plaintext.data,
11859 test_case->plaintext.len);
11861 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11862 ut_params->ibuf, MD5_DIGEST_LEN);
11863 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11864 "no room to append digest");
11865 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11866 ut_params->ibuf, plaintext_pad_len);
11868 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11869 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11870 test_case->auth_tag.len);
11873 sym_op->auth.data.offset = 0;
11874 sym_op->auth.data.length = test_case->plaintext.len;
11876 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11877 ut_params->op->sym->m_src = ut_params->ibuf;
11883 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11885 uint16_t plaintext_pad_len;
11886 uint8_t *plaintext, *auth_tag;
11888 struct crypto_testsuite_params *ts_params = &testsuite_params;
11889 struct crypto_unittest_params *ut_params = &unittest_params;
11890 struct rte_cryptodev_info dev_info;
11892 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11893 uint64_t feat_flags = dev_info.feature_flags;
11895 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11896 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11897 printf("Device doesn't support RAW data-path APIs.\n");
11898 return TEST_SKIPPED;
11901 /* Verify the capabilities */
11902 struct rte_cryptodev_sym_capability_idx cap_idx;
11903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11904 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11907 return TEST_SKIPPED;
11909 if (MD5_HMAC_create_session(ts_params, ut_params,
11910 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11911 return TEST_FAILED;
11913 /* Generate Crypto op data structure */
11914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11916 TEST_ASSERT_NOT_NULL(ut_params->op,
11917 "Failed to allocate symmetric crypto operation struct");
11919 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11922 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11923 return TEST_FAILED;
11925 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11926 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11928 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11929 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11930 ut_params->op, 0, 1, 0, 0);
11932 TEST_ASSERT_NOT_NULL(
11933 process_crypto_request(ts_params->valid_devs[0],
11935 "failed to process sym crypto op");
11937 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11938 "crypto op processing failed");
11940 if (ut_params->op->sym->m_dst) {
11941 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11942 uint8_t *, plaintext_pad_len);
11944 auth_tag = plaintext + plaintext_pad_len;
11947 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11949 test_case->auth_tag.data,
11950 test_case->auth_tag.len,
11951 "HMAC_MD5 generated tag not as expected");
11953 return TEST_SUCCESS;
11957 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11959 uint8_t *plaintext;
11961 struct crypto_testsuite_params *ts_params = &testsuite_params;
11962 struct crypto_unittest_params *ut_params = &unittest_params;
11963 struct rte_cryptodev_info dev_info;
11965 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11966 uint64_t feat_flags = dev_info.feature_flags;
11968 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11969 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11970 printf("Device doesn't support RAW data-path APIs.\n");
11971 return TEST_SKIPPED;
11974 /* Verify the capabilities */
11975 struct rte_cryptodev_sym_capability_idx cap_idx;
11976 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11977 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11978 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11980 return TEST_SKIPPED;
11982 if (MD5_HMAC_create_session(ts_params, ut_params,
11983 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11984 return TEST_FAILED;
11987 /* Generate Crypto op data structure */
11988 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11989 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11990 TEST_ASSERT_NOT_NULL(ut_params->op,
11991 "Failed to allocate symmetric crypto operation struct");
11993 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11994 return TEST_FAILED;
11996 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11997 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11999 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12000 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12001 ut_params->op, 0, 1, 0, 0);
12003 TEST_ASSERT_NOT_NULL(
12004 process_crypto_request(ts_params->valid_devs[0],
12006 "failed to process sym crypto op");
12008 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12009 "HMAC_MD5 crypto op processing failed");
12011 return TEST_SUCCESS;
12015 test_MD5_HMAC_generate_case_1(void)
12017 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
12021 test_MD5_HMAC_verify_case_1(void)
12023 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
12027 test_MD5_HMAC_generate_case_2(void)
12029 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
12033 test_MD5_HMAC_verify_case_2(void)
12035 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
12039 test_multi_session(void)
12041 struct crypto_testsuite_params *ts_params = &testsuite_params;
12042 struct crypto_unittest_params *ut_params = &unittest_params;
12044 struct rte_cryptodev_info dev_info;
12045 struct rte_cryptodev_sym_session **sessions;
12050 /* Verify the capabilities */
12051 struct rte_cryptodev_sym_capability_idx cap_idx;
12052 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12053 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12054 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12056 return TEST_SKIPPED;
12057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12058 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12061 return TEST_SKIPPED;
12063 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
12064 aes_cbc_key, hmac_sha512_key);
12067 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12069 sessions = rte_malloc(NULL,
12070 sizeof(struct rte_cryptodev_sym_session *) *
12071 (MAX_NB_SESSIONS + 1), 0);
12073 /* Create multiple crypto sessions*/
12074 for (i = 0; i < MAX_NB_SESSIONS; i++) {
12076 sessions[i] = rte_cryptodev_sym_session_create(
12077 ts_params->session_mpool);
12078 TEST_ASSERT_NOT_NULL(sessions[i],
12079 "Session creation failed at session number %u",
12082 status = rte_cryptodev_sym_session_init(
12083 ts_params->valid_devs[0],
12084 sessions[i], &ut_params->auth_xform,
12085 ts_params->session_priv_mpool);
12086 if (status == -ENOTSUP)
12087 return TEST_SKIPPED;
12089 /* Attempt to send a request on each session */
12090 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
12094 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
12095 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
12097 "Failed to perform decrypt on request number %u.", i);
12098 /* free crypto operation structure */
12100 rte_crypto_op_free(ut_params->op);
12103 * free mbuf - both obuf and ibuf are usually the same,
12104 * so check if they point at the same address is necessary,
12105 * to avoid freeing the mbuf twice.
12107 if (ut_params->obuf) {
12108 rte_pktmbuf_free(ut_params->obuf);
12109 if (ut_params->ibuf == ut_params->obuf)
12110 ut_params->ibuf = 0;
12111 ut_params->obuf = 0;
12113 if (ut_params->ibuf) {
12114 rte_pktmbuf_free(ut_params->ibuf);
12115 ut_params->ibuf = 0;
12119 sessions[i] = NULL;
12120 /* Next session create should fail */
12121 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12122 sessions[i], &ut_params->auth_xform,
12123 ts_params->session_priv_mpool);
12124 TEST_ASSERT_NULL(sessions[i],
12125 "Session creation succeeded unexpectedly!");
12127 for (i = 0; i < MAX_NB_SESSIONS; i++) {
12128 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
12130 rte_cryptodev_sym_session_free(sessions[i]);
12133 rte_free(sessions);
12135 return TEST_SUCCESS;
12138 struct multi_session_params {
12139 struct crypto_unittest_params ut_params;
12140 uint8_t *cipher_key;
12142 const uint8_t *cipher;
12143 const uint8_t *digest;
12147 #define MB_SESSION_NUMBER 3
12150 test_multi_session_random_usage(void)
12152 struct crypto_testsuite_params *ts_params = &testsuite_params;
12153 struct rte_cryptodev_info dev_info;
12154 struct rte_cryptodev_sym_session **sessions;
12156 struct multi_session_params ut_paramz[] = {
12159 .cipher_key = ms_aes_cbc_key0,
12160 .hmac_key = ms_hmac_key0,
12161 .cipher = ms_aes_cbc_cipher0,
12162 .digest = ms_hmac_digest0,
12163 .iv = ms_aes_cbc_iv0
12166 .cipher_key = ms_aes_cbc_key1,
12167 .hmac_key = ms_hmac_key1,
12168 .cipher = ms_aes_cbc_cipher1,
12169 .digest = ms_hmac_digest1,
12170 .iv = ms_aes_cbc_iv1
12173 .cipher_key = ms_aes_cbc_key2,
12174 .hmac_key = ms_hmac_key2,
12175 .cipher = ms_aes_cbc_cipher2,
12176 .digest = ms_hmac_digest2,
12177 .iv = ms_aes_cbc_iv2
12183 /* Verify the capabilities */
12184 struct rte_cryptodev_sym_capability_idx cap_idx;
12185 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12186 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12187 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12189 return TEST_SKIPPED;
12190 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12191 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12192 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12194 return TEST_SKIPPED;
12196 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12198 sessions = rte_malloc(NULL,
12199 (sizeof(struct rte_cryptodev_sym_session *)
12200 * MAX_NB_SESSIONS) + 1, 0);
12202 for (i = 0; i < MB_SESSION_NUMBER; i++) {
12203 sessions[i] = rte_cryptodev_sym_session_create(
12204 ts_params->session_mpool);
12205 TEST_ASSERT_NOT_NULL(sessions[i],
12206 "Session creation failed at session number %u",
12209 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
12210 sizeof(struct crypto_unittest_params));
12212 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
12213 &ut_paramz[i].ut_params,
12214 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
12216 /* Create multiple crypto sessions*/
12217 status = rte_cryptodev_sym_session_init(
12218 ts_params->valid_devs[0],
12220 &ut_paramz[i].ut_params.auth_xform,
12221 ts_params->session_priv_mpool);
12223 if (status == -ENOTSUP)
12224 return TEST_SKIPPED;
12226 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
12230 for (i = 0; i < 40000; i++) {
12232 j = rand() % MB_SESSION_NUMBER;
12234 TEST_ASSERT_SUCCESS(
12235 test_AES_CBC_HMAC_SHA512_decrypt_perform(
12237 &ut_paramz[j].ut_params,
12238 ts_params, ut_paramz[j].cipher,
12239 ut_paramz[j].digest,
12241 "Failed to perform decrypt on request number %u.", i);
12243 if (ut_paramz[j].ut_params.op)
12244 rte_crypto_op_free(ut_paramz[j].ut_params.op);
12247 * free mbuf - both obuf and ibuf are usually the same,
12248 * so check if they point at the same address is necessary,
12249 * to avoid freeing the mbuf twice.
12251 if (ut_paramz[j].ut_params.obuf) {
12252 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
12253 if (ut_paramz[j].ut_params.ibuf
12254 == ut_paramz[j].ut_params.obuf)
12255 ut_paramz[j].ut_params.ibuf = 0;
12256 ut_paramz[j].ut_params.obuf = 0;
12258 if (ut_paramz[j].ut_params.ibuf) {
12259 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
12260 ut_paramz[j].ut_params.ibuf = 0;
12264 for (i = 0; i < MB_SESSION_NUMBER; i++) {
12265 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
12267 rte_cryptodev_sym_session_free(sessions[i]);
12270 rte_free(sessions);
12272 return TEST_SUCCESS;
12275 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
12276 0xab, 0xab, 0xab, 0xab,
12277 0xab, 0xab, 0xab, 0xab,
12278 0xab, 0xab, 0xab, 0xab};
12281 test_null_invalid_operation(void)
12283 struct crypto_testsuite_params *ts_params = &testsuite_params;
12284 struct crypto_unittest_params *ut_params = &unittest_params;
12287 /* This test is for NULL PMD only */
12288 if (gbl_driver_id != rte_cryptodev_driver_id_get(
12289 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12290 return TEST_SKIPPED;
12292 /* Setup Cipher Parameters */
12293 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12294 ut_params->cipher_xform.next = NULL;
12296 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
12297 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12299 ut_params->sess = rte_cryptodev_sym_session_create(
12300 ts_params->session_mpool);
12302 /* Create Crypto session*/
12303 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12304 ut_params->sess, &ut_params->cipher_xform,
12305 ts_params->session_priv_mpool);
12306 TEST_ASSERT(ret < 0,
12307 "Session creation succeeded unexpectedly");
12310 /* Setup HMAC Parameters */
12311 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12312 ut_params->auth_xform.next = NULL;
12314 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
12315 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12317 ut_params->sess = rte_cryptodev_sym_session_create(
12318 ts_params->session_mpool);
12320 /* Create Crypto session*/
12321 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12322 ut_params->sess, &ut_params->auth_xform,
12323 ts_params->session_priv_mpool);
12324 TEST_ASSERT(ret < 0,
12325 "Session creation succeeded unexpectedly");
12327 return TEST_SUCCESS;
12331 #define NULL_BURST_LENGTH (32)
12334 test_null_burst_operation(void)
12336 struct crypto_testsuite_params *ts_params = &testsuite_params;
12337 struct crypto_unittest_params *ut_params = &unittest_params;
12340 unsigned i, burst_len = NULL_BURST_LENGTH;
12342 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
12343 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
12345 /* This test is for NULL PMD only */
12346 if (gbl_driver_id != rte_cryptodev_driver_id_get(
12347 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12348 return TEST_SKIPPED;
12350 /* Setup Cipher Parameters */
12351 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12352 ut_params->cipher_xform.next = &ut_params->auth_xform;
12354 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
12355 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12357 /* Setup HMAC Parameters */
12358 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12359 ut_params->auth_xform.next = NULL;
12361 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
12362 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12364 ut_params->sess = rte_cryptodev_sym_session_create(
12365 ts_params->session_mpool);
12366 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12368 /* Create Crypto session*/
12369 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12370 ut_params->sess, &ut_params->cipher_xform,
12371 ts_params->session_priv_mpool);
12373 if (status == -ENOTSUP)
12374 return TEST_SKIPPED;
12376 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
12378 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
12379 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
12380 burst_len, "failed to generate burst of crypto ops");
12382 /* Generate an operation for each mbuf in burst */
12383 for (i = 0; i < burst_len; i++) {
12384 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12386 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
12388 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
12392 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
12394 burst[i]->sym->m_src = m;
12397 /* Process crypto operation */
12398 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
12399 0, burst, burst_len),
12401 "Error enqueuing burst");
12403 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
12404 0, burst_dequeued, burst_len),
12406 "Error dequeuing burst");
12409 for (i = 0; i < burst_len; i++) {
12411 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
12412 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
12414 "data not as expected");
12416 rte_pktmbuf_free(burst[i]->sym->m_src);
12417 rte_crypto_op_free(burst[i]);
12420 return TEST_SUCCESS;
12424 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12425 uint16_t nb_ops, void *user_param)
12427 RTE_SET_USED(dev_id);
12428 RTE_SET_USED(qp_id);
12430 RTE_SET_USED(user_param);
12432 printf("crypto enqueue callback called\n");
12437 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12438 uint16_t nb_ops, void *user_param)
12440 RTE_SET_USED(dev_id);
12441 RTE_SET_USED(qp_id);
12443 RTE_SET_USED(user_param);
12445 printf("crypto dequeue callback called\n");
12450 * Thread using enqueue/dequeue callback with RCU.
12453 test_enqdeq_callback_thread(void *arg)
12456 /* DP thread calls rte_cryptodev_enqueue_burst()/
12457 * rte_cryptodev_dequeue_burst() and invokes callback.
12459 test_null_burst_operation();
12464 test_enq_callback_setup(void)
12466 struct crypto_testsuite_params *ts_params = &testsuite_params;
12467 struct rte_cryptodev_info dev_info;
12468 struct rte_cryptodev_qp_conf qp_conf = {
12469 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12472 struct rte_cryptodev_cb *cb;
12473 uint16_t qp_id = 0;
12475 /* Stop the device in case it's started so it can be configured */
12476 rte_cryptodev_stop(ts_params->valid_devs[0]);
12478 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12480 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12482 "Failed to configure cryptodev %u",
12483 ts_params->valid_devs[0]);
12485 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12486 qp_conf.mp_session = ts_params->session_mpool;
12487 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12489 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12490 ts_params->valid_devs[0], qp_id, &qp_conf,
12491 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12493 "rte_cryptodev_queue_pair_setup: num_inflights "
12494 "%u on qp %u on cryptodev %u",
12495 qp_conf.nb_descriptors, qp_id,
12496 ts_params->valid_devs[0]);
12498 /* Test with invalid crypto device */
12499 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12500 qp_id, test_enq_callback, NULL);
12501 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12502 "cryptodev %u did not fail",
12503 qp_id, RTE_CRYPTO_MAX_DEVS);
12505 /* Test with invalid queue pair */
12506 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12507 dev_info.max_nb_queue_pairs + 1,
12508 test_enq_callback, NULL);
12509 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12510 "cryptodev %u did not fail",
12511 dev_info.max_nb_queue_pairs + 1,
12512 ts_params->valid_devs[0]);
12514 /* Test with NULL callback */
12515 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12516 qp_id, NULL, NULL);
12517 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12518 "cryptodev %u did not fail",
12519 qp_id, ts_params->valid_devs[0]);
12521 /* Test with valid configuration */
12522 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12523 qp_id, test_enq_callback, NULL);
12524 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12525 "qp %u on cryptodev %u",
12526 qp_id, ts_params->valid_devs[0]);
12528 rte_cryptodev_start(ts_params->valid_devs[0]);
12530 /* Launch a thread */
12531 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12532 rte_get_next_lcore(-1, 1, 0));
12534 /* Wait until reader exited. */
12535 rte_eal_mp_wait_lcore();
12537 /* Test with invalid crypto device */
12538 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12539 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12540 "Expected call to fail as crypto device is invalid");
12542 /* Test with invalid queue pair */
12543 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12544 ts_params->valid_devs[0],
12545 dev_info.max_nb_queue_pairs + 1, cb),
12546 "Expected call to fail as queue pair is invalid");
12548 /* Test with NULL callback */
12549 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12550 ts_params->valid_devs[0], qp_id, NULL),
12551 "Expected call to fail as callback is NULL");
12553 /* Test with valid configuration */
12554 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12555 ts_params->valid_devs[0], qp_id, cb),
12556 "Failed test to remove callback on "
12557 "qp %u on cryptodev %u",
12558 qp_id, ts_params->valid_devs[0]);
12560 return TEST_SUCCESS;
12564 test_deq_callback_setup(void)
12566 struct crypto_testsuite_params *ts_params = &testsuite_params;
12567 struct rte_cryptodev_info dev_info;
12568 struct rte_cryptodev_qp_conf qp_conf = {
12569 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12572 struct rte_cryptodev_cb *cb;
12573 uint16_t qp_id = 0;
12575 /* Stop the device in case it's started so it can be configured */
12576 rte_cryptodev_stop(ts_params->valid_devs[0]);
12578 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12580 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12582 "Failed to configure cryptodev %u",
12583 ts_params->valid_devs[0]);
12585 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12586 qp_conf.mp_session = ts_params->session_mpool;
12587 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12589 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12590 ts_params->valid_devs[0], qp_id, &qp_conf,
12591 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12593 "rte_cryptodev_queue_pair_setup: num_inflights "
12594 "%u on qp %u on cryptodev %u",
12595 qp_conf.nb_descriptors, qp_id,
12596 ts_params->valid_devs[0]);
12598 /* Test with invalid crypto device */
12599 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12600 qp_id, test_deq_callback, NULL);
12601 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12602 "cryptodev %u did not fail",
12603 qp_id, RTE_CRYPTO_MAX_DEVS);
12605 /* Test with invalid queue pair */
12606 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12607 dev_info.max_nb_queue_pairs + 1,
12608 test_deq_callback, NULL);
12609 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12610 "cryptodev %u did not fail",
12611 dev_info.max_nb_queue_pairs + 1,
12612 ts_params->valid_devs[0]);
12614 /* Test with NULL callback */
12615 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12616 qp_id, NULL, NULL);
12617 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12618 "cryptodev %u did not fail",
12619 qp_id, ts_params->valid_devs[0]);
12621 /* Test with valid configuration */
12622 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12623 qp_id, test_deq_callback, NULL);
12624 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12625 "qp %u on cryptodev %u",
12626 qp_id, ts_params->valid_devs[0]);
12628 rte_cryptodev_start(ts_params->valid_devs[0]);
12630 /* Launch a thread */
12631 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12632 rte_get_next_lcore(-1, 1, 0));
12634 /* Wait until reader exited. */
12635 rte_eal_mp_wait_lcore();
12637 /* Test with invalid crypto device */
12638 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12639 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12640 "Expected call to fail as crypto device is invalid");
12642 /* Test with invalid queue pair */
12643 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12644 ts_params->valid_devs[0],
12645 dev_info.max_nb_queue_pairs + 1, cb),
12646 "Expected call to fail as queue pair is invalid");
12648 /* Test with NULL callback */
12649 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12650 ts_params->valid_devs[0], qp_id, NULL),
12651 "Expected call to fail as callback is NULL");
12653 /* Test with valid configuration */
12654 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12655 ts_params->valid_devs[0], qp_id, cb),
12656 "Failed test to remove callback on "
12657 "qp %u on cryptodev %u",
12658 qp_id, ts_params->valid_devs[0]);
12660 return TEST_SUCCESS;
12664 generate_gmac_large_plaintext(uint8_t *data)
12668 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12669 memcpy(&data[i], &data[0], 32);
12673 create_gmac_operation(enum rte_crypto_auth_operation op,
12674 const struct gmac_test_data *tdata)
12676 struct crypto_testsuite_params *ts_params = &testsuite_params;
12677 struct crypto_unittest_params *ut_params = &unittest_params;
12678 struct rte_crypto_sym_op *sym_op;
12680 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12682 /* Generate Crypto op data structure */
12683 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12684 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12685 TEST_ASSERT_NOT_NULL(ut_params->op,
12686 "Failed to allocate symmetric crypto operation struct");
12688 sym_op = ut_params->op->sym;
12690 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12691 ut_params->ibuf, tdata->gmac_tag.len);
12692 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12693 "no room to append digest");
12695 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12696 ut_params->ibuf, plaintext_pad_len);
12698 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12699 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12700 tdata->gmac_tag.len);
12701 debug_hexdump(stdout, "digest:",
12702 sym_op->auth.digest.data,
12703 tdata->gmac_tag.len);
12706 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12707 uint8_t *, IV_OFFSET);
12709 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12711 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12713 sym_op->cipher.data.length = 0;
12714 sym_op->cipher.data.offset = 0;
12716 sym_op->auth.data.offset = 0;
12717 sym_op->auth.data.length = tdata->plaintext.len;
12723 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12724 const struct gmac_test_data *tdata,
12725 void *digest_mem, uint64_t digest_phys)
12727 struct crypto_testsuite_params *ts_params = &testsuite_params;
12728 struct crypto_unittest_params *ut_params = &unittest_params;
12729 struct rte_crypto_sym_op *sym_op;
12731 /* Generate Crypto op data structure */
12732 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12733 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12734 TEST_ASSERT_NOT_NULL(ut_params->op,
12735 "Failed to allocate symmetric crypto operation struct");
12737 sym_op = ut_params->op->sym;
12739 sym_op->auth.digest.data = digest_mem;
12740 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12741 "no room to append digest");
12743 sym_op->auth.digest.phys_addr = digest_phys;
12745 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12746 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12747 tdata->gmac_tag.len);
12748 debug_hexdump(stdout, "digest:",
12749 sym_op->auth.digest.data,
12750 tdata->gmac_tag.len);
12753 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12754 uint8_t *, IV_OFFSET);
12756 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12758 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12760 sym_op->cipher.data.length = 0;
12761 sym_op->cipher.data.offset = 0;
12763 sym_op->auth.data.offset = 0;
12764 sym_op->auth.data.length = tdata->plaintext.len;
12769 static int create_gmac_session(uint8_t dev_id,
12770 const struct gmac_test_data *tdata,
12771 enum rte_crypto_auth_operation auth_op)
12773 uint8_t auth_key[tdata->key.len];
12776 struct crypto_testsuite_params *ts_params = &testsuite_params;
12777 struct crypto_unittest_params *ut_params = &unittest_params;
12779 memcpy(auth_key, tdata->key.data, tdata->key.len);
12781 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12782 ut_params->auth_xform.next = NULL;
12784 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12785 ut_params->auth_xform.auth.op = auth_op;
12786 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12787 ut_params->auth_xform.auth.key.length = tdata->key.len;
12788 ut_params->auth_xform.auth.key.data = auth_key;
12789 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12790 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12793 ut_params->sess = rte_cryptodev_sym_session_create(
12794 ts_params->session_mpool);
12795 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12797 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12798 &ut_params->auth_xform,
12799 ts_params->session_priv_mpool);
12805 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12807 struct crypto_testsuite_params *ts_params = &testsuite_params;
12808 struct crypto_unittest_params *ut_params = &unittest_params;
12809 struct rte_cryptodev_info dev_info;
12811 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12812 uint64_t feat_flags = dev_info.feature_flags;
12814 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12815 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12816 printf("Device doesn't support RAW data-path APIs.\n");
12817 return TEST_SKIPPED;
12822 uint8_t *auth_tag, *plaintext;
12823 uint16_t plaintext_pad_len;
12825 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12826 "No GMAC length in the source data");
12828 /* Verify the capabilities */
12829 struct rte_cryptodev_sym_capability_idx cap_idx;
12830 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12831 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12832 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12834 return TEST_SKIPPED;
12836 retval = create_gmac_session(ts_params->valid_devs[0],
12837 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12839 if (retval == -ENOTSUP)
12840 return TEST_SKIPPED;
12844 if (tdata->plaintext.len > MBUF_SIZE)
12845 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12847 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12848 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12849 "Failed to allocate input buffer in mempool");
12851 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12852 rte_pktmbuf_tailroom(ut_params->ibuf));
12854 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12856 * Runtime generate the large plain text instead of use hard code
12857 * plain text vector. It is done to avoid create huge source file
12858 * with the test vector.
12860 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12861 generate_gmac_large_plaintext(tdata->plaintext.data);
12863 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12864 plaintext_pad_len);
12865 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12867 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12868 debug_hexdump(stdout, "plaintext:", plaintext,
12869 tdata->plaintext.len);
12871 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12879 ut_params->op->sym->m_src = ut_params->ibuf;
12881 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12882 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12884 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12885 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12886 ut_params->op, 0, 1, 0, 0);
12888 TEST_ASSERT_NOT_NULL(
12889 process_crypto_request(ts_params->valid_devs[0],
12890 ut_params->op), "failed to process sym crypto op");
12892 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12893 "crypto op processing failed");
12895 if (ut_params->op->sym->m_dst) {
12896 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12897 uint8_t *, plaintext_pad_len);
12899 auth_tag = plaintext + plaintext_pad_len;
12902 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12906 tdata->gmac_tag.data,
12907 tdata->gmac_tag.len,
12908 "GMAC Generated auth tag not as expected");
12914 test_AES_GMAC_authentication_test_case_1(void)
12916 return test_AES_GMAC_authentication(&gmac_test_case_1);
12920 test_AES_GMAC_authentication_test_case_2(void)
12922 return test_AES_GMAC_authentication(&gmac_test_case_2);
12926 test_AES_GMAC_authentication_test_case_3(void)
12928 return test_AES_GMAC_authentication(&gmac_test_case_3);
12932 test_AES_GMAC_authentication_test_case_4(void)
12934 return test_AES_GMAC_authentication(&gmac_test_case_4);
12938 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12940 struct crypto_testsuite_params *ts_params = &testsuite_params;
12941 struct crypto_unittest_params *ut_params = &unittest_params;
12943 uint32_t plaintext_pad_len;
12944 uint8_t *plaintext;
12945 struct rte_cryptodev_info dev_info;
12947 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12948 uint64_t feat_flags = dev_info.feature_flags;
12950 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12951 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12952 printf("Device doesn't support RAW data-path APIs.\n");
12953 return TEST_SKIPPED;
12956 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12957 "No GMAC length in the source data");
12959 /* Verify the capabilities */
12960 struct rte_cryptodev_sym_capability_idx cap_idx;
12961 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12962 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12963 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12965 return TEST_SKIPPED;
12967 retval = create_gmac_session(ts_params->valid_devs[0],
12968 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12970 if (retval == -ENOTSUP)
12971 return TEST_SKIPPED;
12975 if (tdata->plaintext.len > MBUF_SIZE)
12976 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12978 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12979 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12980 "Failed to allocate input buffer in mempool");
12982 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12983 rte_pktmbuf_tailroom(ut_params->ibuf));
12985 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12988 * Runtime generate the large plain text instead of use hard code
12989 * plain text vector. It is done to avoid create huge source file
12990 * with the test vector.
12992 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12993 generate_gmac_large_plaintext(tdata->plaintext.data);
12995 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12996 plaintext_pad_len);
12997 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12999 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13000 debug_hexdump(stdout, "plaintext:", plaintext,
13001 tdata->plaintext.len);
13003 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
13009 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13011 ut_params->op->sym->m_src = ut_params->ibuf;
13013 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13014 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13016 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13017 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13018 ut_params->op, 0, 1, 0, 0);
13020 TEST_ASSERT_NOT_NULL(
13021 process_crypto_request(ts_params->valid_devs[0],
13022 ut_params->op), "failed to process sym crypto op");
13024 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13025 "crypto op processing failed");
13032 test_AES_GMAC_authentication_verify_test_case_1(void)
13034 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
13038 test_AES_GMAC_authentication_verify_test_case_2(void)
13040 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
13044 test_AES_GMAC_authentication_verify_test_case_3(void)
13046 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
13050 test_AES_GMAC_authentication_verify_test_case_4(void)
13052 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
13056 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
13059 struct crypto_testsuite_params *ts_params = &testsuite_params;
13060 struct crypto_unittest_params *ut_params = &unittest_params;
13061 struct rte_cryptodev_info dev_info;
13062 uint64_t feature_flags;
13063 unsigned int trn_data = 0;
13064 void *digest_mem = NULL;
13066 unsigned int to_trn = 0;
13067 struct rte_mbuf *buf = NULL;
13068 uint8_t *auth_tag, *plaintext;
13071 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13072 "No GMAC length in the source data");
13074 /* Verify the capabilities */
13075 struct rte_cryptodev_sym_capability_idx cap_idx;
13076 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13077 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13078 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13080 return TEST_SKIPPED;
13082 /* Check for any input SGL support */
13083 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13084 feature_flags = dev_info.feature_flags;
13086 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
13087 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
13088 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
13089 return TEST_SKIPPED;
13091 if (fragsz > tdata->plaintext.len)
13092 fragsz = tdata->plaintext.len;
13094 uint16_t plaintext_len = fragsz;
13096 retval = create_gmac_session(ts_params->valid_devs[0],
13097 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13099 if (retval == -ENOTSUP)
13100 return TEST_SKIPPED;
13104 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13105 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13106 "Failed to allocate input buffer in mempool");
13108 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13109 rte_pktmbuf_tailroom(ut_params->ibuf));
13111 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13113 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13115 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13117 trn_data += plaintext_len;
13119 buf = ut_params->ibuf;
13122 * Loop until no more fragments
13125 while (trn_data < tdata->plaintext.len) {
13127 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13128 (tdata->plaintext.len - trn_data) : fragsz;
13130 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13133 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13134 rte_pktmbuf_tailroom(buf));
13136 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13139 memcpy(plaintext, tdata->plaintext.data + trn_data,
13141 trn_data += to_trn;
13142 if (trn_data == tdata->plaintext.len)
13143 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13144 tdata->gmac_tag.len);
13146 ut_params->ibuf->nb_segs = segs;
13149 * Place digest at the end of the last buffer
13151 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13154 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13155 + tdata->gmac_tag.len);
13156 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13157 tdata->plaintext.len);
13160 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
13161 tdata, digest_mem, digest_phys);
13166 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13168 ut_params->op->sym->m_src = ut_params->ibuf;
13170 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13171 return TEST_SKIPPED;
13173 TEST_ASSERT_NOT_NULL(
13174 process_crypto_request(ts_params->valid_devs[0],
13175 ut_params->op), "failed to process sym crypto op");
13177 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13178 "crypto op processing failed");
13180 auth_tag = digest_mem;
13181 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
13182 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13184 tdata->gmac_tag.data,
13185 tdata->gmac_tag.len,
13186 "GMAC Generated auth tag not as expected");
13191 /* Segment size not multiple of block size (16B) */
13193 test_AES_GMAC_authentication_SGL_40B(void)
13195 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
13199 test_AES_GMAC_authentication_SGL_80B(void)
13201 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
13205 test_AES_GMAC_authentication_SGL_2048B(void)
13207 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
13210 /* Segment size not multiple of block size (16B) */
13212 test_AES_GMAC_authentication_SGL_2047B(void)
13214 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
13217 struct test_crypto_vector {
13218 enum rte_crypto_cipher_algorithm crypto_algo;
13219 unsigned int cipher_offset;
13220 unsigned int cipher_len;
13233 const uint8_t *data;
13238 const uint8_t *data;
13242 enum rte_crypto_auth_algorithm auth_algo;
13243 unsigned int auth_offset;
13251 const uint8_t *data;
13261 static const struct test_crypto_vector
13262 hmac_sha1_test_crypto_vector = {
13263 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13265 .data = plaintext_hash,
13270 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13271 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13272 0xDE, 0xF4, 0xDE, 0xAD
13278 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
13279 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
13280 0x3F, 0x91, 0x64, 0x59
13286 static const struct test_crypto_vector
13287 aes128_gmac_test_vector = {
13288 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
13290 .data = plaintext_hash,
13295 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13296 0x08, 0x09, 0x0A, 0x0B
13302 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13303 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
13309 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
13310 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
13316 static const struct test_crypto_vector
13317 aes128cbc_hmac_sha1_test_vector = {
13318 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13319 .cipher_offset = 0,
13323 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13324 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13330 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13331 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13336 .data = plaintext_hash,
13340 .data = ciphertext512_aes128cbc,
13343 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13347 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13348 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13349 0xDE, 0xF4, 0xDE, 0xAD
13355 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
13356 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13357 0x18, 0x8C, 0x1D, 0x32
13363 static const struct test_crypto_vector
13364 aes128cbc_hmac_sha1_aad_test_vector = {
13365 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13366 .cipher_offset = 8,
13370 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13371 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13377 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13378 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13383 .data = plaintext_hash,
13387 .data = ciphertext512_aes128cbc_aad,
13390 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13394 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13395 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13396 0xDE, 0xF4, 0xDE, 0xAD
13402 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
13403 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
13404 0x62, 0x0F, 0xFB, 0x10
13411 data_corruption(uint8_t *data)
13417 tag_corruption(uint8_t *data, unsigned int tag_offset)
13419 data[tag_offset] += 1;
13423 create_auth_session(struct crypto_unittest_params *ut_params,
13425 const struct test_crypto_vector *reference,
13426 enum rte_crypto_auth_operation auth_op)
13428 struct crypto_testsuite_params *ts_params = &testsuite_params;
13429 uint8_t auth_key[reference->auth_key.len + 1];
13432 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13434 /* Setup Authentication Parameters */
13435 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13436 ut_params->auth_xform.auth.op = auth_op;
13437 ut_params->auth_xform.next = NULL;
13438 ut_params->auth_xform.auth.algo = reference->auth_algo;
13439 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13440 ut_params->auth_xform.auth.key.data = auth_key;
13441 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13443 /* Create Crypto session*/
13444 ut_params->sess = rte_cryptodev_sym_session_create(
13445 ts_params->session_mpool);
13446 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13448 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13449 &ut_params->auth_xform,
13450 ts_params->session_priv_mpool);
13456 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13458 const struct test_crypto_vector *reference,
13459 enum rte_crypto_auth_operation auth_op,
13460 enum rte_crypto_cipher_operation cipher_op)
13462 struct crypto_testsuite_params *ts_params = &testsuite_params;
13463 uint8_t cipher_key[reference->cipher_key.len + 1];
13464 uint8_t auth_key[reference->auth_key.len + 1];
13467 memcpy(cipher_key, reference->cipher_key.data,
13468 reference->cipher_key.len);
13469 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13471 /* Setup Authentication Parameters */
13472 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13473 ut_params->auth_xform.auth.op = auth_op;
13474 ut_params->auth_xform.auth.algo = reference->auth_algo;
13475 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13476 ut_params->auth_xform.auth.key.data = auth_key;
13477 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13479 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13480 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13481 ut_params->auth_xform.auth.iv.length = reference->iv.len;
13483 ut_params->auth_xform.next = &ut_params->cipher_xform;
13485 /* Setup Cipher Parameters */
13486 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13487 ut_params->cipher_xform.next = NULL;
13488 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13489 ut_params->cipher_xform.cipher.op = cipher_op;
13490 ut_params->cipher_xform.cipher.key.data = cipher_key;
13491 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13492 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13493 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13496 /* Create Crypto session*/
13497 ut_params->sess = rte_cryptodev_sym_session_create(
13498 ts_params->session_mpool);
13499 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13501 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13502 &ut_params->auth_xform,
13503 ts_params->session_priv_mpool);
13509 create_auth_operation(struct crypto_testsuite_params *ts_params,
13510 struct crypto_unittest_params *ut_params,
13511 const struct test_crypto_vector *reference,
13512 unsigned int auth_generate)
13514 /* Generate Crypto op data structure */
13515 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13516 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13517 TEST_ASSERT_NOT_NULL(ut_params->op,
13518 "Failed to allocate pktmbuf offload");
13520 /* Set crypto operation data parameters */
13521 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13525 /* set crypto operation source mbuf */
13526 sym_op->m_src = ut_params->ibuf;
13529 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13530 ut_params->ibuf, reference->digest.len);
13532 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13533 "no room to append auth tag");
13535 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13536 ut_params->ibuf, reference->plaintext.len);
13539 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13541 memcpy(sym_op->auth.digest.data,
13542 reference->digest.data,
13543 reference->digest.len);
13545 debug_hexdump(stdout, "digest:",
13546 sym_op->auth.digest.data,
13547 reference->digest.len);
13549 sym_op->auth.data.length = reference->plaintext.len;
13550 sym_op->auth.data.offset = 0;
13556 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13557 struct crypto_unittest_params *ut_params,
13558 const struct test_crypto_vector *reference,
13559 unsigned int auth_generate)
13561 /* Generate Crypto op data structure */
13562 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13563 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13564 TEST_ASSERT_NOT_NULL(ut_params->op,
13565 "Failed to allocate pktmbuf offload");
13567 /* Set crypto operation data parameters */
13568 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13570 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13572 /* set crypto operation source mbuf */
13573 sym_op->m_src = ut_params->ibuf;
13576 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13577 ut_params->ibuf, reference->digest.len);
13579 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13580 "no room to append auth tag");
13582 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13583 ut_params->ibuf, reference->ciphertext.len);
13586 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13588 memcpy(sym_op->auth.digest.data,
13589 reference->digest.data,
13590 reference->digest.len);
13592 debug_hexdump(stdout, "digest:",
13593 sym_op->auth.digest.data,
13594 reference->digest.len);
13596 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13597 reference->iv.data, reference->iv.len);
13599 sym_op->cipher.data.length = 0;
13600 sym_op->cipher.data.offset = 0;
13602 sym_op->auth.data.length = reference->plaintext.len;
13603 sym_op->auth.data.offset = 0;
13609 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13610 struct crypto_unittest_params *ut_params,
13611 const struct test_crypto_vector *reference,
13612 unsigned int auth_generate)
13614 /* Generate Crypto op data structure */
13615 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13616 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13617 TEST_ASSERT_NOT_NULL(ut_params->op,
13618 "Failed to allocate pktmbuf offload");
13620 /* Set crypto operation data parameters */
13621 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13623 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13625 /* set crypto operation source mbuf */
13626 sym_op->m_src = ut_params->ibuf;
13629 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13630 ut_params->ibuf, reference->digest.len);
13632 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13633 "no room to append auth tag");
13635 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13636 ut_params->ibuf, reference->ciphertext.len);
13639 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13641 memcpy(sym_op->auth.digest.data,
13642 reference->digest.data,
13643 reference->digest.len);
13645 debug_hexdump(stdout, "digest:",
13646 sym_op->auth.digest.data,
13647 reference->digest.len);
13649 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13650 reference->iv.data, reference->iv.len);
13652 sym_op->cipher.data.length = reference->cipher_len;
13653 sym_op->cipher.data.offset = reference->cipher_offset;
13655 sym_op->auth.data.length = reference->plaintext.len;
13656 sym_op->auth.data.offset = reference->auth_offset;
13662 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13663 struct crypto_unittest_params *ut_params,
13664 const struct test_crypto_vector *reference)
13666 return create_auth_operation(ts_params, ut_params, reference, 0);
13670 create_auth_verify_GMAC_operation(
13671 struct crypto_testsuite_params *ts_params,
13672 struct crypto_unittest_params *ut_params,
13673 const struct test_crypto_vector *reference)
13675 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13679 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13680 struct crypto_unittest_params *ut_params,
13681 const struct test_crypto_vector *reference)
13683 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13687 test_authentication_verify_fail_when_data_corruption(
13688 struct crypto_testsuite_params *ts_params,
13689 struct crypto_unittest_params *ut_params,
13690 const struct test_crypto_vector *reference,
13691 unsigned int data_corrupted)
13695 uint8_t *plaintext;
13696 struct rte_cryptodev_info dev_info;
13698 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13699 uint64_t feat_flags = dev_info.feature_flags;
13701 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13702 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13703 printf("Device doesn't support RAW data-path APIs.\n");
13704 return TEST_SKIPPED;
13707 /* Verify the capabilities */
13708 struct rte_cryptodev_sym_capability_idx cap_idx;
13709 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13710 cap_idx.algo.auth = reference->auth_algo;
13711 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13713 return TEST_SKIPPED;
13716 /* Create session */
13717 retval = create_auth_session(ut_params,
13718 ts_params->valid_devs[0],
13720 RTE_CRYPTO_AUTH_OP_VERIFY);
13722 if (retval == -ENOTSUP)
13723 return TEST_SKIPPED;
13727 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13728 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13729 "Failed to allocate input buffer in mempool");
13731 /* clear mbuf payload */
13732 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13733 rte_pktmbuf_tailroom(ut_params->ibuf));
13735 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13736 reference->plaintext.len);
13737 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13738 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13740 debug_hexdump(stdout, "plaintext:", plaintext,
13741 reference->plaintext.len);
13743 /* Create operation */
13744 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13749 if (data_corrupted)
13750 data_corruption(plaintext);
13752 tag_corruption(plaintext, reference->plaintext.len);
13754 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13755 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13757 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13758 RTE_CRYPTO_OP_STATUS_SUCCESS,
13759 "authentication not failed");
13760 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13761 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13762 ut_params->op, 0, 1, 0, 0);
13764 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13767 if (ut_params->op == NULL)
13769 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13776 test_authentication_verify_GMAC_fail_when_corruption(
13777 struct crypto_testsuite_params *ts_params,
13778 struct crypto_unittest_params *ut_params,
13779 const struct test_crypto_vector *reference,
13780 unsigned int data_corrupted)
13783 uint8_t *plaintext;
13784 struct rte_cryptodev_info dev_info;
13786 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13787 uint64_t feat_flags = dev_info.feature_flags;
13789 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13790 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13791 printf("Device doesn't support RAW data-path APIs.\n");
13792 return TEST_SKIPPED;
13795 /* Verify the capabilities */
13796 struct rte_cryptodev_sym_capability_idx cap_idx;
13797 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13798 cap_idx.algo.auth = reference->auth_algo;
13799 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13801 return TEST_SKIPPED;
13803 /* Create session */
13804 retval = create_auth_cipher_session(ut_params,
13805 ts_params->valid_devs[0],
13807 RTE_CRYPTO_AUTH_OP_VERIFY,
13808 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13812 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13813 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13814 "Failed to allocate input buffer in mempool");
13816 /* clear mbuf payload */
13817 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13818 rte_pktmbuf_tailroom(ut_params->ibuf));
13820 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13821 reference->plaintext.len);
13822 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13823 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13825 debug_hexdump(stdout, "plaintext:", plaintext,
13826 reference->plaintext.len);
13828 /* Create operation */
13829 retval = create_auth_verify_GMAC_operation(ts_params,
13836 if (data_corrupted)
13837 data_corruption(plaintext);
13839 tag_corruption(plaintext, reference->aad.len);
13841 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13842 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13844 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13845 RTE_CRYPTO_OP_STATUS_SUCCESS,
13846 "authentication not failed");
13847 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13848 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13849 ut_params->op, 0, 1, 0, 0);
13851 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13853 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13860 test_authenticated_decryption_fail_when_corruption(
13861 struct crypto_testsuite_params *ts_params,
13862 struct crypto_unittest_params *ut_params,
13863 const struct test_crypto_vector *reference,
13864 unsigned int data_corrupted)
13868 uint8_t *ciphertext;
13869 struct rte_cryptodev_info dev_info;
13871 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13872 uint64_t feat_flags = dev_info.feature_flags;
13874 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13875 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13876 printf("Device doesn't support RAW data-path APIs.\n");
13877 return TEST_SKIPPED;
13880 /* Verify the capabilities */
13881 struct rte_cryptodev_sym_capability_idx cap_idx;
13882 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13883 cap_idx.algo.auth = reference->auth_algo;
13884 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13886 return TEST_SKIPPED;
13887 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13888 cap_idx.algo.cipher = reference->crypto_algo;
13889 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13891 return TEST_SKIPPED;
13893 /* Create session */
13894 retval = create_auth_cipher_session(ut_params,
13895 ts_params->valid_devs[0],
13897 RTE_CRYPTO_AUTH_OP_VERIFY,
13898 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13900 if (retval == -ENOTSUP)
13901 return TEST_SKIPPED;
13905 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13906 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13907 "Failed to allocate input buffer in mempool");
13909 /* clear mbuf payload */
13910 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13911 rte_pktmbuf_tailroom(ut_params->ibuf));
13913 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13914 reference->ciphertext.len);
13915 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13916 memcpy(ciphertext, reference->ciphertext.data,
13917 reference->ciphertext.len);
13919 /* Create operation */
13920 retval = create_cipher_auth_verify_operation(ts_params,
13927 if (data_corrupted)
13928 data_corruption(ciphertext);
13930 tag_corruption(ciphertext, reference->ciphertext.len);
13932 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13933 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13935 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13936 RTE_CRYPTO_OP_STATUS_SUCCESS,
13937 "authentication not failed");
13938 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13939 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13940 ut_params->op, 1, 1, 0, 0);
13942 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13944 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13951 test_authenticated_encrypt_with_esn(
13952 struct crypto_testsuite_params *ts_params,
13953 struct crypto_unittest_params *ut_params,
13954 const struct test_crypto_vector *reference)
13958 uint8_t *authciphertext, *plaintext, *auth_tag;
13959 uint16_t plaintext_pad_len;
13960 uint8_t cipher_key[reference->cipher_key.len + 1];
13961 uint8_t auth_key[reference->auth_key.len + 1];
13962 struct rte_cryptodev_info dev_info;
13965 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13966 uint64_t feat_flags = dev_info.feature_flags;
13968 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13969 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13970 printf("Device doesn't support RAW data-path APIs.\n");
13971 return TEST_SKIPPED;
13974 /* Verify the capabilities */
13975 struct rte_cryptodev_sym_capability_idx cap_idx;
13976 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13977 cap_idx.algo.auth = reference->auth_algo;
13978 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13980 return TEST_SKIPPED;
13981 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13982 cap_idx.algo.cipher = reference->crypto_algo;
13983 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13985 return TEST_SKIPPED;
13987 /* Create session */
13988 memcpy(cipher_key, reference->cipher_key.data,
13989 reference->cipher_key.len);
13990 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13992 /* Setup Cipher Parameters */
13993 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13994 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13995 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13996 ut_params->cipher_xform.cipher.key.data = cipher_key;
13997 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13998 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13999 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14001 ut_params->cipher_xform.next = &ut_params->auth_xform;
14003 /* Setup Authentication Parameters */
14004 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14005 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14006 ut_params->auth_xform.auth.algo = reference->auth_algo;
14007 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14008 ut_params->auth_xform.auth.key.data = auth_key;
14009 ut_params->auth_xform.auth.digest_length = reference->digest.len;
14010 ut_params->auth_xform.next = NULL;
14012 /* Create Crypto session*/
14013 ut_params->sess = rte_cryptodev_sym_session_create(
14014 ts_params->session_mpool);
14015 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14017 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
14019 &ut_params->cipher_xform,
14020 ts_params->session_priv_mpool);
14022 if (status == -ENOTSUP)
14023 return TEST_SKIPPED;
14025 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
14027 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14028 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14029 "Failed to allocate input buffer in mempool");
14031 /* clear mbuf payload */
14032 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14033 rte_pktmbuf_tailroom(ut_params->ibuf));
14035 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14036 reference->plaintext.len);
14037 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14038 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14040 /* Create operation */
14041 retval = create_cipher_auth_operation(ts_params,
14048 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14049 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14051 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14052 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14053 ut_params->op, 1, 1, 0, 0);
14055 ut_params->op = process_crypto_request(
14056 ts_params->valid_devs[0], ut_params->op);
14058 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
14060 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14061 "crypto op processing failed");
14063 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
14065 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14066 ut_params->op->sym->auth.data.offset);
14067 auth_tag = authciphertext + plaintext_pad_len;
14068 debug_hexdump(stdout, "ciphertext:", authciphertext,
14069 reference->ciphertext.len);
14070 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
14072 /* Validate obuf */
14073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14075 reference->ciphertext.data,
14076 reference->ciphertext.len,
14077 "Ciphertext data not as expected");
14079 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14081 reference->digest.data,
14082 reference->digest.len,
14083 "Generated digest not as expected");
14085 return TEST_SUCCESS;
14090 test_authenticated_decrypt_with_esn(
14091 struct crypto_testsuite_params *ts_params,
14092 struct crypto_unittest_params *ut_params,
14093 const struct test_crypto_vector *reference)
14097 uint8_t *ciphertext;
14098 uint8_t cipher_key[reference->cipher_key.len + 1];
14099 uint8_t auth_key[reference->auth_key.len + 1];
14100 struct rte_cryptodev_info dev_info;
14102 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14103 uint64_t feat_flags = dev_info.feature_flags;
14105 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14106 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14107 printf("Device doesn't support RAW data-path APIs.\n");
14108 return TEST_SKIPPED;
14111 /* Verify the capabilities */
14112 struct rte_cryptodev_sym_capability_idx cap_idx;
14113 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14114 cap_idx.algo.auth = reference->auth_algo;
14115 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14117 return TEST_SKIPPED;
14118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14119 cap_idx.algo.cipher = reference->crypto_algo;
14120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14122 return TEST_SKIPPED;
14124 /* Create session */
14125 memcpy(cipher_key, reference->cipher_key.data,
14126 reference->cipher_key.len);
14127 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14129 /* Setup Authentication Parameters */
14130 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14131 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
14132 ut_params->auth_xform.auth.algo = reference->auth_algo;
14133 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14134 ut_params->auth_xform.auth.key.data = auth_key;
14135 ut_params->auth_xform.auth.digest_length = reference->digest.len;
14136 ut_params->auth_xform.next = &ut_params->cipher_xform;
14138 /* Setup Cipher Parameters */
14139 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14140 ut_params->cipher_xform.next = NULL;
14141 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14142 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
14143 ut_params->cipher_xform.cipher.key.data = cipher_key;
14144 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14145 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14146 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14148 /* Create Crypto session*/
14149 ut_params->sess = rte_cryptodev_sym_session_create(
14150 ts_params->session_mpool);
14151 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14153 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
14155 &ut_params->auth_xform,
14156 ts_params->session_priv_mpool);
14158 if (retval == -ENOTSUP)
14159 return TEST_SKIPPED;
14161 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
14163 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14164 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14165 "Failed to allocate input buffer in mempool");
14167 /* clear mbuf payload */
14168 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14169 rte_pktmbuf_tailroom(ut_params->ibuf));
14171 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14172 reference->ciphertext.len);
14173 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
14174 memcpy(ciphertext, reference->ciphertext.data,
14175 reference->ciphertext.len);
14177 /* Create operation */
14178 retval = create_cipher_auth_verify_operation(ts_params,
14185 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14186 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14188 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14189 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14190 ut_params->op, 1, 1, 0, 0);
14192 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14195 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14196 TEST_ASSERT_EQUAL(ut_params->op->status,
14197 RTE_CRYPTO_OP_STATUS_SUCCESS,
14198 "crypto op processing passed");
14200 ut_params->obuf = ut_params->op->sym->m_src;
14201 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
14207 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
14208 const struct aead_test_data *tdata,
14209 void *digest_mem, uint64_t digest_phys)
14211 struct crypto_testsuite_params *ts_params = &testsuite_params;
14212 struct crypto_unittest_params *ut_params = &unittest_params;
14214 const unsigned int auth_tag_len = tdata->auth_tag.len;
14215 const unsigned int iv_len = tdata->iv.len;
14216 unsigned int aad_len = tdata->aad.len;
14217 unsigned int aad_len_pad = 0;
14219 /* Generate Crypto op data structure */
14220 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14221 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14222 TEST_ASSERT_NOT_NULL(ut_params->op,
14223 "Failed to allocate symmetric crypto operation struct");
14225 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14227 sym_op->aead.digest.data = digest_mem;
14229 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
14230 "no room to append digest");
14232 sym_op->aead.digest.phys_addr = digest_phys;
14234 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
14235 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
14237 debug_hexdump(stdout, "digest:",
14238 sym_op->aead.digest.data,
14242 /* Append aad data */
14243 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
14244 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14245 uint8_t *, IV_OFFSET);
14247 /* Copy IV 1 byte after the IV pointer, according to the API */
14248 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
14250 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
14252 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14253 ut_params->ibuf, aad_len);
14254 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14255 "no room to prepend aad");
14256 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14259 memset(sym_op->aead.aad.data, 0, aad_len);
14260 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
14261 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14263 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14264 debug_hexdump(stdout, "aad:",
14265 sym_op->aead.aad.data, aad_len);
14267 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14268 uint8_t *, IV_OFFSET);
14270 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
14272 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
14274 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14275 ut_params->ibuf, aad_len_pad);
14276 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14277 "no room to prepend aad");
14278 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14281 memset(sym_op->aead.aad.data, 0, aad_len);
14282 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14284 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14285 debug_hexdump(stdout, "aad:",
14286 sym_op->aead.aad.data, aad_len);
14289 sym_op->aead.data.length = tdata->plaintext.len;
14290 sym_op->aead.data.offset = aad_len_pad;
14295 #define SGL_MAX_NO 16
14298 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
14299 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
14301 struct crypto_testsuite_params *ts_params = &testsuite_params;
14302 struct crypto_unittest_params *ut_params = &unittest_params;
14303 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
14306 int to_trn_tbl[SGL_MAX_NO];
14308 unsigned int trn_data = 0;
14309 uint8_t *plaintext, *ciphertext, *auth_tag;
14310 struct rte_cryptodev_info dev_info;
14312 /* Verify the capabilities */
14313 struct rte_cryptodev_sym_capability_idx cap_idx;
14314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14315 cap_idx.algo.aead = tdata->algo;
14316 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14318 return TEST_SKIPPED;
14320 /* OOP not supported with CPU crypto */
14321 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14322 return TEST_SKIPPED;
14324 /* Detailed check for the particular SGL support flag */
14325 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14327 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14328 if (sgl_in && (!(dev_info.feature_flags &
14329 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
14330 return TEST_SKIPPED;
14332 uint64_t feat_flags = dev_info.feature_flags;
14334 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14335 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14336 printf("Device doesn't support RAW data-path APIs.\n");
14337 return TEST_SKIPPED;
14340 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14341 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
14342 tdata->plaintext.len;
14343 /* Raw data path API does not support OOP */
14344 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14345 return TEST_SKIPPED;
14346 if (sgl_in && !sgl_out) {
14347 if (!(dev_info.feature_flags &
14348 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
14349 return TEST_SKIPPED;
14350 } else if (!sgl_in && sgl_out) {
14351 if (!(dev_info.feature_flags &
14352 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
14353 return TEST_SKIPPED;
14354 } else if (sgl_in && sgl_out) {
14355 if (!(dev_info.feature_flags &
14356 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
14357 return TEST_SKIPPED;
14361 if (fragsz > tdata->plaintext.len)
14362 fragsz = tdata->plaintext.len;
14364 uint16_t plaintext_len = fragsz;
14365 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
14367 if (fragsz_oop > tdata->plaintext.len)
14368 frag_size_oop = tdata->plaintext.len;
14371 void *digest_mem = NULL;
14373 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
14375 if (tdata->plaintext.len % fragsz != 0) {
14376 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
14379 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
14384 * For out-op-place we need to alloc another mbuf
14387 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14388 rte_pktmbuf_append(ut_params->obuf,
14389 frag_size_oop + prepend_len);
14390 buf_oop = ut_params->obuf;
14393 /* Create AEAD session */
14394 retval = create_aead_session(ts_params->valid_devs[0],
14396 RTE_CRYPTO_AEAD_OP_ENCRYPT,
14397 tdata->key.data, tdata->key.len,
14398 tdata->aad.len, tdata->auth_tag.len,
14403 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14405 /* clear mbuf payload */
14406 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14407 rte_pktmbuf_tailroom(ut_params->ibuf));
14409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14412 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14414 trn_data += plaintext_len;
14416 buf = ut_params->ibuf;
14419 * Loop until no more fragments
14422 while (trn_data < tdata->plaintext.len) {
14424 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14425 (tdata->plaintext.len - trn_data) : fragsz;
14427 to_trn_tbl[ecx++] = to_trn;
14429 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14432 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14433 rte_pktmbuf_tailroom(buf));
14436 if (oop && !fragsz_oop) {
14437 buf_last_oop = buf_oop->next =
14438 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14439 buf_oop = buf_oop->next;
14440 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14441 0, rte_pktmbuf_tailroom(buf_oop));
14442 rte_pktmbuf_append(buf_oop, to_trn);
14445 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14448 memcpy(plaintext, tdata->plaintext.data + trn_data,
14450 trn_data += to_trn;
14451 if (trn_data == tdata->plaintext.len) {
14454 digest_mem = rte_pktmbuf_append(buf_oop,
14455 tdata->auth_tag.len);
14457 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14458 tdata->auth_tag.len);
14462 uint64_t digest_phys = 0;
14464 ut_params->ibuf->nb_segs = segs;
14467 if (fragsz_oop && oop) {
14471 if (frag_size_oop == tdata->plaintext.len) {
14472 digest_mem = rte_pktmbuf_append(ut_params->obuf,
14473 tdata->auth_tag.len);
14475 digest_phys = rte_pktmbuf_iova_offset(
14477 tdata->plaintext.len + prepend_len);
14480 trn_data = frag_size_oop;
14481 while (trn_data < tdata->plaintext.len) {
14484 (tdata->plaintext.len - trn_data <
14486 (tdata->plaintext.len - trn_data) :
14489 to_trn_tbl[ecx++] = to_trn;
14491 buf_last_oop = buf_oop->next =
14492 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14493 buf_oop = buf_oop->next;
14494 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14495 0, rte_pktmbuf_tailroom(buf_oop));
14496 rte_pktmbuf_append(buf_oop, to_trn);
14498 trn_data += to_trn;
14500 if (trn_data == tdata->plaintext.len) {
14501 digest_mem = rte_pktmbuf_append(buf_oop,
14502 tdata->auth_tag.len);
14506 ut_params->obuf->nb_segs = segs;
14510 * Place digest at the end of the last buffer
14513 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14514 if (oop && buf_last_oop)
14515 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14517 if (!digest_mem && !oop) {
14518 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14519 + tdata->auth_tag.len);
14520 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14521 tdata->plaintext.len);
14524 /* Create AEAD operation */
14525 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14526 tdata, digest_mem, digest_phys);
14531 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14533 ut_params->op->sym->m_src = ut_params->ibuf;
14535 ut_params->op->sym->m_dst = ut_params->obuf;
14537 /* Process crypto operation */
14538 if (oop == IN_PLACE &&
14539 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14540 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14541 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14542 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14543 ut_params->op, 0, 0, 0, 0);
14545 TEST_ASSERT_NOT_NULL(
14546 process_crypto_request(ts_params->valid_devs[0],
14547 ut_params->op), "failed to process sym crypto op");
14549 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14550 "crypto op processing failed");
14553 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14554 uint8_t *, prepend_len);
14556 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14557 uint8_t *, prepend_len);
14561 fragsz = fragsz_oop;
14563 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14565 tdata->ciphertext.data,
14567 "Ciphertext data not as expected");
14569 buf = ut_params->op->sym->m_src->next;
14571 buf = ut_params->op->sym->m_dst->next;
14573 unsigned int off = fragsz;
14577 ciphertext = rte_pktmbuf_mtod(buf,
14580 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14582 tdata->ciphertext.data + off,
14584 "Ciphertext data not as expected");
14586 off += to_trn_tbl[ecx++];
14590 auth_tag = digest_mem;
14591 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14593 tdata->auth_tag.data,
14594 tdata->auth_tag.len,
14595 "Generated auth tag not as expected");
14601 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14603 return test_authenticated_encryption_SGL(
14604 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14608 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14610 return test_authenticated_encryption_SGL(
14611 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14615 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14617 return test_authenticated_encryption_SGL(
14618 &gcm_test_case_8, OUT_OF_PLACE, 400,
14619 gcm_test_case_8.plaintext.len);
14623 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14625 /* This test is not for OPENSSL PMD */
14626 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14627 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14628 return TEST_SKIPPED;
14630 return test_authenticated_encryption_SGL(
14631 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14635 test_authentication_verify_fail_when_data_corrupted(
14636 struct crypto_testsuite_params *ts_params,
14637 struct crypto_unittest_params *ut_params,
14638 const struct test_crypto_vector *reference)
14640 return test_authentication_verify_fail_when_data_corruption(
14641 ts_params, ut_params, reference, 1);
14645 test_authentication_verify_fail_when_tag_corrupted(
14646 struct crypto_testsuite_params *ts_params,
14647 struct crypto_unittest_params *ut_params,
14648 const struct test_crypto_vector *reference)
14650 return test_authentication_verify_fail_when_data_corruption(
14651 ts_params, ut_params, reference, 0);
14655 test_authentication_verify_GMAC_fail_when_data_corrupted(
14656 struct crypto_testsuite_params *ts_params,
14657 struct crypto_unittest_params *ut_params,
14658 const struct test_crypto_vector *reference)
14660 return test_authentication_verify_GMAC_fail_when_corruption(
14661 ts_params, ut_params, reference, 1);
14665 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14666 struct crypto_testsuite_params *ts_params,
14667 struct crypto_unittest_params *ut_params,
14668 const struct test_crypto_vector *reference)
14670 return test_authentication_verify_GMAC_fail_when_corruption(
14671 ts_params, ut_params, reference, 0);
14675 test_authenticated_decryption_fail_when_data_corrupted(
14676 struct crypto_testsuite_params *ts_params,
14677 struct crypto_unittest_params *ut_params,
14678 const struct test_crypto_vector *reference)
14680 return test_authenticated_decryption_fail_when_corruption(
14681 ts_params, ut_params, reference, 1);
14685 test_authenticated_decryption_fail_when_tag_corrupted(
14686 struct crypto_testsuite_params *ts_params,
14687 struct crypto_unittest_params *ut_params,
14688 const struct test_crypto_vector *reference)
14690 return test_authenticated_decryption_fail_when_corruption(
14691 ts_params, ut_params, reference, 0);
14695 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14697 return test_authentication_verify_fail_when_data_corrupted(
14698 &testsuite_params, &unittest_params,
14699 &hmac_sha1_test_crypto_vector);
14703 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14705 return test_authentication_verify_fail_when_tag_corrupted(
14706 &testsuite_params, &unittest_params,
14707 &hmac_sha1_test_crypto_vector);
14711 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14713 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14714 &testsuite_params, &unittest_params,
14715 &aes128_gmac_test_vector);
14719 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14721 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14722 &testsuite_params, &unittest_params,
14723 &aes128_gmac_test_vector);
14727 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14729 return test_authenticated_decryption_fail_when_data_corrupted(
14732 &aes128cbc_hmac_sha1_test_vector);
14736 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14738 return test_authenticated_decryption_fail_when_tag_corrupted(
14741 &aes128cbc_hmac_sha1_test_vector);
14745 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14747 return test_authenticated_encrypt_with_esn(
14750 &aes128cbc_hmac_sha1_aad_test_vector);
14754 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14756 return test_authenticated_decrypt_with_esn(
14759 &aes128cbc_hmac_sha1_aad_test_vector);
14763 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14765 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14769 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14771 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14775 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14777 return test_authenticated_encryption_SGL(
14778 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14779 chacha20_poly1305_case_2.plaintext.len);
14782 #ifdef RTE_CRYPTO_SCHEDULER
14784 /* global AESNI worker IDs for the scheduler test */
14785 uint8_t aesni_ids[2];
14788 scheduler_testsuite_setup(void)
14791 int32_t nb_devs, ret;
14792 char vdev_args[VDEV_ARGS_SIZE] = {""};
14793 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14794 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14795 uint16_t worker_core_count = 0;
14796 uint16_t socket_id = 0;
14798 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14799 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14801 /* Identify the Worker Cores
14802 * Use 2 worker cores for the device args
14804 RTE_LCORE_FOREACH_WORKER(i) {
14805 if (worker_core_count > 1)
14807 snprintf(vdev_args, sizeof(vdev_args),
14808 "%s%d", temp_str, i);
14809 strcpy(temp_str, vdev_args);
14810 strlcat(temp_str, ";", sizeof(temp_str));
14811 worker_core_count++;
14812 socket_id = rte_lcore_to_socket_id(i);
14814 if (worker_core_count != 2) {
14815 RTE_LOG(ERR, USER1,
14816 "Cryptodev scheduler test require at least "
14817 "two worker cores to run. "
14818 "Please use the correct coremask.\n");
14819 return TEST_FAILED;
14821 strcpy(temp_str, vdev_args);
14822 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14823 temp_str, socket_id);
14824 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14825 nb_devs = rte_cryptodev_device_count_by_driver(
14826 rte_cryptodev_driver_id_get(
14827 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14829 ret = rte_vdev_init(
14830 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14832 TEST_ASSERT(ret == 0,
14833 "Failed to create instance %u of pmd : %s",
14834 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14837 return testsuite_setup();
14841 test_scheduler_attach_worker_op(void)
14843 struct crypto_testsuite_params *ts_params = &testsuite_params;
14844 uint8_t sched_id = ts_params->valid_devs[0];
14845 uint32_t i, nb_devs_attached = 0;
14847 char vdev_name[32];
14848 unsigned int count = rte_cryptodev_count();
14850 /* create 2 AESNI_MB vdevs on top of existing devices */
14851 for (i = count; i < count + 2; i++) {
14852 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14853 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14855 ret = rte_vdev_init(vdev_name, NULL);
14857 TEST_ASSERT(ret == 0,
14858 "Failed to create instance %u of"
14860 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14863 RTE_LOG(ERR, USER1,
14864 "Failed to create 2 AESNI MB PMDs.\n");
14865 return TEST_SKIPPED;
14869 /* attach 2 AESNI_MB cdevs */
14870 for (i = count; i < count + 2; i++) {
14871 struct rte_cryptodev_info info;
14872 unsigned int session_size;
14874 rte_cryptodev_info_get(i, &info);
14875 if (info.driver_id != rte_cryptodev_driver_id_get(
14876 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14879 session_size = rte_cryptodev_sym_get_private_session_size(i);
14881 * Create the session mempool again, since now there are new devices
14882 * to use the mempool.
14884 if (ts_params->session_mpool) {
14885 rte_mempool_free(ts_params->session_mpool);
14886 ts_params->session_mpool = NULL;
14888 if (ts_params->session_priv_mpool) {
14889 rte_mempool_free(ts_params->session_priv_mpool);
14890 ts_params->session_priv_mpool = NULL;
14893 if (info.sym.max_nb_sessions != 0 &&
14894 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14895 RTE_LOG(ERR, USER1,
14896 "Device does not support "
14897 "at least %u sessions\n",
14899 return TEST_FAILED;
14902 * Create mempool with maximum number of sessions,
14903 * to include the session headers
14905 if (ts_params->session_mpool == NULL) {
14906 ts_params->session_mpool =
14907 rte_cryptodev_sym_session_pool_create(
14909 MAX_NB_SESSIONS, 0, 0, 0,
14911 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14912 "session mempool allocation failed");
14916 * Create mempool with maximum number of sessions,
14917 * to include device specific session private data
14919 if (ts_params->session_priv_mpool == NULL) {
14920 ts_params->session_priv_mpool = rte_mempool_create(
14921 "test_sess_mp_priv",
14924 0, 0, NULL, NULL, NULL,
14925 NULL, SOCKET_ID_ANY,
14928 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14929 "session mempool allocation failed");
14932 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14933 ts_params->qp_conf.mp_session_private =
14934 ts_params->session_priv_mpool;
14936 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14939 TEST_ASSERT(ret == 0,
14940 "Failed to attach device %u of pmd : %s", i,
14941 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14943 aesni_ids[nb_devs_attached] = (uint8_t)i;
14945 nb_devs_attached++;
14952 test_scheduler_detach_worker_op(void)
14954 struct crypto_testsuite_params *ts_params = &testsuite_params;
14955 uint8_t sched_id = ts_params->valid_devs[0];
14959 for (i = 0; i < 2; i++) {
14960 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14962 TEST_ASSERT(ret == 0,
14963 "Failed to detach device %u", aesni_ids[i]);
14970 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14972 struct crypto_testsuite_params *ts_params = &testsuite_params;
14973 uint8_t sched_id = ts_params->valid_devs[0];
14975 return rte_cryptodev_scheduler_mode_set(sched_id,
14980 test_scheduler_mode_roundrobin_op(void)
14982 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14983 0, "Failed to set roundrobin mode");
14989 test_scheduler_mode_multicore_op(void)
14991 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14992 0, "Failed to set multicore mode");
14998 test_scheduler_mode_failover_op(void)
15000 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
15001 0, "Failed to set failover mode");
15007 test_scheduler_mode_pkt_size_distr_op(void)
15009 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
15010 0, "Failed to set pktsize mode");
15016 scheduler_multicore_testsuite_setup(void)
15018 if (test_scheduler_attach_worker_op() < 0)
15019 return TEST_SKIPPED;
15020 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
15021 return TEST_SKIPPED;
15026 scheduler_roundrobin_testsuite_setup(void)
15028 if (test_scheduler_attach_worker_op() < 0)
15029 return TEST_SKIPPED;
15030 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
15031 return TEST_SKIPPED;
15036 scheduler_failover_testsuite_setup(void)
15038 if (test_scheduler_attach_worker_op() < 0)
15039 return TEST_SKIPPED;
15040 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
15041 return TEST_SKIPPED;
15046 scheduler_pkt_size_distr_testsuite_setup(void)
15048 if (test_scheduler_attach_worker_op() < 0)
15049 return TEST_SKIPPED;
15050 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
15051 return TEST_SKIPPED;
15056 scheduler_mode_testsuite_teardown(void)
15058 test_scheduler_detach_worker_op();
15061 #endif /* RTE_CRYPTO_SCHEDULER */
15063 static struct unit_test_suite end_testsuite = {
15064 .suite_name = NULL,
15067 .unit_test_suites = NULL
15070 #ifdef RTE_LIB_SECURITY
15071 static struct unit_test_suite ipsec_proto_testsuite = {
15072 .suite_name = "IPsec Proto Unit Test Suite",
15073 .setup = ipsec_proto_testsuite_setup,
15074 .unit_test_cases = {
15075 TEST_CASE_NAMED_WITH_DATA(
15076 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15077 ut_setup_security, ut_teardown,
15078 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
15079 TEST_CASE_NAMED_WITH_DATA(
15080 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15081 ut_setup_security, ut_teardown,
15082 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
15083 TEST_CASE_NAMED_WITH_DATA(
15084 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15085 ut_setup_security, ut_teardown,
15086 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
15087 TEST_CASE_NAMED_WITH_DATA(
15088 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15089 ut_setup_security, ut_teardown,
15090 test_ipsec_proto_known_vec,
15091 &pkt_aes_128_cbc_hmac_sha256),
15092 TEST_CASE_NAMED_WITH_DATA(
15093 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15094 ut_setup_security, ut_teardown,
15095 test_ipsec_proto_known_vec,
15096 &pkt_aes_128_cbc_hmac_sha384),
15097 TEST_CASE_NAMED_WITH_DATA(
15098 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15099 ut_setup_security, ut_teardown,
15100 test_ipsec_proto_known_vec,
15101 &pkt_aes_128_cbc_hmac_sha512),
15102 TEST_CASE_NAMED_WITH_DATA(
15103 "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15104 ut_setup_security, ut_teardown,
15105 test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
15106 TEST_CASE_NAMED_WITH_DATA(
15107 "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15108 ut_setup_security, ut_teardown,
15109 test_ipsec_proto_known_vec,
15110 &pkt_aes_128_cbc_hmac_sha256_v6),
15111 TEST_CASE_NAMED_WITH_DATA(
15112 "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15113 ut_setup_security, ut_teardown,
15114 test_ipsec_proto_known_vec,
15115 &pkt_null_aes_xcbc),
15116 TEST_CASE_NAMED_WITH_DATA(
15117 "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15118 ut_setup_security, ut_teardown,
15119 test_ipsec_proto_known_vec,
15120 &pkt_ah_tunnel_sha256),
15121 TEST_CASE_NAMED_WITH_DATA(
15122 "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15123 ut_setup_security, ut_teardown,
15124 test_ipsec_proto_known_vec,
15125 &pkt_ah_transport_sha256),
15126 TEST_CASE_NAMED_WITH_DATA(
15127 "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15128 ut_setup_security, ut_teardown,
15129 test_ipsec_proto_known_vec,
15130 &pkt_ah_ipv4_aes_gmac_128),
15131 TEST_CASE_NAMED_WITH_DATA(
15132 "Outbound fragmented packet",
15133 ut_setup_security, ut_teardown,
15134 test_ipsec_proto_known_vec_fragmented,
15135 &pkt_aes_128_gcm_frag),
15136 TEST_CASE_NAMED_WITH_DATA(
15137 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15138 ut_setup_security, ut_teardown,
15139 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
15140 TEST_CASE_NAMED_WITH_DATA(
15141 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15142 ut_setup_security, ut_teardown,
15143 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
15144 TEST_CASE_NAMED_WITH_DATA(
15145 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15146 ut_setup_security, ut_teardown,
15147 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
15148 TEST_CASE_NAMED_WITH_DATA(
15149 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
15150 ut_setup_security, ut_teardown,
15151 test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
15152 TEST_CASE_NAMED_WITH_DATA(
15153 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15154 ut_setup_security, ut_teardown,
15155 test_ipsec_proto_known_vec_inb,
15156 &pkt_aes_128_cbc_hmac_sha256),
15157 TEST_CASE_NAMED_WITH_DATA(
15158 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15159 ut_setup_security, ut_teardown,
15160 test_ipsec_proto_known_vec_inb,
15161 &pkt_aes_128_cbc_hmac_sha384),
15162 TEST_CASE_NAMED_WITH_DATA(
15163 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15164 ut_setup_security, ut_teardown,
15165 test_ipsec_proto_known_vec_inb,
15166 &pkt_aes_128_cbc_hmac_sha512),
15167 TEST_CASE_NAMED_WITH_DATA(
15168 "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15169 ut_setup_security, ut_teardown,
15170 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
15171 TEST_CASE_NAMED_WITH_DATA(
15172 "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15173 ut_setup_security, ut_teardown,
15174 test_ipsec_proto_known_vec_inb,
15175 &pkt_aes_128_cbc_hmac_sha256_v6),
15176 TEST_CASE_NAMED_WITH_DATA(
15177 "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15178 ut_setup_security, ut_teardown,
15179 test_ipsec_proto_known_vec_inb,
15180 &pkt_null_aes_xcbc),
15181 TEST_CASE_NAMED_WITH_DATA(
15182 "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15183 ut_setup_security, ut_teardown,
15184 test_ipsec_proto_known_vec_inb,
15185 &pkt_ah_tunnel_sha256),
15186 TEST_CASE_NAMED_WITH_DATA(
15187 "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15188 ut_setup_security, ut_teardown,
15189 test_ipsec_proto_known_vec_inb,
15190 &pkt_ah_transport_sha256),
15191 TEST_CASE_NAMED_WITH_DATA(
15192 "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15193 ut_setup_security, ut_teardown,
15194 test_ipsec_proto_known_vec_inb,
15195 &pkt_ah_ipv4_aes_gmac_128),
15196 TEST_CASE_NAMED_ST(
15197 "Combined test alg list",
15198 ut_setup_security, ut_teardown,
15199 test_ipsec_proto_display_list),
15200 TEST_CASE_NAMED_ST(
15201 "Combined test alg list (AH)",
15202 ut_setup_security, ut_teardown,
15203 test_ipsec_proto_ah_tunnel_ipv4),
15204 TEST_CASE_NAMED_ST(
15206 ut_setup_security, ut_teardown,
15207 test_ipsec_proto_iv_gen),
15208 TEST_CASE_NAMED_ST(
15209 "UDP encapsulation",
15210 ut_setup_security, ut_teardown,
15211 test_ipsec_proto_udp_encap),
15212 TEST_CASE_NAMED_ST(
15213 "UDP encapsulation ports verification test",
15214 ut_setup_security, ut_teardown,
15215 test_ipsec_proto_udp_ports_verify),
15216 TEST_CASE_NAMED_ST(
15217 "SA expiry packets soft",
15218 ut_setup_security, ut_teardown,
15219 test_ipsec_proto_sa_exp_pkts_soft),
15220 TEST_CASE_NAMED_ST(
15221 "SA expiry packets hard",
15222 ut_setup_security, ut_teardown,
15223 test_ipsec_proto_sa_exp_pkts_hard),
15224 TEST_CASE_NAMED_ST(
15225 "Negative test: ICV corruption",
15226 ut_setup_security, ut_teardown,
15227 test_ipsec_proto_err_icv_corrupt),
15228 TEST_CASE_NAMED_ST(
15229 "Tunnel dst addr verification",
15230 ut_setup_security, ut_teardown,
15231 test_ipsec_proto_tunnel_dst_addr_verify),
15232 TEST_CASE_NAMED_ST(
15233 "Tunnel src and dst addr verification",
15234 ut_setup_security, ut_teardown,
15235 test_ipsec_proto_tunnel_src_dst_addr_verify),
15236 TEST_CASE_NAMED_ST(
15237 "Inner IP checksum",
15238 ut_setup_security, ut_teardown,
15239 test_ipsec_proto_inner_ip_csum),
15240 TEST_CASE_NAMED_ST(
15241 "Inner L4 checksum",
15242 ut_setup_security, ut_teardown,
15243 test_ipsec_proto_inner_l4_csum),
15244 TEST_CASE_NAMED_ST(
15245 "Tunnel IPv4 in IPv4",
15246 ut_setup_security, ut_teardown,
15247 test_ipsec_proto_tunnel_v4_in_v4),
15248 TEST_CASE_NAMED_ST(
15249 "Tunnel IPv6 in IPv6",
15250 ut_setup_security, ut_teardown,
15251 test_ipsec_proto_tunnel_v6_in_v6),
15252 TEST_CASE_NAMED_ST(
15253 "Tunnel IPv4 in IPv6",
15254 ut_setup_security, ut_teardown,
15255 test_ipsec_proto_tunnel_v4_in_v6),
15256 TEST_CASE_NAMED_ST(
15257 "Tunnel IPv6 in IPv4",
15258 ut_setup_security, ut_teardown,
15259 test_ipsec_proto_tunnel_v6_in_v4),
15260 TEST_CASE_NAMED_ST(
15262 ut_setup_security, ut_teardown,
15263 test_ipsec_proto_transport_v4),
15264 TEST_CASE_NAMED_ST(
15265 "AH transport IPv4",
15266 ut_setup_security, ut_teardown,
15267 test_ipsec_proto_ah_transport_ipv4),
15268 TEST_CASE_NAMED_ST(
15269 "Transport l4 checksum",
15270 ut_setup_security, ut_teardown,
15271 test_ipsec_proto_transport_l4_csum),
15272 TEST_CASE_NAMED_ST(
15273 "Statistics: success",
15274 ut_setup_security, ut_teardown,
15275 test_ipsec_proto_stats),
15276 TEST_CASE_NAMED_ST(
15277 "Fragmented packet",
15278 ut_setup_security, ut_teardown,
15279 test_ipsec_proto_pkt_fragment),
15280 TEST_CASE_NAMED_ST(
15281 "Tunnel header copy DF (inner 0)",
15282 ut_setup_security, ut_teardown,
15283 test_ipsec_proto_copy_df_inner_0),
15284 TEST_CASE_NAMED_ST(
15285 "Tunnel header copy DF (inner 1)",
15286 ut_setup_security, ut_teardown,
15287 test_ipsec_proto_copy_df_inner_1),
15288 TEST_CASE_NAMED_ST(
15289 "Tunnel header set DF 0 (inner 1)",
15290 ut_setup_security, ut_teardown,
15291 test_ipsec_proto_set_df_0_inner_1),
15292 TEST_CASE_NAMED_ST(
15293 "Tunnel header set DF 1 (inner 0)",
15294 ut_setup_security, ut_teardown,
15295 test_ipsec_proto_set_df_1_inner_0),
15296 TEST_CASE_NAMED_ST(
15297 "Tunnel header IPv4 copy DSCP (inner 0)",
15298 ut_setup_security, ut_teardown,
15299 test_ipsec_proto_ipv4_copy_dscp_inner_0),
15300 TEST_CASE_NAMED_ST(
15301 "Tunnel header IPv4 copy DSCP (inner 1)",
15302 ut_setup_security, ut_teardown,
15303 test_ipsec_proto_ipv4_copy_dscp_inner_1),
15304 TEST_CASE_NAMED_ST(
15305 "Tunnel header IPv4 set DSCP 0 (inner 1)",
15306 ut_setup_security, ut_teardown,
15307 test_ipsec_proto_ipv4_set_dscp_0_inner_1),
15308 TEST_CASE_NAMED_ST(
15309 "Tunnel header IPv4 set DSCP 1 (inner 0)",
15310 ut_setup_security, ut_teardown,
15311 test_ipsec_proto_ipv4_set_dscp_1_inner_0),
15312 TEST_CASE_NAMED_ST(
15313 "Tunnel header IPv6 copy DSCP (inner 0)",
15314 ut_setup_security, ut_teardown,
15315 test_ipsec_proto_ipv6_copy_dscp_inner_0),
15316 TEST_CASE_NAMED_ST(
15317 "Tunnel header IPv6 copy DSCP (inner 1)",
15318 ut_setup_security, ut_teardown,
15319 test_ipsec_proto_ipv6_copy_dscp_inner_1),
15320 TEST_CASE_NAMED_ST(
15321 "Tunnel header IPv6 set DSCP 0 (inner 1)",
15322 ut_setup_security, ut_teardown,
15323 test_ipsec_proto_ipv6_set_dscp_0_inner_1),
15324 TEST_CASE_NAMED_ST(
15325 "Tunnel header IPv6 set DSCP 1 (inner 0)",
15326 ut_setup_security, ut_teardown,
15327 test_ipsec_proto_ipv6_set_dscp_1_inner_0),
15328 TEST_CASE_NAMED_WITH_DATA(
15329 "Antireplay with window size 1024",
15330 ut_setup_security, ut_teardown,
15331 test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
15332 TEST_CASE_NAMED_WITH_DATA(
15333 "Antireplay with window size 2048",
15334 ut_setup_security, ut_teardown,
15335 test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
15336 TEST_CASE_NAMED_WITH_DATA(
15337 "Antireplay with window size 4096",
15338 ut_setup_security, ut_teardown,
15339 test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
15340 TEST_CASE_NAMED_WITH_DATA(
15341 "ESN and Antireplay with window size 1024",
15342 ut_setup_security, ut_teardown,
15343 test_ipsec_proto_pkt_esn_antireplay1024,
15345 TEST_CASE_NAMED_WITH_DATA(
15346 "ESN and Antireplay with window size 2048",
15347 ut_setup_security, ut_teardown,
15348 test_ipsec_proto_pkt_esn_antireplay2048,
15350 TEST_CASE_NAMED_WITH_DATA(
15351 "ESN and Antireplay with window size 4096",
15352 ut_setup_security, ut_teardown,
15353 test_ipsec_proto_pkt_esn_antireplay4096,
15355 TEST_CASE_NAMED_ST(
15356 "Tunnel header IPv4 decrement inner TTL",
15357 ut_setup_security, ut_teardown,
15358 test_ipsec_proto_ipv4_ttl_decrement),
15359 TEST_CASE_NAMED_ST(
15360 "Tunnel header IPv6 decrement inner hop limit",
15361 ut_setup_security, ut_teardown,
15362 test_ipsec_proto_ipv6_hop_limit_decrement),
15363 TEST_CASES_END() /**< NULL terminate unit test array */
15367 static struct unit_test_suite pdcp_proto_testsuite = {
15368 .suite_name = "PDCP Proto Unit Test Suite",
15369 .setup = pdcp_proto_testsuite_setup,
15370 .unit_test_cases = {
15371 TEST_CASE_ST(ut_setup_security, ut_teardown,
15372 test_PDCP_PROTO_all),
15373 TEST_CASES_END() /**< NULL terminate unit test array */
15377 #define ADD_UPLINK_TESTCASE(data) \
15378 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
15379 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
15381 #define ADD_DOWNLINK_TESTCASE(data) \
15382 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
15383 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
15385 static struct unit_test_suite docsis_proto_testsuite = {
15386 .suite_name = "DOCSIS Proto Unit Test Suite",
15387 .setup = docsis_proto_testsuite_setup,
15388 .unit_test_cases = {
15390 ADD_UPLINK_TESTCASE(docsis_test_case_1)
15391 ADD_UPLINK_TESTCASE(docsis_test_case_2)
15392 ADD_UPLINK_TESTCASE(docsis_test_case_3)
15393 ADD_UPLINK_TESTCASE(docsis_test_case_4)
15394 ADD_UPLINK_TESTCASE(docsis_test_case_5)
15395 ADD_UPLINK_TESTCASE(docsis_test_case_6)
15396 ADD_UPLINK_TESTCASE(docsis_test_case_7)
15397 ADD_UPLINK_TESTCASE(docsis_test_case_8)
15398 ADD_UPLINK_TESTCASE(docsis_test_case_9)
15399 ADD_UPLINK_TESTCASE(docsis_test_case_10)
15400 ADD_UPLINK_TESTCASE(docsis_test_case_11)
15401 ADD_UPLINK_TESTCASE(docsis_test_case_12)
15402 ADD_UPLINK_TESTCASE(docsis_test_case_13)
15403 ADD_UPLINK_TESTCASE(docsis_test_case_14)
15404 ADD_UPLINK_TESTCASE(docsis_test_case_15)
15405 ADD_UPLINK_TESTCASE(docsis_test_case_16)
15406 ADD_UPLINK_TESTCASE(docsis_test_case_17)
15407 ADD_UPLINK_TESTCASE(docsis_test_case_18)
15408 ADD_UPLINK_TESTCASE(docsis_test_case_19)
15409 ADD_UPLINK_TESTCASE(docsis_test_case_20)
15410 ADD_UPLINK_TESTCASE(docsis_test_case_21)
15411 ADD_UPLINK_TESTCASE(docsis_test_case_22)
15412 ADD_UPLINK_TESTCASE(docsis_test_case_23)
15413 ADD_UPLINK_TESTCASE(docsis_test_case_24)
15414 ADD_UPLINK_TESTCASE(docsis_test_case_25)
15415 ADD_UPLINK_TESTCASE(docsis_test_case_26)
15417 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
15418 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
15419 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
15420 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
15421 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
15422 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
15423 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
15424 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
15425 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
15426 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
15427 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
15428 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
15429 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
15430 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
15431 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
15432 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
15433 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
15434 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
15435 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
15436 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
15437 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
15438 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
15439 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
15440 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
15441 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
15442 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
15443 TEST_CASES_END() /**< NULL terminate unit test array */
15448 static struct unit_test_suite cryptodev_gen_testsuite = {
15449 .suite_name = "Crypto General Unit Test Suite",
15450 .setup = crypto_gen_testsuite_setup,
15451 .unit_test_cases = {
15452 TEST_CASE_ST(ut_setup, ut_teardown,
15453 test_device_configure_invalid_dev_id),
15454 TEST_CASE_ST(ut_setup, ut_teardown,
15455 test_queue_pair_descriptor_setup),
15456 TEST_CASE_ST(ut_setup, ut_teardown,
15457 test_device_configure_invalid_queue_pair_ids),
15458 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
15459 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
15460 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
15461 TEST_CASES_END() /**< NULL terminate unit test array */
15465 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
15466 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
15467 .setup = negative_hmac_sha1_testsuite_setup,
15468 .unit_test_cases = {
15469 /** Negative tests */
15470 TEST_CASE_ST(ut_setup, ut_teardown,
15471 authentication_verify_HMAC_SHA1_fail_data_corrupt),
15472 TEST_CASE_ST(ut_setup, ut_teardown,
15473 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
15474 TEST_CASE_ST(ut_setup, ut_teardown,
15475 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
15476 TEST_CASE_ST(ut_setup, ut_teardown,
15477 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
15479 TEST_CASES_END() /**< NULL terminate unit test array */
15483 static struct unit_test_suite cryptodev_multi_session_testsuite = {
15484 .suite_name = "Multi Session Unit Test Suite",
15485 .setup = multi_session_testsuite_setup,
15486 .unit_test_cases = {
15487 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
15488 TEST_CASE_ST(ut_setup, ut_teardown,
15489 test_multi_session_random_usage),
15491 TEST_CASES_END() /**< NULL terminate unit test array */
15495 static struct unit_test_suite cryptodev_null_testsuite = {
15496 .suite_name = "NULL Test Suite",
15497 .setup = null_testsuite_setup,
15498 .unit_test_cases = {
15499 TEST_CASE_ST(ut_setup, ut_teardown,
15500 test_null_invalid_operation),
15501 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
15506 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
15507 .suite_name = "AES CCM Authenticated Test Suite",
15508 .setup = aes_ccm_auth_testsuite_setup,
15509 .unit_test_cases = {
15510 /** AES CCM Authenticated Encryption 128 bits key*/
15511 TEST_CASE_ST(ut_setup, ut_teardown,
15512 test_AES_CCM_authenticated_encryption_test_case_128_1),
15513 TEST_CASE_ST(ut_setup, ut_teardown,
15514 test_AES_CCM_authenticated_encryption_test_case_128_2),
15515 TEST_CASE_ST(ut_setup, ut_teardown,
15516 test_AES_CCM_authenticated_encryption_test_case_128_3),
15518 /** AES CCM Authenticated Decryption 128 bits key*/
15519 TEST_CASE_ST(ut_setup, ut_teardown,
15520 test_AES_CCM_authenticated_decryption_test_case_128_1),
15521 TEST_CASE_ST(ut_setup, ut_teardown,
15522 test_AES_CCM_authenticated_decryption_test_case_128_2),
15523 TEST_CASE_ST(ut_setup, ut_teardown,
15524 test_AES_CCM_authenticated_decryption_test_case_128_3),
15526 /** AES CCM Authenticated Encryption 192 bits key */
15527 TEST_CASE_ST(ut_setup, ut_teardown,
15528 test_AES_CCM_authenticated_encryption_test_case_192_1),
15529 TEST_CASE_ST(ut_setup, ut_teardown,
15530 test_AES_CCM_authenticated_encryption_test_case_192_2),
15531 TEST_CASE_ST(ut_setup, ut_teardown,
15532 test_AES_CCM_authenticated_encryption_test_case_192_3),
15534 /** AES CCM Authenticated Decryption 192 bits key*/
15535 TEST_CASE_ST(ut_setup, ut_teardown,
15536 test_AES_CCM_authenticated_decryption_test_case_192_1),
15537 TEST_CASE_ST(ut_setup, ut_teardown,
15538 test_AES_CCM_authenticated_decryption_test_case_192_2),
15539 TEST_CASE_ST(ut_setup, ut_teardown,
15540 test_AES_CCM_authenticated_decryption_test_case_192_3),
15542 /** AES CCM Authenticated Encryption 256 bits key */
15543 TEST_CASE_ST(ut_setup, ut_teardown,
15544 test_AES_CCM_authenticated_encryption_test_case_256_1),
15545 TEST_CASE_ST(ut_setup, ut_teardown,
15546 test_AES_CCM_authenticated_encryption_test_case_256_2),
15547 TEST_CASE_ST(ut_setup, ut_teardown,
15548 test_AES_CCM_authenticated_encryption_test_case_256_3),
15550 /** AES CCM Authenticated Decryption 256 bits key*/
15551 TEST_CASE_ST(ut_setup, ut_teardown,
15552 test_AES_CCM_authenticated_decryption_test_case_256_1),
15553 TEST_CASE_ST(ut_setup, ut_teardown,
15554 test_AES_CCM_authenticated_decryption_test_case_256_2),
15555 TEST_CASE_ST(ut_setup, ut_teardown,
15556 test_AES_CCM_authenticated_decryption_test_case_256_3),
15561 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
15562 .suite_name = "AES GCM Authenticated Test Suite",
15563 .setup = aes_gcm_auth_testsuite_setup,
15564 .unit_test_cases = {
15565 /** AES GCM Authenticated Encryption */
15566 TEST_CASE_ST(ut_setup, ut_teardown,
15567 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15568 TEST_CASE_ST(ut_setup, ut_teardown,
15569 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15570 TEST_CASE_ST(ut_setup, ut_teardown,
15571 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15572 TEST_CASE_ST(ut_setup, ut_teardown,
15573 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15574 TEST_CASE_ST(ut_setup, ut_teardown,
15575 test_AES_GCM_authenticated_encryption_test_case_1),
15576 TEST_CASE_ST(ut_setup, ut_teardown,
15577 test_AES_GCM_authenticated_encryption_test_case_2),
15578 TEST_CASE_ST(ut_setup, ut_teardown,
15579 test_AES_GCM_authenticated_encryption_test_case_3),
15580 TEST_CASE_ST(ut_setup, ut_teardown,
15581 test_AES_GCM_authenticated_encryption_test_case_4),
15582 TEST_CASE_ST(ut_setup, ut_teardown,
15583 test_AES_GCM_authenticated_encryption_test_case_5),
15584 TEST_CASE_ST(ut_setup, ut_teardown,
15585 test_AES_GCM_authenticated_encryption_test_case_6),
15586 TEST_CASE_ST(ut_setup, ut_teardown,
15587 test_AES_GCM_authenticated_encryption_test_case_7),
15588 TEST_CASE_ST(ut_setup, ut_teardown,
15589 test_AES_GCM_authenticated_encryption_test_case_8),
15590 TEST_CASE_ST(ut_setup, ut_teardown,
15591 test_AES_GCM_J0_authenticated_encryption_test_case_1),
15593 /** AES GCM Authenticated Decryption */
15594 TEST_CASE_ST(ut_setup, ut_teardown,
15595 test_AES_GCM_authenticated_decryption_test_case_1),
15596 TEST_CASE_ST(ut_setup, ut_teardown,
15597 test_AES_GCM_authenticated_decryption_test_case_2),
15598 TEST_CASE_ST(ut_setup, ut_teardown,
15599 test_AES_GCM_authenticated_decryption_test_case_3),
15600 TEST_CASE_ST(ut_setup, ut_teardown,
15601 test_AES_GCM_authenticated_decryption_test_case_4),
15602 TEST_CASE_ST(ut_setup, ut_teardown,
15603 test_AES_GCM_authenticated_decryption_test_case_5),
15604 TEST_CASE_ST(ut_setup, ut_teardown,
15605 test_AES_GCM_authenticated_decryption_test_case_6),
15606 TEST_CASE_ST(ut_setup, ut_teardown,
15607 test_AES_GCM_authenticated_decryption_test_case_7),
15608 TEST_CASE_ST(ut_setup, ut_teardown,
15609 test_AES_GCM_authenticated_decryption_test_case_8),
15610 TEST_CASE_ST(ut_setup, ut_teardown,
15611 test_AES_GCM_J0_authenticated_decryption_test_case_1),
15613 /** AES GCM Authenticated Encryption 192 bits key */
15614 TEST_CASE_ST(ut_setup, ut_teardown,
15615 test_AES_GCM_auth_encryption_test_case_192_1),
15616 TEST_CASE_ST(ut_setup, ut_teardown,
15617 test_AES_GCM_auth_encryption_test_case_192_2),
15618 TEST_CASE_ST(ut_setup, ut_teardown,
15619 test_AES_GCM_auth_encryption_test_case_192_3),
15620 TEST_CASE_ST(ut_setup, ut_teardown,
15621 test_AES_GCM_auth_encryption_test_case_192_4),
15622 TEST_CASE_ST(ut_setup, ut_teardown,
15623 test_AES_GCM_auth_encryption_test_case_192_5),
15624 TEST_CASE_ST(ut_setup, ut_teardown,
15625 test_AES_GCM_auth_encryption_test_case_192_6),
15626 TEST_CASE_ST(ut_setup, ut_teardown,
15627 test_AES_GCM_auth_encryption_test_case_192_7),
15629 /** AES GCM Authenticated Decryption 192 bits key */
15630 TEST_CASE_ST(ut_setup, ut_teardown,
15631 test_AES_GCM_auth_decryption_test_case_192_1),
15632 TEST_CASE_ST(ut_setup, ut_teardown,
15633 test_AES_GCM_auth_decryption_test_case_192_2),
15634 TEST_CASE_ST(ut_setup, ut_teardown,
15635 test_AES_GCM_auth_decryption_test_case_192_3),
15636 TEST_CASE_ST(ut_setup, ut_teardown,
15637 test_AES_GCM_auth_decryption_test_case_192_4),
15638 TEST_CASE_ST(ut_setup, ut_teardown,
15639 test_AES_GCM_auth_decryption_test_case_192_5),
15640 TEST_CASE_ST(ut_setup, ut_teardown,
15641 test_AES_GCM_auth_decryption_test_case_192_6),
15642 TEST_CASE_ST(ut_setup, ut_teardown,
15643 test_AES_GCM_auth_decryption_test_case_192_7),
15645 /** AES GCM Authenticated Encryption 256 bits key */
15646 TEST_CASE_ST(ut_setup, ut_teardown,
15647 test_AES_GCM_auth_encryption_test_case_256_1),
15648 TEST_CASE_ST(ut_setup, ut_teardown,
15649 test_AES_GCM_auth_encryption_test_case_256_2),
15650 TEST_CASE_ST(ut_setup, ut_teardown,
15651 test_AES_GCM_auth_encryption_test_case_256_3),
15652 TEST_CASE_ST(ut_setup, ut_teardown,
15653 test_AES_GCM_auth_encryption_test_case_256_4),
15654 TEST_CASE_ST(ut_setup, ut_teardown,
15655 test_AES_GCM_auth_encryption_test_case_256_5),
15656 TEST_CASE_ST(ut_setup, ut_teardown,
15657 test_AES_GCM_auth_encryption_test_case_256_6),
15658 TEST_CASE_ST(ut_setup, ut_teardown,
15659 test_AES_GCM_auth_encryption_test_case_256_7),
15661 /** AES GCM Authenticated Decryption 256 bits key */
15662 TEST_CASE_ST(ut_setup, ut_teardown,
15663 test_AES_GCM_auth_decryption_test_case_256_1),
15664 TEST_CASE_ST(ut_setup, ut_teardown,
15665 test_AES_GCM_auth_decryption_test_case_256_2),
15666 TEST_CASE_ST(ut_setup, ut_teardown,
15667 test_AES_GCM_auth_decryption_test_case_256_3),
15668 TEST_CASE_ST(ut_setup, ut_teardown,
15669 test_AES_GCM_auth_decryption_test_case_256_4),
15670 TEST_CASE_ST(ut_setup, ut_teardown,
15671 test_AES_GCM_auth_decryption_test_case_256_5),
15672 TEST_CASE_ST(ut_setup, ut_teardown,
15673 test_AES_GCM_auth_decryption_test_case_256_6),
15674 TEST_CASE_ST(ut_setup, ut_teardown,
15675 test_AES_GCM_auth_decryption_test_case_256_7),
15677 /** AES GCM Authenticated Encryption big aad size */
15678 TEST_CASE_ST(ut_setup, ut_teardown,
15679 test_AES_GCM_auth_encryption_test_case_aad_1),
15680 TEST_CASE_ST(ut_setup, ut_teardown,
15681 test_AES_GCM_auth_encryption_test_case_aad_2),
15683 /** AES GCM Authenticated Decryption big aad size */
15684 TEST_CASE_ST(ut_setup, ut_teardown,
15685 test_AES_GCM_auth_decryption_test_case_aad_1),
15686 TEST_CASE_ST(ut_setup, ut_teardown,
15687 test_AES_GCM_auth_decryption_test_case_aad_2),
15689 /** Out of place tests */
15690 TEST_CASE_ST(ut_setup, ut_teardown,
15691 test_AES_GCM_authenticated_encryption_oop_test_case_1),
15692 TEST_CASE_ST(ut_setup, ut_teardown,
15693 test_AES_GCM_authenticated_decryption_oop_test_case_1),
15695 /** Session-less tests */
15696 TEST_CASE_ST(ut_setup, ut_teardown,
15697 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15698 TEST_CASE_ST(ut_setup, ut_teardown,
15699 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15705 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
15706 .suite_name = "AES GMAC Authentication Test Suite",
15707 .setup = aes_gmac_auth_testsuite_setup,
15708 .unit_test_cases = {
15709 TEST_CASE_ST(ut_setup, ut_teardown,
15710 test_AES_GMAC_authentication_test_case_1),
15711 TEST_CASE_ST(ut_setup, ut_teardown,
15712 test_AES_GMAC_authentication_verify_test_case_1),
15713 TEST_CASE_ST(ut_setup, ut_teardown,
15714 test_AES_GMAC_authentication_test_case_2),
15715 TEST_CASE_ST(ut_setup, ut_teardown,
15716 test_AES_GMAC_authentication_verify_test_case_2),
15717 TEST_CASE_ST(ut_setup, ut_teardown,
15718 test_AES_GMAC_authentication_test_case_3),
15719 TEST_CASE_ST(ut_setup, ut_teardown,
15720 test_AES_GMAC_authentication_verify_test_case_3),
15721 TEST_CASE_ST(ut_setup, ut_teardown,
15722 test_AES_GMAC_authentication_test_case_4),
15723 TEST_CASE_ST(ut_setup, ut_teardown,
15724 test_AES_GMAC_authentication_verify_test_case_4),
15725 TEST_CASE_ST(ut_setup, ut_teardown,
15726 test_AES_GMAC_authentication_SGL_40B),
15727 TEST_CASE_ST(ut_setup, ut_teardown,
15728 test_AES_GMAC_authentication_SGL_80B),
15729 TEST_CASE_ST(ut_setup, ut_teardown,
15730 test_AES_GMAC_authentication_SGL_2048B),
15731 TEST_CASE_ST(ut_setup, ut_teardown,
15732 test_AES_GMAC_authentication_SGL_2047B),
15738 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
15739 .suite_name = "Chacha20-Poly1305 Test Suite",
15740 .setup = chacha20_poly1305_testsuite_setup,
15741 .unit_test_cases = {
15742 TEST_CASE_ST(ut_setup, ut_teardown,
15743 test_chacha20_poly1305_encrypt_test_case_rfc8439),
15744 TEST_CASE_ST(ut_setup, ut_teardown,
15745 test_chacha20_poly1305_decrypt_test_case_rfc8439),
15746 TEST_CASE_ST(ut_setup, ut_teardown,
15747 test_chacha20_poly1305_encrypt_SGL_out_of_place),
15752 static struct unit_test_suite cryptodev_snow3g_testsuite = {
15753 .suite_name = "SNOW 3G Test Suite",
15754 .setup = snow3g_testsuite_setup,
15755 .unit_test_cases = {
15756 /** SNOW 3G encrypt only (UEA2) */
15757 TEST_CASE_ST(ut_setup, ut_teardown,
15758 test_snow3g_encryption_test_case_1),
15759 TEST_CASE_ST(ut_setup, ut_teardown,
15760 test_snow3g_encryption_test_case_2),
15761 TEST_CASE_ST(ut_setup, ut_teardown,
15762 test_snow3g_encryption_test_case_3),
15763 TEST_CASE_ST(ut_setup, ut_teardown,
15764 test_snow3g_encryption_test_case_4),
15765 TEST_CASE_ST(ut_setup, ut_teardown,
15766 test_snow3g_encryption_test_case_5),
15768 TEST_CASE_ST(ut_setup, ut_teardown,
15769 test_snow3g_encryption_test_case_1_oop),
15770 TEST_CASE_ST(ut_setup, ut_teardown,
15771 test_snow3g_encryption_test_case_1_oop_sgl),
15772 TEST_CASE_ST(ut_setup, ut_teardown,
15773 test_snow3g_encryption_test_case_1_offset_oop),
15774 TEST_CASE_ST(ut_setup, ut_teardown,
15775 test_snow3g_decryption_test_case_1_oop),
15777 /** SNOW 3G generate auth, then encrypt (UEA2) */
15778 TEST_CASE_ST(ut_setup, ut_teardown,
15779 test_snow3g_auth_cipher_test_case_1),
15780 TEST_CASE_ST(ut_setup, ut_teardown,
15781 test_snow3g_auth_cipher_test_case_2),
15782 TEST_CASE_ST(ut_setup, ut_teardown,
15783 test_snow3g_auth_cipher_test_case_2_oop),
15784 TEST_CASE_ST(ut_setup, ut_teardown,
15785 test_snow3g_auth_cipher_part_digest_enc),
15786 TEST_CASE_ST(ut_setup, ut_teardown,
15787 test_snow3g_auth_cipher_part_digest_enc_oop),
15788 TEST_CASE_ST(ut_setup, ut_teardown,
15789 test_snow3g_auth_cipher_test_case_3_sgl),
15790 TEST_CASE_ST(ut_setup, ut_teardown,
15791 test_snow3g_auth_cipher_test_case_3_oop_sgl),
15792 TEST_CASE_ST(ut_setup, ut_teardown,
15793 test_snow3g_auth_cipher_part_digest_enc_sgl),
15794 TEST_CASE_ST(ut_setup, ut_teardown,
15795 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15797 /** SNOW 3G decrypt (UEA2), then verify auth */
15798 TEST_CASE_ST(ut_setup, ut_teardown,
15799 test_snow3g_auth_cipher_verify_test_case_1),
15800 TEST_CASE_ST(ut_setup, ut_teardown,
15801 test_snow3g_auth_cipher_verify_test_case_2),
15802 TEST_CASE_ST(ut_setup, ut_teardown,
15803 test_snow3g_auth_cipher_verify_test_case_2_oop),
15804 TEST_CASE_ST(ut_setup, ut_teardown,
15805 test_snow3g_auth_cipher_verify_part_digest_enc),
15806 TEST_CASE_ST(ut_setup, ut_teardown,
15807 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15808 TEST_CASE_ST(ut_setup, ut_teardown,
15809 test_snow3g_auth_cipher_verify_test_case_3_sgl),
15810 TEST_CASE_ST(ut_setup, ut_teardown,
15811 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15812 TEST_CASE_ST(ut_setup, ut_teardown,
15813 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15814 TEST_CASE_ST(ut_setup, ut_teardown,
15815 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15817 /** SNOW 3G decrypt only (UEA2) */
15818 TEST_CASE_ST(ut_setup, ut_teardown,
15819 test_snow3g_decryption_test_case_1),
15820 TEST_CASE_ST(ut_setup, ut_teardown,
15821 test_snow3g_decryption_test_case_2),
15822 TEST_CASE_ST(ut_setup, ut_teardown,
15823 test_snow3g_decryption_test_case_3),
15824 TEST_CASE_ST(ut_setup, ut_teardown,
15825 test_snow3g_decryption_test_case_4),
15826 TEST_CASE_ST(ut_setup, ut_teardown,
15827 test_snow3g_decryption_test_case_5),
15828 TEST_CASE_ST(ut_setup, ut_teardown,
15829 test_snow3g_decryption_with_digest_test_case_1),
15830 TEST_CASE_ST(ut_setup, ut_teardown,
15831 test_snow3g_hash_generate_test_case_1),
15832 TEST_CASE_ST(ut_setup, ut_teardown,
15833 test_snow3g_hash_generate_test_case_2),
15834 TEST_CASE_ST(ut_setup, ut_teardown,
15835 test_snow3g_hash_generate_test_case_3),
15837 /* Tests with buffers which length is not byte-aligned */
15838 TEST_CASE_ST(ut_setup, ut_teardown,
15839 test_snow3g_hash_generate_test_case_4),
15840 TEST_CASE_ST(ut_setup, ut_teardown,
15841 test_snow3g_hash_generate_test_case_5),
15842 TEST_CASE_ST(ut_setup, ut_teardown,
15843 test_snow3g_hash_generate_test_case_6),
15844 TEST_CASE_ST(ut_setup, ut_teardown,
15845 test_snow3g_hash_verify_test_case_1),
15846 TEST_CASE_ST(ut_setup, ut_teardown,
15847 test_snow3g_hash_verify_test_case_2),
15848 TEST_CASE_ST(ut_setup, ut_teardown,
15849 test_snow3g_hash_verify_test_case_3),
15851 /* Tests with buffers which length is not byte-aligned */
15852 TEST_CASE_ST(ut_setup, ut_teardown,
15853 test_snow3g_hash_verify_test_case_4),
15854 TEST_CASE_ST(ut_setup, ut_teardown,
15855 test_snow3g_hash_verify_test_case_5),
15856 TEST_CASE_ST(ut_setup, ut_teardown,
15857 test_snow3g_hash_verify_test_case_6),
15858 TEST_CASE_ST(ut_setup, ut_teardown,
15859 test_snow3g_cipher_auth_test_case_1),
15860 TEST_CASE_ST(ut_setup, ut_teardown,
15861 test_snow3g_auth_cipher_with_digest_test_case_1),
15866 static struct unit_test_suite cryptodev_zuc_testsuite = {
15867 .suite_name = "ZUC Test Suite",
15868 .setup = zuc_testsuite_setup,
15869 .unit_test_cases = {
15870 /** ZUC encrypt only (EEA3) */
15871 TEST_CASE_ST(ut_setup, ut_teardown,
15872 test_zuc_encryption_test_case_1),
15873 TEST_CASE_ST(ut_setup, ut_teardown,
15874 test_zuc_encryption_test_case_2),
15875 TEST_CASE_ST(ut_setup, ut_teardown,
15876 test_zuc_encryption_test_case_3),
15877 TEST_CASE_ST(ut_setup, ut_teardown,
15878 test_zuc_encryption_test_case_4),
15879 TEST_CASE_ST(ut_setup, ut_teardown,
15880 test_zuc_encryption_test_case_5),
15881 TEST_CASE_ST(ut_setup, ut_teardown,
15882 test_zuc_encryption_test_case_6_sgl),
15884 /** ZUC authenticate (EIA3) */
15885 TEST_CASE_ST(ut_setup, ut_teardown,
15886 test_zuc_hash_generate_test_case_1),
15887 TEST_CASE_ST(ut_setup, ut_teardown,
15888 test_zuc_hash_generate_test_case_2),
15889 TEST_CASE_ST(ut_setup, ut_teardown,
15890 test_zuc_hash_generate_test_case_3),
15891 TEST_CASE_ST(ut_setup, ut_teardown,
15892 test_zuc_hash_generate_test_case_4),
15893 TEST_CASE_ST(ut_setup, ut_teardown,
15894 test_zuc_hash_generate_test_case_5),
15895 TEST_CASE_ST(ut_setup, ut_teardown,
15896 test_zuc_hash_generate_test_case_6),
15897 TEST_CASE_ST(ut_setup, ut_teardown,
15898 test_zuc_hash_generate_test_case_7),
15899 TEST_CASE_ST(ut_setup, ut_teardown,
15900 test_zuc_hash_generate_test_case_8),
15901 TEST_CASE_ST(ut_setup, ut_teardown,
15902 test_zuc_hash_generate_test_case_9),
15903 TEST_CASE_ST(ut_setup, ut_teardown,
15904 test_zuc_hash_generate_test_case_10),
15905 TEST_CASE_ST(ut_setup, ut_teardown,
15906 test_zuc_hash_generate_test_case_11),
15909 /** ZUC alg-chain (EEA3/EIA3) */
15910 TEST_CASE_ST(ut_setup, ut_teardown,
15911 test_zuc_cipher_auth_test_case_1),
15912 TEST_CASE_ST(ut_setup, ut_teardown,
15913 test_zuc_cipher_auth_test_case_2),
15915 /** ZUC generate auth, then encrypt (EEA3) */
15916 TEST_CASE_ST(ut_setup, ut_teardown,
15917 test_zuc_auth_cipher_test_case_1),
15918 TEST_CASE_ST(ut_setup, ut_teardown,
15919 test_zuc_auth_cipher_test_case_1_oop),
15920 TEST_CASE_ST(ut_setup, ut_teardown,
15921 test_zuc_auth_cipher_test_case_1_sgl),
15922 TEST_CASE_ST(ut_setup, ut_teardown,
15923 test_zuc_auth_cipher_test_case_1_oop_sgl),
15925 /** ZUC decrypt (EEA3), then verify auth */
15926 TEST_CASE_ST(ut_setup, ut_teardown,
15927 test_zuc_auth_cipher_verify_test_case_1),
15928 TEST_CASE_ST(ut_setup, ut_teardown,
15929 test_zuc_auth_cipher_verify_test_case_1_oop),
15930 TEST_CASE_ST(ut_setup, ut_teardown,
15931 test_zuc_auth_cipher_verify_test_case_1_sgl),
15932 TEST_CASE_ST(ut_setup, ut_teardown,
15933 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15935 /** ZUC-256 encrypt only **/
15936 TEST_CASE_ST(ut_setup, ut_teardown,
15937 test_zuc256_encryption_test_case_1),
15938 TEST_CASE_ST(ut_setup, ut_teardown,
15939 test_zuc256_encryption_test_case_2),
15941 /** ZUC-256 authentication only **/
15942 TEST_CASE_ST(ut_setup, ut_teardown,
15943 test_zuc256_authentication_test_case_1),
15944 TEST_CASE_ST(ut_setup, ut_teardown,
15945 test_zuc256_authentication_test_case_2),
15951 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15952 .suite_name = "HMAC_MD5 Authentication Test Suite",
15953 .setup = hmac_md5_auth_testsuite_setup,
15954 .unit_test_cases = {
15955 TEST_CASE_ST(ut_setup, ut_teardown,
15956 test_MD5_HMAC_generate_case_1),
15957 TEST_CASE_ST(ut_setup, ut_teardown,
15958 test_MD5_HMAC_verify_case_1),
15959 TEST_CASE_ST(ut_setup, ut_teardown,
15960 test_MD5_HMAC_generate_case_2),
15961 TEST_CASE_ST(ut_setup, ut_teardown,
15962 test_MD5_HMAC_verify_case_2),
15967 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15968 .suite_name = "Kasumi Test Suite",
15969 .setup = kasumi_testsuite_setup,
15970 .unit_test_cases = {
15971 /** KASUMI hash only (UIA1) */
15972 TEST_CASE_ST(ut_setup, ut_teardown,
15973 test_kasumi_hash_generate_test_case_1),
15974 TEST_CASE_ST(ut_setup, ut_teardown,
15975 test_kasumi_hash_generate_test_case_2),
15976 TEST_CASE_ST(ut_setup, ut_teardown,
15977 test_kasumi_hash_generate_test_case_3),
15978 TEST_CASE_ST(ut_setup, ut_teardown,
15979 test_kasumi_hash_generate_test_case_4),
15980 TEST_CASE_ST(ut_setup, ut_teardown,
15981 test_kasumi_hash_generate_test_case_5),
15982 TEST_CASE_ST(ut_setup, ut_teardown,
15983 test_kasumi_hash_generate_test_case_6),
15985 TEST_CASE_ST(ut_setup, ut_teardown,
15986 test_kasumi_hash_verify_test_case_1),
15987 TEST_CASE_ST(ut_setup, ut_teardown,
15988 test_kasumi_hash_verify_test_case_2),
15989 TEST_CASE_ST(ut_setup, ut_teardown,
15990 test_kasumi_hash_verify_test_case_3),
15991 TEST_CASE_ST(ut_setup, ut_teardown,
15992 test_kasumi_hash_verify_test_case_4),
15993 TEST_CASE_ST(ut_setup, ut_teardown,
15994 test_kasumi_hash_verify_test_case_5),
15996 /** KASUMI encrypt only (UEA1) */
15997 TEST_CASE_ST(ut_setup, ut_teardown,
15998 test_kasumi_encryption_test_case_1),
15999 TEST_CASE_ST(ut_setup, ut_teardown,
16000 test_kasumi_encryption_test_case_1_sgl),
16001 TEST_CASE_ST(ut_setup, ut_teardown,
16002 test_kasumi_encryption_test_case_1_oop),
16003 TEST_CASE_ST(ut_setup, ut_teardown,
16004 test_kasumi_encryption_test_case_1_oop_sgl),
16005 TEST_CASE_ST(ut_setup, ut_teardown,
16006 test_kasumi_encryption_test_case_2),
16007 TEST_CASE_ST(ut_setup, ut_teardown,
16008 test_kasumi_encryption_test_case_3),
16009 TEST_CASE_ST(ut_setup, ut_teardown,
16010 test_kasumi_encryption_test_case_4),
16011 TEST_CASE_ST(ut_setup, ut_teardown,
16012 test_kasumi_encryption_test_case_5),
16014 /** KASUMI decrypt only (UEA1) */
16015 TEST_CASE_ST(ut_setup, ut_teardown,
16016 test_kasumi_decryption_test_case_1),
16017 TEST_CASE_ST(ut_setup, ut_teardown,
16018 test_kasumi_decryption_test_case_2),
16019 TEST_CASE_ST(ut_setup, ut_teardown,
16020 test_kasumi_decryption_test_case_3),
16021 TEST_CASE_ST(ut_setup, ut_teardown,
16022 test_kasumi_decryption_test_case_4),
16023 TEST_CASE_ST(ut_setup, ut_teardown,
16024 test_kasumi_decryption_test_case_5),
16025 TEST_CASE_ST(ut_setup, ut_teardown,
16026 test_kasumi_decryption_test_case_1_oop),
16027 TEST_CASE_ST(ut_setup, ut_teardown,
16028 test_kasumi_cipher_auth_test_case_1),
16030 /** KASUMI generate auth, then encrypt (F8) */
16031 TEST_CASE_ST(ut_setup, ut_teardown,
16032 test_kasumi_auth_cipher_test_case_1),
16033 TEST_CASE_ST(ut_setup, ut_teardown,
16034 test_kasumi_auth_cipher_test_case_2),
16035 TEST_CASE_ST(ut_setup, ut_teardown,
16036 test_kasumi_auth_cipher_test_case_2_oop),
16037 TEST_CASE_ST(ut_setup, ut_teardown,
16038 test_kasumi_auth_cipher_test_case_2_sgl),
16039 TEST_CASE_ST(ut_setup, ut_teardown,
16040 test_kasumi_auth_cipher_test_case_2_oop_sgl),
16042 /** KASUMI decrypt (F8), then verify auth */
16043 TEST_CASE_ST(ut_setup, ut_teardown,
16044 test_kasumi_auth_cipher_verify_test_case_1),
16045 TEST_CASE_ST(ut_setup, ut_teardown,
16046 test_kasumi_auth_cipher_verify_test_case_2),
16047 TEST_CASE_ST(ut_setup, ut_teardown,
16048 test_kasumi_auth_cipher_verify_test_case_2_oop),
16049 TEST_CASE_ST(ut_setup, ut_teardown,
16050 test_kasumi_auth_cipher_verify_test_case_2_sgl),
16051 TEST_CASE_ST(ut_setup, ut_teardown,
16052 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
16058 static struct unit_test_suite cryptodev_esn_testsuite = {
16059 .suite_name = "ESN Test Suite",
16060 .setup = esn_testsuite_setup,
16061 .unit_test_cases = {
16062 TEST_CASE_ST(ut_setup, ut_teardown,
16063 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
16064 TEST_CASE_ST(ut_setup, ut_teardown,
16065 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
16070 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
16071 .suite_name = "Negative AES GCM Test Suite",
16072 .setup = negative_aes_gcm_testsuite_setup,
16073 .unit_test_cases = {
16074 TEST_CASE_ST(ut_setup, ut_teardown,
16075 test_AES_GCM_auth_encryption_fail_iv_corrupt),
16076 TEST_CASE_ST(ut_setup, ut_teardown,
16077 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
16078 TEST_CASE_ST(ut_setup, ut_teardown,
16079 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
16080 TEST_CASE_ST(ut_setup, ut_teardown,
16081 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
16082 TEST_CASE_ST(ut_setup, ut_teardown,
16083 test_AES_GCM_auth_encryption_fail_aad_corrupt),
16084 TEST_CASE_ST(ut_setup, ut_teardown,
16085 test_AES_GCM_auth_encryption_fail_tag_corrupt),
16086 TEST_CASE_ST(ut_setup, ut_teardown,
16087 test_AES_GCM_auth_decryption_fail_iv_corrupt),
16088 TEST_CASE_ST(ut_setup, ut_teardown,
16089 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
16090 TEST_CASE_ST(ut_setup, ut_teardown,
16091 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
16092 TEST_CASE_ST(ut_setup, ut_teardown,
16093 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
16094 TEST_CASE_ST(ut_setup, ut_teardown,
16095 test_AES_GCM_auth_decryption_fail_aad_corrupt),
16096 TEST_CASE_ST(ut_setup, ut_teardown,
16097 test_AES_GCM_auth_decryption_fail_tag_corrupt),
16103 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
16104 .suite_name = "Negative AES GMAC Test Suite",
16105 .setup = negative_aes_gmac_testsuite_setup,
16106 .unit_test_cases = {
16107 TEST_CASE_ST(ut_setup, ut_teardown,
16108 authentication_verify_AES128_GMAC_fail_data_corrupt),
16109 TEST_CASE_ST(ut_setup, ut_teardown,
16110 authentication_verify_AES128_GMAC_fail_tag_corrupt),
16116 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
16117 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
16118 .setup = mixed_cipher_hash_testsuite_setup,
16119 .unit_test_cases = {
16120 /** AUTH AES CMAC + CIPHER AES CTR */
16121 TEST_CASE_ST(ut_setup, ut_teardown,
16122 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
16123 TEST_CASE_ST(ut_setup, ut_teardown,
16124 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16125 TEST_CASE_ST(ut_setup, ut_teardown,
16126 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16127 TEST_CASE_ST(ut_setup, ut_teardown,
16128 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16129 TEST_CASE_ST(ut_setup, ut_teardown,
16130 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
16131 TEST_CASE_ST(ut_setup, ut_teardown,
16132 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16133 TEST_CASE_ST(ut_setup, ut_teardown,
16134 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16135 TEST_CASE_ST(ut_setup, ut_teardown,
16136 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16138 /** AUTH ZUC + CIPHER SNOW3G */
16139 TEST_CASE_ST(ut_setup, ut_teardown,
16140 test_auth_zuc_cipher_snow_test_case_1),
16141 TEST_CASE_ST(ut_setup, ut_teardown,
16142 test_verify_auth_zuc_cipher_snow_test_case_1),
16143 /** AUTH AES CMAC + CIPHER SNOW3G */
16144 TEST_CASE_ST(ut_setup, ut_teardown,
16145 test_auth_aes_cmac_cipher_snow_test_case_1),
16146 TEST_CASE_ST(ut_setup, ut_teardown,
16147 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
16148 /** AUTH ZUC + CIPHER AES CTR */
16149 TEST_CASE_ST(ut_setup, ut_teardown,
16150 test_auth_zuc_cipher_aes_ctr_test_case_1),
16151 TEST_CASE_ST(ut_setup, ut_teardown,
16152 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
16153 /** AUTH SNOW3G + CIPHER AES CTR */
16154 TEST_CASE_ST(ut_setup, ut_teardown,
16155 test_auth_snow_cipher_aes_ctr_test_case_1),
16156 TEST_CASE_ST(ut_setup, ut_teardown,
16157 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
16158 /** AUTH SNOW3G + CIPHER ZUC */
16159 TEST_CASE_ST(ut_setup, ut_teardown,
16160 test_auth_snow_cipher_zuc_test_case_1),
16161 TEST_CASE_ST(ut_setup, ut_teardown,
16162 test_verify_auth_snow_cipher_zuc_test_case_1),
16163 /** AUTH AES CMAC + CIPHER ZUC */
16164 TEST_CASE_ST(ut_setup, ut_teardown,
16165 test_auth_aes_cmac_cipher_zuc_test_case_1),
16166 TEST_CASE_ST(ut_setup, ut_teardown,
16167 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
16169 /** AUTH NULL + CIPHER SNOW3G */
16170 TEST_CASE_ST(ut_setup, ut_teardown,
16171 test_auth_null_cipher_snow_test_case_1),
16172 TEST_CASE_ST(ut_setup, ut_teardown,
16173 test_verify_auth_null_cipher_snow_test_case_1),
16174 /** AUTH NULL + CIPHER ZUC */
16175 TEST_CASE_ST(ut_setup, ut_teardown,
16176 test_auth_null_cipher_zuc_test_case_1),
16177 TEST_CASE_ST(ut_setup, ut_teardown,
16178 test_verify_auth_null_cipher_zuc_test_case_1),
16179 /** AUTH SNOW3G + CIPHER NULL */
16180 TEST_CASE_ST(ut_setup, ut_teardown,
16181 test_auth_snow_cipher_null_test_case_1),
16182 TEST_CASE_ST(ut_setup, ut_teardown,
16183 test_verify_auth_snow_cipher_null_test_case_1),
16184 /** AUTH ZUC + CIPHER NULL */
16185 TEST_CASE_ST(ut_setup, ut_teardown,
16186 test_auth_zuc_cipher_null_test_case_1),
16187 TEST_CASE_ST(ut_setup, ut_teardown,
16188 test_verify_auth_zuc_cipher_null_test_case_1),
16189 /** AUTH NULL + CIPHER AES CTR */
16190 TEST_CASE_ST(ut_setup, ut_teardown,
16191 test_auth_null_cipher_aes_ctr_test_case_1),
16192 TEST_CASE_ST(ut_setup, ut_teardown,
16193 test_verify_auth_null_cipher_aes_ctr_test_case_1),
16194 /** AUTH AES CMAC + CIPHER NULL */
16195 TEST_CASE_ST(ut_setup, ut_teardown,
16196 test_auth_aes_cmac_cipher_null_test_case_1),
16197 TEST_CASE_ST(ut_setup, ut_teardown,
16198 test_verify_auth_aes_cmac_cipher_null_test_case_1),
16204 run_cryptodev_testsuite(const char *pmd_name)
16206 uint8_t ret, j, i = 0, blk_start_idx = 0;
16207 const enum blockcipher_test_type blk_suites[] = {
16208 BLKCIPHER_AES_CHAIN_TYPE,
16209 BLKCIPHER_AES_CIPHERONLY_TYPE,
16210 BLKCIPHER_AES_DOCSIS_TYPE,
16211 BLKCIPHER_3DES_CHAIN_TYPE,
16212 BLKCIPHER_3DES_CIPHERONLY_TYPE,
16213 BLKCIPHER_DES_CIPHERONLY_TYPE,
16214 BLKCIPHER_DES_DOCSIS_TYPE,
16215 BLKCIPHER_AUTHONLY_TYPE};
16216 struct unit_test_suite *static_suites[] = {
16217 &cryptodev_multi_session_testsuite,
16218 &cryptodev_null_testsuite,
16219 &cryptodev_aes_ccm_auth_testsuite,
16220 &cryptodev_aes_gcm_auth_testsuite,
16221 &cryptodev_aes_gmac_auth_testsuite,
16222 &cryptodev_snow3g_testsuite,
16223 &cryptodev_chacha20_poly1305_testsuite,
16224 &cryptodev_zuc_testsuite,
16225 &cryptodev_hmac_md5_auth_testsuite,
16226 &cryptodev_kasumi_testsuite,
16227 &cryptodev_esn_testsuite,
16228 &cryptodev_negative_aes_gcm_testsuite,
16229 &cryptodev_negative_aes_gmac_testsuite,
16230 &cryptodev_mixed_cipher_hash_testsuite,
16231 &cryptodev_negative_hmac_sha1_testsuite,
16232 &cryptodev_gen_testsuite,
16233 #ifdef RTE_LIB_SECURITY
16234 &ipsec_proto_testsuite,
16235 &pdcp_proto_testsuite,
16236 &docsis_proto_testsuite,
16240 static struct unit_test_suite ts = {
16241 .suite_name = "Cryptodev Unit Test Suite",
16242 .setup = testsuite_setup,
16243 .teardown = testsuite_teardown,
16244 .unit_test_cases = {TEST_CASES_END()}
16247 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
16249 if (gbl_driver_id == -1) {
16250 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
16251 return TEST_SKIPPED;
16254 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16255 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
16257 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
16258 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16259 ret = unit_test_suite_runner(&ts);
16261 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
16262 free(ts.unit_test_suites);
16267 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
16269 struct rte_cryptodev_info dev_info;
16270 uint8_t i, nb_devs;
16273 driver_id = rte_cryptodev_driver_id_get(pmd_name);
16274 if (driver_id == -1) {
16275 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
16276 return TEST_SKIPPED;
16279 nb_devs = rte_cryptodev_count();
16281 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
16282 return TEST_SKIPPED;
16285 for (i = 0; i < nb_devs; i++) {
16286 rte_cryptodev_info_get(i, &dev_info);
16287 if (dev_info.driver_id == driver_id) {
16288 if (!(dev_info.feature_flags & flag)) {
16289 RTE_LOG(INFO, USER1, "%s not supported\n",
16291 return TEST_SKIPPED;
16293 return 0; /* found */
16297 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
16298 return TEST_SKIPPED;
16302 test_cryptodev_qat(void)
16304 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
16308 test_cryptodev_virtio(void)
16310 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
16314 test_cryptodev_aesni_mb(void)
16316 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16320 test_cryptodev_cpu_aesni_mb(void)
16323 enum rte_security_session_action_type at = gbl_action_type;
16324 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16325 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16326 gbl_action_type = at;
16331 test_cryptodev_chacha_poly_mb(void)
16334 enum rte_security_session_action_type at = gbl_action_type;
16335 rc = run_cryptodev_testsuite(
16336 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
16337 gbl_action_type = at;
16342 test_cryptodev_openssl(void)
16344 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
16348 test_cryptodev_aesni_gcm(void)
16350 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16354 test_cryptodev_cpu_aesni_gcm(void)
16357 enum rte_security_session_action_type at = gbl_action_type;
16358 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16359 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16360 gbl_action_type = at;
16365 test_cryptodev_mlx5(void)
16367 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
16371 test_cryptodev_null(void)
16373 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
16377 test_cryptodev_sw_snow3g(void)
16379 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
16383 test_cryptodev_sw_kasumi(void)
16385 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
16389 test_cryptodev_sw_zuc(void)
16391 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
16395 test_cryptodev_armv8(void)
16397 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
16401 test_cryptodev_mrvl(void)
16403 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
16406 #ifdef RTE_CRYPTO_SCHEDULER
16409 test_cryptodev_scheduler(void)
16411 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
16412 const enum blockcipher_test_type blk_suites[] = {
16413 BLKCIPHER_AES_CHAIN_TYPE,
16414 BLKCIPHER_AES_CIPHERONLY_TYPE,
16415 BLKCIPHER_AUTHONLY_TYPE
16417 static struct unit_test_suite scheduler_multicore = {
16418 .suite_name = "Scheduler Multicore Unit Test Suite",
16419 .setup = scheduler_multicore_testsuite_setup,
16420 .teardown = scheduler_mode_testsuite_teardown,
16421 .unit_test_cases = {TEST_CASES_END()}
16423 static struct unit_test_suite scheduler_round_robin = {
16424 .suite_name = "Scheduler Round Robin Unit Test Suite",
16425 .setup = scheduler_roundrobin_testsuite_setup,
16426 .teardown = scheduler_mode_testsuite_teardown,
16427 .unit_test_cases = {TEST_CASES_END()}
16429 static struct unit_test_suite scheduler_failover = {
16430 .suite_name = "Scheduler Failover Unit Test Suite",
16431 .setup = scheduler_failover_testsuite_setup,
16432 .teardown = scheduler_mode_testsuite_teardown,
16433 .unit_test_cases = {TEST_CASES_END()}
16435 static struct unit_test_suite scheduler_pkt_size_distr = {
16436 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
16437 .setup = scheduler_pkt_size_distr_testsuite_setup,
16438 .teardown = scheduler_mode_testsuite_teardown,
16439 .unit_test_cases = {TEST_CASES_END()}
16441 struct unit_test_suite *sched_mode_suites[] = {
16442 &scheduler_multicore,
16443 &scheduler_round_robin,
16444 &scheduler_failover,
16445 &scheduler_pkt_size_distr
16447 static struct unit_test_suite scheduler_config = {
16448 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
16449 .unit_test_cases = {
16450 TEST_CASE(test_scheduler_attach_worker_op),
16451 TEST_CASE(test_scheduler_mode_multicore_op),
16452 TEST_CASE(test_scheduler_mode_roundrobin_op),
16453 TEST_CASE(test_scheduler_mode_failover_op),
16454 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
16455 TEST_CASE(test_scheduler_detach_worker_op),
16457 TEST_CASES_END() /**< NULL terminate array */
16460 struct unit_test_suite *static_suites[] = {
16464 static struct unit_test_suite ts = {
16465 .suite_name = "Scheduler Unit Test Suite",
16466 .setup = scheduler_testsuite_setup,
16467 .teardown = testsuite_teardown,
16468 .unit_test_cases = {TEST_CASES_END()}
16471 gbl_driver_id = rte_cryptodev_driver_id_get(
16472 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16474 if (gbl_driver_id == -1) {
16475 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
16476 return TEST_SKIPPED;
16479 if (rte_cryptodev_driver_id_get(
16480 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
16481 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
16482 return TEST_SKIPPED;
16485 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16487 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
16488 (struct unit_test_suite *) *
16489 (RTE_DIM(blk_suites) + 1));
16490 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
16491 blk_suites, RTE_DIM(blk_suites));
16492 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
16495 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16496 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
16497 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
16498 RTE_DIM(sched_mode_suites));
16499 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16500 ret = unit_test_suite_runner(&ts);
16502 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16503 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
16504 (*sched_mode_suites[sched_i]),
16505 RTE_DIM(blk_suites));
16506 free(sched_mode_suites[sched_i]->unit_test_suites);
16508 free(ts.unit_test_suites);
16512 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
16517 test_cryptodev_dpaa2_sec(void)
16519 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
16523 test_cryptodev_dpaa_sec(void)
16525 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
16529 test_cryptodev_ccp(void)
16531 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
16535 test_cryptodev_octeontx(void)
16537 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
16541 test_cryptodev_caam_jr(void)
16543 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
16547 test_cryptodev_nitrox(void)
16549 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
16553 test_cryptodev_bcmfs(void)
16555 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
16559 test_cryptodev_qat_raw_api(void)
16561 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16564 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16569 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16570 ret = run_cryptodev_testsuite(pmd_name);
16571 global_api_test_type = CRYPTODEV_API_TEST;
16577 test_cryptodev_cn9k(void)
16579 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16583 test_cryptodev_cn10k(void)
16585 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16589 test_cryptodev_dpaa2_sec_raw_api(void)
16591 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16594 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16599 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16600 ret = run_cryptodev_testsuite(pmd_name);
16601 global_api_test_type = CRYPTODEV_API_TEST;
16607 test_cryptodev_dpaa_sec_raw_api(void)
16609 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD);
16612 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16617 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16618 ret = run_cryptodev_testsuite(pmd_name);
16619 global_api_test_type = CRYPTODEV_API_TEST;
16624 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16625 test_cryptodev_dpaa2_sec_raw_api);
16626 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16627 test_cryptodev_dpaa_sec_raw_api);
16628 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16629 test_cryptodev_qat_raw_api);
16630 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16631 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16632 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16633 test_cryptodev_cpu_aesni_mb);
16634 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16635 test_cryptodev_chacha_poly_mb);
16636 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16637 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16638 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16639 test_cryptodev_cpu_aesni_gcm);
16640 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16641 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16642 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16643 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16644 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16645 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16646 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16647 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16648 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16649 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16650 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16651 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16652 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16653 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16654 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16655 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16656 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
16658 #endif /* !RTE_EXEC_ENV_WINDOWS */