1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* Stop the device in case it's started so it can be configured */
771 rte_cryptodev_stop(ts_params->valid_devs[0]);
773 /* valid - max value queue pairs */
774 ts_params->conf.nb_queue_pairs = orig_nb_qps;
776 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
778 "Failed to configure cryptodev: dev_id %u, qp_id %u",
779 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
781 /* valid - one queue pairs */
782 ts_params->conf.nb_queue_pairs = 1;
784 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
786 "Failed to configure cryptodev: dev_id %u, qp_id %u",
787 ts_params->valid_devs[0],
788 ts_params->conf.nb_queue_pairs);
791 /* invalid - zero queue pairs */
792 ts_params->conf.nb_queue_pairs = 0;
794 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
796 "Failed test for rte_cryptodev_configure, dev_id %u,"
798 ts_params->valid_devs[0],
799 ts_params->conf.nb_queue_pairs);
802 /* invalid - max value supported by field queue pairs */
803 ts_params->conf.nb_queue_pairs = UINT16_MAX;
805 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
807 "Failed test for rte_cryptodev_configure, dev_id %u,"
809 ts_params->valid_devs[0],
810 ts_params->conf.nb_queue_pairs);
813 /* invalid - max value + 1 queue pairs */
814 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
816 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
818 "Failed test for rte_cryptodev_configure, dev_id %u,"
820 ts_params->valid_devs[0],
821 ts_params->conf.nb_queue_pairs);
823 /* revert to original testsuite value */
824 ts_params->conf.nb_queue_pairs = orig_nb_qps;
830 test_queue_pair_descriptor_setup(void)
832 struct crypto_testsuite_params *ts_params = &testsuite_params;
833 struct rte_cryptodev_qp_conf qp_conf = {
834 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
838 /* Stop the device in case it's started so it can be configured */
839 rte_cryptodev_stop(ts_params->valid_devs[0]);
841 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
843 "Failed to configure cryptodev %u",
844 ts_params->valid_devs[0]);
847 * Test various ring sizes on this device. memzones can't be
848 * freed so are re-used if ring is released and re-created.
850 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
851 qp_conf.mp_session = ts_params->session_mpool;
852 qp_conf.mp_session_private = ts_params->session_priv_mpool;
854 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
856 ts_params->valid_devs[0], qp_id, &qp_conf,
857 rte_cryptodev_socket_id(
858 ts_params->valid_devs[0])),
860 "rte_cryptodev_queue_pair_setup: num_inflights "
861 "%u on qp %u on cryptodev %u",
862 qp_conf.nb_descriptors, qp_id,
863 ts_params->valid_devs[0]);
866 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
868 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
869 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
870 ts_params->valid_devs[0], qp_id, &qp_conf,
871 rte_cryptodev_socket_id(
872 ts_params->valid_devs[0])),
874 " rte_cryptodev_queue_pair_setup: num_inflights"
875 " %u on qp %u on cryptodev %u",
876 qp_conf.nb_descriptors, qp_id,
877 ts_params->valid_devs[0]);
880 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
882 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
883 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
884 ts_params->valid_devs[0], qp_id, &qp_conf,
885 rte_cryptodev_socket_id(
886 ts_params->valid_devs[0])),
888 "rte_cryptodev_queue_pair_setup: num_inflights"
889 " %u on qp %u on cryptodev %u",
890 qp_conf.nb_descriptors, qp_id,
891 ts_params->valid_devs[0]);
894 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
896 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
897 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
898 ts_params->valid_devs[0], qp_id, &qp_conf,
899 rte_cryptodev_socket_id(
900 ts_params->valid_devs[0])),
902 " rte_cryptodev_queue_pair_setup:"
903 "num_inflights %u on qp %u on cryptodev %u",
904 qp_conf.nb_descriptors, qp_id,
905 ts_params->valid_devs[0]);
908 /* test invalid queue pair id */
909 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
911 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
913 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
914 ts_params->valid_devs[0],
916 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
917 "Failed test for rte_cryptodev_queue_pair_setup:"
918 "invalid qp %u on cryptodev %u",
919 qp_id, ts_params->valid_devs[0]);
921 qp_id = 0xffff; /*invalid*/
923 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
924 ts_params->valid_devs[0],
926 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
927 "Failed test for rte_cryptodev_queue_pair_setup:"
928 "invalid qp %u on cryptodev %u",
929 qp_id, ts_params->valid_devs[0]);
934 /* ***** Plaintext data for tests ***** */
936 const char catch_22_quote_1[] =
937 "There was only one catch and that was Catch-22, which "
938 "specified that a concern for one's safety in the face of "
939 "dangers that were real and immediate was the process of a "
940 "rational mind. Orr was crazy and could be grounded. All he "
941 "had to do was ask; and as soon as he did, he would no longer "
942 "be crazy and would have to fly more missions. Orr would be "
943 "crazy to fly more missions and sane if he didn't, but if he "
944 "was sane he had to fly them. If he flew them he was crazy "
945 "and didn't have to; but if he didn't want to he was sane and "
946 "had to. Yossarian was moved very deeply by the absolute "
947 "simplicity of this clause of Catch-22 and let out a "
948 "respectful whistle. \"That's some catch, that Catch-22\", he "
949 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
951 const char catch_22_quote[] =
952 "What a lousy earth! He wondered how many people were "
953 "destitute that same night even in his own prosperous country, "
954 "how many homes were shanties, how many husbands were drunk "
955 "and wives socked, and how many children were bullied, abused, "
956 "or abandoned. How many families hungered for food they could "
957 "not afford to buy? How many hearts were broken? How many "
958 "suicides would take place that same night, how many people "
959 "would go insane? How many cockroaches and landlords would "
960 "triumph? How many winners were losers, successes failures, "
961 "and rich men poor men? How many wise guys were stupid? How "
962 "many happy endings were unhappy endings? How many honest men "
963 "were liars, brave men cowards, loyal men traitors, how many "
964 "sainted men were corrupt, how many people in positions of "
965 "trust had sold their souls to bodyguards, how many had never "
966 "had souls? How many straight-and-narrow paths were crooked "
967 "paths? How many best families were worst families and how "
968 "many good people were bad people? When you added them all up "
969 "and then subtracted, you might be left with only the children, "
970 "and perhaps with Albert Einstein and an old violinist or "
971 "sculptor somewhere.";
973 #define QUOTE_480_BYTES (480)
974 #define QUOTE_512_BYTES (512)
975 #define QUOTE_768_BYTES (768)
976 #define QUOTE_1024_BYTES (1024)
980 /* ***** SHA1 Hash Tests ***** */
982 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
984 static uint8_t hmac_sha1_key[] = {
985 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
986 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
987 0xDE, 0xF4, 0xDE, 0xAD };
989 /* ***** SHA224 Hash Tests ***** */
991 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
994 /* ***** AES-CBC Cipher Tests ***** */
996 #define CIPHER_KEY_LENGTH_AES_CBC (16)
997 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
999 static uint8_t aes_cbc_key[] = {
1000 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1001 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1003 static uint8_t aes_cbc_iv[] = {
1004 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1005 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1008 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1010 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1011 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1012 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1013 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1014 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1015 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1016 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1017 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1018 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1019 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1020 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1021 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1022 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1023 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1024 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1025 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1026 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1027 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1028 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1029 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1030 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1031 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1032 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1033 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1034 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1035 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1036 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1037 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1038 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1039 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1040 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1041 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1042 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1043 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1044 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1045 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1046 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1047 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1048 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1049 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1050 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1051 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1052 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1053 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1054 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1055 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1056 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1057 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1058 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1059 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1060 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1061 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1062 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1063 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1064 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1065 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1066 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1067 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1068 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1069 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1070 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1071 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1072 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1073 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1074 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1077 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1078 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1079 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1080 0x18, 0x8c, 0x1d, 0x32
1084 /* Multisession Vector context Test */
1085 /*Begin Session 0 */
1086 static uint8_t ms_aes_cbc_key0[] = {
1087 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1088 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1091 static uint8_t ms_aes_cbc_iv0[] = {
1092 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1093 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1096 static const uint8_t ms_aes_cbc_cipher0[] = {
1097 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1098 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1099 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1100 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1101 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1102 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1103 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1104 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1105 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1106 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1107 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1108 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1109 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1110 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1111 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1112 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1113 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1114 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1115 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1116 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1117 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1118 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1119 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1120 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1121 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1122 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1123 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1124 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1125 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1126 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1127 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1128 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1129 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1130 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1131 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1132 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1133 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1134 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1135 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1136 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1137 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1138 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1139 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1140 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1141 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1142 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1143 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1144 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1145 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1146 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1147 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1148 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1149 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1150 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1151 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1152 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1153 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1154 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1155 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1156 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1157 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1158 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1159 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1160 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1164 static uint8_t ms_hmac_key0[] = {
1165 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1166 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1167 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1168 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1169 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1170 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1171 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1172 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1175 static const uint8_t ms_hmac_digest0[] = {
1176 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1177 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1178 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1179 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1180 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1181 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1182 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1183 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1187 /* Begin session 1 */
1189 static uint8_t ms_aes_cbc_key1[] = {
1190 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1191 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1194 static uint8_t ms_aes_cbc_iv1[] = {
1195 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1196 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1199 static const uint8_t ms_aes_cbc_cipher1[] = {
1200 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1201 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1202 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1203 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1204 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1205 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1206 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1207 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1208 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1209 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1210 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1211 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1212 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1213 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1214 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1215 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1216 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1217 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1218 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1219 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1220 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1221 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1222 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1223 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1224 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1225 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1226 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1227 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1228 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1229 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1230 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1231 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1232 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1233 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1234 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1235 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1236 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1237 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1238 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1239 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1240 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1241 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1242 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1243 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1244 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1245 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1246 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1247 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1248 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1249 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1250 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1251 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1252 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1253 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1254 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1255 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1256 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1257 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1258 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1259 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1260 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1261 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1262 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1263 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1267 static uint8_t ms_hmac_key1[] = {
1268 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1269 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1270 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1271 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1272 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1273 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1274 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1275 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1278 static const uint8_t ms_hmac_digest1[] = {
1279 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1280 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1281 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1282 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1283 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1284 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1285 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1286 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1289 /* Begin Session 2 */
1290 static uint8_t ms_aes_cbc_key2[] = {
1291 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1292 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1295 static uint8_t ms_aes_cbc_iv2[] = {
1296 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1297 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1300 static const uint8_t ms_aes_cbc_cipher2[] = {
1301 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1302 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1303 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1304 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1305 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1306 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1307 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1308 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1309 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1310 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1311 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1312 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1313 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1314 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1315 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1316 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1317 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1318 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1319 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1320 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1321 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1322 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1323 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1324 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1325 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1326 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1327 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1328 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1329 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1330 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1331 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1332 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1333 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1334 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1335 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1336 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1337 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1338 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1339 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1340 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1341 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1342 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1343 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1344 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1345 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1346 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1347 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1348 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1349 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1350 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1351 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1352 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1353 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1354 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1355 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1356 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1357 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1358 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1359 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1360 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1361 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1362 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1363 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1364 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1367 static uint8_t ms_hmac_key2[] = {
1368 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1369 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1370 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1371 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1372 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1373 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1374 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1375 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1378 static const uint8_t ms_hmac_digest2[] = {
1379 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1380 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1381 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1382 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1383 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1384 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1385 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1386 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1393 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1395 struct crypto_testsuite_params *ts_params = &testsuite_params;
1396 struct crypto_unittest_params *ut_params = &unittest_params;
1398 /* Verify the capabilities */
1399 struct rte_cryptodev_sym_capability_idx cap_idx;
1400 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1401 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1402 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1405 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1406 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1407 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1411 /* Generate test mbuf data and space for digest */
1412 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1413 catch_22_quote, QUOTE_512_BYTES, 0);
1415 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1416 DIGEST_BYTE_LENGTH_SHA1);
1417 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1419 /* Setup Cipher Parameters */
1420 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1421 ut_params->cipher_xform.next = &ut_params->auth_xform;
1423 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1424 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1425 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1426 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1427 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1428 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1430 /* Setup HMAC Parameters */
1431 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1433 ut_params->auth_xform.next = NULL;
1435 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1436 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1437 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1438 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1439 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1441 ut_params->sess = rte_cryptodev_sym_session_create(
1442 ts_params->session_mpool);
1444 /* Create crypto session*/
1445 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1446 ut_params->sess, &ut_params->cipher_xform,
1447 ts_params->session_priv_mpool);
1448 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1450 /* Generate crypto op data structure */
1451 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1452 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1453 TEST_ASSERT_NOT_NULL(ut_params->op,
1454 "Failed to allocate symmetric crypto operation struct");
1456 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1458 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1460 /* set crypto operation source mbuf */
1461 sym_op->m_src = ut_params->ibuf;
1463 /* Set crypto operation authentication parameters */
1464 sym_op->auth.digest.data = ut_params->digest;
1465 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1466 ut_params->ibuf, QUOTE_512_BYTES);
1468 sym_op->auth.data.offset = 0;
1469 sym_op->auth.data.length = QUOTE_512_BYTES;
1471 /* Copy IV at the end of the crypto operation */
1472 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1473 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1475 /* Set crypto operation cipher parameters */
1476 sym_op->cipher.data.offset = 0;
1477 sym_op->cipher.data.length = QUOTE_512_BYTES;
1479 /* Process crypto operation */
1480 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1481 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1484 TEST_ASSERT_NOT_NULL(
1485 process_crypto_request(ts_params->valid_devs[0],
1487 "failed to process sym crypto op");
1489 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1490 "crypto op processing failed");
1493 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1496 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1497 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1499 "ciphertext data not as expected");
1501 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1503 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1504 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1505 gbl_driver_id == rte_cryptodev_driver_id_get(
1506 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1507 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1508 DIGEST_BYTE_LENGTH_SHA1,
1509 "Generated digest data not as expected");
1511 return TEST_SUCCESS;
1514 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1516 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1518 static uint8_t hmac_sha512_key[] = {
1519 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1520 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1521 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1522 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1523 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1524 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1525 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1526 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1528 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1529 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1530 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1531 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1532 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1533 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1534 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1535 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1536 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1541 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1542 struct crypto_unittest_params *ut_params,
1543 uint8_t *cipher_key,
1547 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1548 struct crypto_unittest_params *ut_params,
1549 struct crypto_testsuite_params *ts_params,
1550 const uint8_t *cipher,
1551 const uint8_t *digest,
1556 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1557 struct crypto_unittest_params *ut_params,
1558 uint8_t *cipher_key,
1562 /* Setup Cipher Parameters */
1563 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1564 ut_params->cipher_xform.next = NULL;
1566 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1567 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1568 ut_params->cipher_xform.cipher.key.data = cipher_key;
1569 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1570 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1571 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1573 /* Setup HMAC Parameters */
1574 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1575 ut_params->auth_xform.next = &ut_params->cipher_xform;
1577 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1578 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1579 ut_params->auth_xform.auth.key.data = hmac_key;
1580 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1581 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1583 return TEST_SUCCESS;
1588 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1589 struct crypto_unittest_params *ut_params,
1590 struct crypto_testsuite_params *ts_params,
1591 const uint8_t *cipher,
1592 const uint8_t *digest,
1595 /* Generate test mbuf data and digest */
1596 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1599 QUOTE_512_BYTES, 0);
1601 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1602 DIGEST_BYTE_LENGTH_SHA512);
1603 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1605 rte_memcpy(ut_params->digest,
1607 DIGEST_BYTE_LENGTH_SHA512);
1609 /* Generate Crypto op data structure */
1610 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1611 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1612 TEST_ASSERT_NOT_NULL(ut_params->op,
1613 "Failed to allocate symmetric crypto operation struct");
1615 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1617 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1619 /* set crypto operation source mbuf */
1620 sym_op->m_src = ut_params->ibuf;
1622 sym_op->auth.digest.data = ut_params->digest;
1623 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1624 ut_params->ibuf, QUOTE_512_BYTES);
1626 sym_op->auth.data.offset = 0;
1627 sym_op->auth.data.length = QUOTE_512_BYTES;
1629 /* Copy IV at the end of the crypto operation */
1630 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1631 iv, CIPHER_IV_LENGTH_AES_CBC);
1633 sym_op->cipher.data.offset = 0;
1634 sym_op->cipher.data.length = QUOTE_512_BYTES;
1636 /* Process crypto operation */
1637 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1638 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1641 TEST_ASSERT_NOT_NULL(
1642 process_crypto_request(ts_params->valid_devs[0],
1644 "failed to process sym crypto op");
1646 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1647 "crypto op processing failed");
1649 ut_params->obuf = ut_params->op->sym->m_src;
1652 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1653 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1656 "Plaintext data not as expected");
1659 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1660 "Digest verification failed");
1662 return TEST_SUCCESS;
1666 test_blockcipher(enum blockcipher_test_type test_type)
1668 struct crypto_testsuite_params *ts_params = &testsuite_params;
1671 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1672 ts_params->op_mpool,
1673 ts_params->session_mpool, ts_params->session_priv_mpool,
1674 ts_params->valid_devs[0],
1677 if (status == -ENOTSUP)
1680 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1682 return TEST_SUCCESS;
1686 test_AES_cipheronly_all(void)
1688 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1692 test_AES_docsis_all(void)
1694 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1698 test_DES_docsis_all(void)
1700 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1704 test_DES_cipheronly_all(void)
1706 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1710 test_authonly_all(void)
1712 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1716 test_AES_chain_all(void)
1718 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1722 test_3DES_chain_all(void)
1724 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1728 test_3DES_cipheronly_all(void)
1730 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1733 /* ***** SNOW 3G Tests ***** */
1735 create_wireless_algo_hash_session(uint8_t dev_id,
1736 const uint8_t *key, const uint8_t key_len,
1737 const uint8_t iv_len, const uint8_t auth_len,
1738 enum rte_crypto_auth_operation op,
1739 enum rte_crypto_auth_algorithm algo)
1741 uint8_t hash_key[key_len];
1744 struct crypto_testsuite_params *ts_params = &testsuite_params;
1745 struct crypto_unittest_params *ut_params = &unittest_params;
1747 memcpy(hash_key, key, key_len);
1749 debug_hexdump(stdout, "key:", key, key_len);
1751 /* Setup Authentication Parameters */
1752 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1753 ut_params->auth_xform.next = NULL;
1755 ut_params->auth_xform.auth.op = op;
1756 ut_params->auth_xform.auth.algo = algo;
1757 ut_params->auth_xform.auth.key.length = key_len;
1758 ut_params->auth_xform.auth.key.data = hash_key;
1759 ut_params->auth_xform.auth.digest_length = auth_len;
1760 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1761 ut_params->auth_xform.auth.iv.length = iv_len;
1762 ut_params->sess = rte_cryptodev_sym_session_create(
1763 ts_params->session_mpool);
1765 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1766 &ut_params->auth_xform,
1767 ts_params->session_priv_mpool);
1768 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1769 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1774 create_wireless_algo_cipher_session(uint8_t dev_id,
1775 enum rte_crypto_cipher_operation op,
1776 enum rte_crypto_cipher_algorithm algo,
1777 const uint8_t *key, const uint8_t key_len,
1780 uint8_t cipher_key[key_len];
1782 struct crypto_testsuite_params *ts_params = &testsuite_params;
1783 struct crypto_unittest_params *ut_params = &unittest_params;
1785 memcpy(cipher_key, key, key_len);
1787 /* Setup Cipher Parameters */
1788 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1789 ut_params->cipher_xform.next = NULL;
1791 ut_params->cipher_xform.cipher.algo = algo;
1792 ut_params->cipher_xform.cipher.op = op;
1793 ut_params->cipher_xform.cipher.key.data = cipher_key;
1794 ut_params->cipher_xform.cipher.key.length = key_len;
1795 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1796 ut_params->cipher_xform.cipher.iv.length = iv_len;
1798 debug_hexdump(stdout, "key:", key, key_len);
1800 /* Create Crypto session */
1801 ut_params->sess = rte_cryptodev_sym_session_create(
1802 ts_params->session_mpool);
1804 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1805 &ut_params->cipher_xform,
1806 ts_params->session_priv_mpool);
1807 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1808 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1813 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1814 unsigned int cipher_len,
1815 unsigned int cipher_offset)
1817 struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 struct crypto_unittest_params *ut_params = &unittest_params;
1820 /* Generate Crypto op data structure */
1821 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1822 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1823 TEST_ASSERT_NOT_NULL(ut_params->op,
1824 "Failed to allocate pktmbuf offload");
1826 /* Set crypto operation data parameters */
1827 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1829 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1831 /* set crypto operation source mbuf */
1832 sym_op->m_src = ut_params->ibuf;
1835 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1837 sym_op->cipher.data.length = cipher_len;
1838 sym_op->cipher.data.offset = cipher_offset;
1843 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1844 unsigned int cipher_len,
1845 unsigned int cipher_offset)
1847 struct crypto_testsuite_params *ts_params = &testsuite_params;
1848 struct crypto_unittest_params *ut_params = &unittest_params;
1850 /* Generate Crypto op data structure */
1851 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1852 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1853 TEST_ASSERT_NOT_NULL(ut_params->op,
1854 "Failed to allocate pktmbuf offload");
1856 /* Set crypto operation data parameters */
1857 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1859 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1861 /* set crypto operation source mbuf */
1862 sym_op->m_src = ut_params->ibuf;
1863 sym_op->m_dst = ut_params->obuf;
1866 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1868 sym_op->cipher.data.length = cipher_len;
1869 sym_op->cipher.data.offset = cipher_offset;
1874 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1875 enum rte_crypto_cipher_operation cipher_op,
1876 enum rte_crypto_auth_operation auth_op,
1877 enum rte_crypto_auth_algorithm auth_algo,
1878 enum rte_crypto_cipher_algorithm cipher_algo,
1879 const uint8_t *key, uint8_t key_len,
1880 uint8_t auth_iv_len, uint8_t auth_len,
1881 uint8_t cipher_iv_len)
1884 uint8_t cipher_auth_key[key_len];
1887 struct crypto_testsuite_params *ts_params = &testsuite_params;
1888 struct crypto_unittest_params *ut_params = &unittest_params;
1890 memcpy(cipher_auth_key, key, key_len);
1892 /* Setup Authentication Parameters */
1893 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1894 ut_params->auth_xform.next = NULL;
1896 ut_params->auth_xform.auth.op = auth_op;
1897 ut_params->auth_xform.auth.algo = auth_algo;
1898 ut_params->auth_xform.auth.key.length = key_len;
1899 /* Hash key = cipher key */
1900 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1901 ut_params->auth_xform.auth.digest_length = auth_len;
1902 /* Auth IV will be after cipher IV */
1903 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1904 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1906 /* Setup Cipher Parameters */
1907 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1908 ut_params->cipher_xform.next = &ut_params->auth_xform;
1910 ut_params->cipher_xform.cipher.algo = cipher_algo;
1911 ut_params->cipher_xform.cipher.op = cipher_op;
1912 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1913 ut_params->cipher_xform.cipher.key.length = key_len;
1914 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1915 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1917 debug_hexdump(stdout, "key:", key, key_len);
1919 /* Create Crypto session*/
1920 ut_params->sess = rte_cryptodev_sym_session_create(
1921 ts_params->session_mpool);
1922 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1924 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1925 &ut_params->cipher_xform,
1926 ts_params->session_priv_mpool);
1927 if (status == -ENOTSUP)
1930 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1935 create_wireless_cipher_auth_session(uint8_t dev_id,
1936 enum rte_crypto_cipher_operation cipher_op,
1937 enum rte_crypto_auth_operation auth_op,
1938 enum rte_crypto_auth_algorithm auth_algo,
1939 enum rte_crypto_cipher_algorithm cipher_algo,
1940 const struct wireless_test_data *tdata)
1942 const uint8_t key_len = tdata->key.len;
1943 uint8_t cipher_auth_key[key_len];
1946 struct crypto_testsuite_params *ts_params = &testsuite_params;
1947 struct crypto_unittest_params *ut_params = &unittest_params;
1948 const uint8_t *key = tdata->key.data;
1949 const uint8_t auth_len = tdata->digest.len;
1950 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1951 uint8_t auth_iv_len = tdata->auth_iv.len;
1953 memcpy(cipher_auth_key, key, key_len);
1955 /* Setup Authentication Parameters */
1956 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1957 ut_params->auth_xform.next = NULL;
1959 ut_params->auth_xform.auth.op = auth_op;
1960 ut_params->auth_xform.auth.algo = auth_algo;
1961 ut_params->auth_xform.auth.key.length = key_len;
1962 /* Hash key = cipher key */
1963 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1964 ut_params->auth_xform.auth.digest_length = auth_len;
1965 /* Auth IV will be after cipher IV */
1966 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1967 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1969 /* Setup Cipher Parameters */
1970 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1971 ut_params->cipher_xform.next = &ut_params->auth_xform;
1973 ut_params->cipher_xform.cipher.algo = cipher_algo;
1974 ut_params->cipher_xform.cipher.op = cipher_op;
1975 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1976 ut_params->cipher_xform.cipher.key.length = key_len;
1977 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1978 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1981 debug_hexdump(stdout, "key:", key, key_len);
1983 /* Create Crypto session*/
1984 ut_params->sess = rte_cryptodev_sym_session_create(
1985 ts_params->session_mpool);
1987 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1988 &ut_params->cipher_xform,
1989 ts_params->session_priv_mpool);
1990 if (status == -ENOTSUP)
1993 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1994 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1999 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2000 const struct wireless_test_data *tdata)
2002 return create_wireless_cipher_auth_session(dev_id,
2003 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2004 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2005 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2009 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2010 enum rte_crypto_cipher_operation cipher_op,
2011 enum rte_crypto_auth_operation auth_op,
2012 enum rte_crypto_auth_algorithm auth_algo,
2013 enum rte_crypto_cipher_algorithm cipher_algo,
2014 const uint8_t *key, const uint8_t key_len,
2015 uint8_t auth_iv_len, uint8_t auth_len,
2016 uint8_t cipher_iv_len)
2018 uint8_t auth_cipher_key[key_len];
2020 struct crypto_testsuite_params *ts_params = &testsuite_params;
2021 struct crypto_unittest_params *ut_params = &unittest_params;
2023 memcpy(auth_cipher_key, key, key_len);
2025 /* Setup Authentication Parameters */
2026 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2027 ut_params->auth_xform.auth.op = auth_op;
2028 ut_params->auth_xform.next = &ut_params->cipher_xform;
2029 ut_params->auth_xform.auth.algo = auth_algo;
2030 ut_params->auth_xform.auth.key.length = key_len;
2031 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2032 ut_params->auth_xform.auth.digest_length = auth_len;
2033 /* Auth IV will be after cipher IV */
2034 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2035 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2037 /* Setup Cipher Parameters */
2038 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2039 ut_params->cipher_xform.next = NULL;
2040 ut_params->cipher_xform.cipher.algo = cipher_algo;
2041 ut_params->cipher_xform.cipher.op = cipher_op;
2042 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2043 ut_params->cipher_xform.cipher.key.length = key_len;
2044 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2045 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2047 debug_hexdump(stdout, "key:", key, key_len);
2049 /* Create Crypto session*/
2050 ut_params->sess = rte_cryptodev_sym_session_create(
2051 ts_params->session_mpool);
2052 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2054 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2055 ut_params->auth_xform.next = NULL;
2056 ut_params->cipher_xform.next = &ut_params->auth_xform;
2057 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2058 &ut_params->cipher_xform,
2059 ts_params->session_priv_mpool);
2062 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2063 &ut_params->auth_xform,
2064 ts_params->session_priv_mpool);
2066 if (status == -ENOTSUP)
2069 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2075 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2076 unsigned int auth_tag_len,
2077 const uint8_t *iv, unsigned int iv_len,
2078 unsigned int data_pad_len,
2079 enum rte_crypto_auth_operation op,
2080 unsigned int auth_len, unsigned int auth_offset)
2082 struct crypto_testsuite_params *ts_params = &testsuite_params;
2084 struct crypto_unittest_params *ut_params = &unittest_params;
2086 /* Generate Crypto op data structure */
2087 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2088 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2089 TEST_ASSERT_NOT_NULL(ut_params->op,
2090 "Failed to allocate pktmbuf offload");
2092 /* Set crypto operation data parameters */
2093 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2095 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2097 /* set crypto operation source mbuf */
2098 sym_op->m_src = ut_params->ibuf;
2101 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2104 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2105 ut_params->ibuf, auth_tag_len);
2107 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2108 "no room to append auth tag");
2109 ut_params->digest = sym_op->auth.digest.data;
2110 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2111 ut_params->ibuf, data_pad_len);
2112 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2113 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2115 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2117 debug_hexdump(stdout, "digest:",
2118 sym_op->auth.digest.data,
2121 sym_op->auth.data.length = auth_len;
2122 sym_op->auth.data.offset = auth_offset;
2128 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2129 enum rte_crypto_auth_operation op)
2131 struct crypto_testsuite_params *ts_params = &testsuite_params;
2132 struct crypto_unittest_params *ut_params = &unittest_params;
2134 const uint8_t *auth_tag = tdata->digest.data;
2135 const unsigned int auth_tag_len = tdata->digest.len;
2136 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2137 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2139 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2140 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2141 const uint8_t *auth_iv = tdata->auth_iv.data;
2142 const uint8_t auth_iv_len = tdata->auth_iv.len;
2143 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2144 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2146 /* Generate Crypto op data structure */
2147 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2148 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2149 TEST_ASSERT_NOT_NULL(ut_params->op,
2150 "Failed to allocate pktmbuf offload");
2151 /* Set crypto operation data parameters */
2152 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2154 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2156 /* set crypto operation source mbuf */
2157 sym_op->m_src = ut_params->ibuf;
2160 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2161 ut_params->ibuf, auth_tag_len);
2163 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2164 "no room to append auth tag");
2165 ut_params->digest = sym_op->auth.digest.data;
2166 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2167 ut_params->ibuf, data_pad_len);
2168 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2169 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2171 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2173 debug_hexdump(stdout, "digest:",
2174 sym_op->auth.digest.data,
2177 /* Copy cipher and auth IVs at the end of the crypto operation */
2178 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2180 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2181 iv_ptr += cipher_iv_len;
2182 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2184 sym_op->cipher.data.length = cipher_len;
2185 sym_op->cipher.data.offset = 0;
2186 sym_op->auth.data.length = auth_len;
2187 sym_op->auth.data.offset = 0;
2193 create_zuc_cipher_hash_generate_operation(
2194 const struct wireless_test_data *tdata)
2196 return create_wireless_cipher_hash_operation(tdata,
2197 RTE_CRYPTO_AUTH_OP_GENERATE);
2201 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2202 const unsigned auth_tag_len,
2203 const uint8_t *auth_iv, uint8_t auth_iv_len,
2204 unsigned data_pad_len,
2205 enum rte_crypto_auth_operation op,
2206 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2207 const unsigned cipher_len, const unsigned cipher_offset,
2208 const unsigned auth_len, const unsigned auth_offset)
2210 struct crypto_testsuite_params *ts_params = &testsuite_params;
2211 struct crypto_unittest_params *ut_params = &unittest_params;
2213 enum rte_crypto_cipher_algorithm cipher_algo =
2214 ut_params->cipher_xform.cipher.algo;
2215 enum rte_crypto_auth_algorithm auth_algo =
2216 ut_params->auth_xform.auth.algo;
2218 /* Generate Crypto op data structure */
2219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2221 TEST_ASSERT_NOT_NULL(ut_params->op,
2222 "Failed to allocate pktmbuf offload");
2223 /* Set crypto operation data parameters */
2224 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2226 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2228 /* set crypto operation source mbuf */
2229 sym_op->m_src = ut_params->ibuf;
2232 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2233 ut_params->ibuf, auth_tag_len);
2235 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2236 "no room to append auth tag");
2237 ut_params->digest = sym_op->auth.digest.data;
2239 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2240 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2241 ut_params->ibuf, data_pad_len);
2243 struct rte_mbuf *m = ut_params->ibuf;
2244 unsigned int offset = data_pad_len;
2246 while (offset > m->data_len && m->next != NULL) {
2247 offset -= m->data_len;
2250 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2254 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2255 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2257 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2259 debug_hexdump(stdout, "digest:",
2260 sym_op->auth.digest.data,
2263 /* Copy cipher and auth IVs at the end of the crypto operation */
2264 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2266 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2267 iv_ptr += cipher_iv_len;
2268 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2270 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2271 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2272 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2273 sym_op->cipher.data.length = cipher_len;
2274 sym_op->cipher.data.offset = cipher_offset;
2276 sym_op->cipher.data.length = cipher_len >> 3;
2277 sym_op->cipher.data.offset = cipher_offset >> 3;
2280 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2281 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2282 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2283 sym_op->auth.data.length = auth_len;
2284 sym_op->auth.data.offset = auth_offset;
2286 sym_op->auth.data.length = auth_len >> 3;
2287 sym_op->auth.data.offset = auth_offset >> 3;
2294 create_wireless_algo_auth_cipher_operation(
2295 const uint8_t *auth_tag, unsigned int auth_tag_len,
2296 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2297 const uint8_t *auth_iv, uint8_t auth_iv_len,
2298 unsigned int data_pad_len,
2299 unsigned int cipher_len, unsigned int cipher_offset,
2300 unsigned int auth_len, unsigned int auth_offset,
2301 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2303 struct crypto_testsuite_params *ts_params = &testsuite_params;
2304 struct crypto_unittest_params *ut_params = &unittest_params;
2306 enum rte_crypto_cipher_algorithm cipher_algo =
2307 ut_params->cipher_xform.cipher.algo;
2308 enum rte_crypto_auth_algorithm auth_algo =
2309 ut_params->auth_xform.auth.algo;
2311 /* Generate Crypto op data structure */
2312 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2313 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2314 TEST_ASSERT_NOT_NULL(ut_params->op,
2315 "Failed to allocate pktmbuf offload");
2317 /* Set crypto operation data parameters */
2318 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2322 /* set crypto operation mbufs */
2323 sym_op->m_src = ut_params->ibuf;
2324 if (op_mode == OUT_OF_PLACE)
2325 sym_op->m_dst = ut_params->obuf;
2329 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2330 (op_mode == IN_PLACE ?
2331 ut_params->ibuf : ut_params->obuf),
2332 uint8_t *, data_pad_len);
2333 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2334 (op_mode == IN_PLACE ?
2335 ut_params->ibuf : ut_params->obuf),
2337 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2339 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2340 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2341 sym_op->m_src : sym_op->m_dst);
2342 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2343 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2344 sgl_buf = sgl_buf->next;
2346 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2347 uint8_t *, remaining_off);
2348 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2350 memset(sym_op->auth.digest.data, 0, remaining_off);
2351 while (sgl_buf->next != NULL) {
2352 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2353 0, rte_pktmbuf_data_len(sgl_buf));
2354 sgl_buf = sgl_buf->next;
2358 /* Copy digest for the verification */
2360 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2362 /* Copy cipher and auth IVs at the end of the crypto operation */
2363 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2364 ut_params->op, uint8_t *, IV_OFFSET);
2366 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2367 iv_ptr += cipher_iv_len;
2368 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2370 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2371 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2372 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2373 sym_op->cipher.data.length = cipher_len;
2374 sym_op->cipher.data.offset = cipher_offset;
2376 sym_op->cipher.data.length = cipher_len >> 3;
2377 sym_op->cipher.data.offset = cipher_offset >> 3;
2380 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2381 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2382 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2383 sym_op->auth.data.length = auth_len;
2384 sym_op->auth.data.offset = auth_offset;
2386 sym_op->auth.data.length = auth_len >> 3;
2387 sym_op->auth.data.offset = auth_offset >> 3;
2394 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2396 struct crypto_testsuite_params *ts_params = &testsuite_params;
2397 struct crypto_unittest_params *ut_params = &unittest_params;
2400 unsigned plaintext_pad_len;
2401 unsigned plaintext_len;
2403 struct rte_cryptodev_info dev_info;
2405 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2406 uint64_t feat_flags = dev_info.feature_flags;
2408 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2409 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2410 printf("Device doesn't support NON-Byte Aligned Data.\n");
2414 /* Verify the capabilities */
2415 struct rte_cryptodev_sym_capability_idx cap_idx;
2416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2417 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2422 /* Create SNOW 3G session */
2423 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2424 tdata->key.data, tdata->key.len,
2425 tdata->auth_iv.len, tdata->digest.len,
2426 RTE_CRYPTO_AUTH_OP_GENERATE,
2427 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2431 /* alloc mbuf and set payload */
2432 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2434 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2435 rte_pktmbuf_tailroom(ut_params->ibuf));
2437 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2438 /* Append data which is padded to a multiple of */
2439 /* the algorithms block size */
2440 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2441 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2443 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2445 /* Create SNOW 3G operation */
2446 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2447 tdata->auth_iv.data, tdata->auth_iv.len,
2448 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2449 tdata->validAuthLenInBits.len,
2454 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2456 ut_params->obuf = ut_params->op->sym->m_src;
2457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2458 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2459 + plaintext_pad_len;
2462 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2465 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2466 "SNOW 3G Generated auth tag not as expected");
2472 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2474 struct crypto_testsuite_params *ts_params = &testsuite_params;
2475 struct crypto_unittest_params *ut_params = &unittest_params;
2478 unsigned plaintext_pad_len;
2479 unsigned plaintext_len;
2481 struct rte_cryptodev_info dev_info;
2483 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2484 uint64_t feat_flags = dev_info.feature_flags;
2486 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2487 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2488 printf("Device doesn't support NON-Byte Aligned Data.\n");
2492 /* Verify the capabilities */
2493 struct rte_cryptodev_sym_capability_idx cap_idx;
2494 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2495 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2496 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2500 /* Create SNOW 3G session */
2501 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2502 tdata->key.data, tdata->key.len,
2503 tdata->auth_iv.len, tdata->digest.len,
2504 RTE_CRYPTO_AUTH_OP_VERIFY,
2505 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2508 /* alloc mbuf and set payload */
2509 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2511 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2512 rte_pktmbuf_tailroom(ut_params->ibuf));
2514 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2515 /* Append data which is padded to a multiple of */
2516 /* the algorithms block size */
2517 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2518 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2520 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2522 /* Create SNOW 3G operation */
2523 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2525 tdata->auth_iv.data, tdata->auth_iv.len,
2527 RTE_CRYPTO_AUTH_OP_VERIFY,
2528 tdata->validAuthLenInBits.len,
2533 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2535 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2536 ut_params->obuf = ut_params->op->sym->m_src;
2537 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2538 + plaintext_pad_len;
2541 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2550 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2552 struct crypto_testsuite_params *ts_params = &testsuite_params;
2553 struct crypto_unittest_params *ut_params = &unittest_params;
2556 unsigned plaintext_pad_len;
2557 unsigned plaintext_len;
2560 /* Verify the capabilities */
2561 struct rte_cryptodev_sym_capability_idx cap_idx;
2562 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2563 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2564 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2568 /* Create KASUMI session */
2569 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2570 tdata->key.data, tdata->key.len,
2571 0, tdata->digest.len,
2572 RTE_CRYPTO_AUTH_OP_GENERATE,
2573 RTE_CRYPTO_AUTH_KASUMI_F9);
2577 /* alloc mbuf and set payload */
2578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2581 rte_pktmbuf_tailroom(ut_params->ibuf));
2583 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2584 /* Append data which is padded to a multiple of */
2585 /* the algorithms block size */
2586 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2587 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2589 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2591 /* Create KASUMI operation */
2592 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2594 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2595 tdata->plaintext.len,
2600 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2601 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2604 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2607 ut_params->obuf = ut_params->op->sym->m_src;
2608 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2609 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2610 + plaintext_pad_len;
2613 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2616 DIGEST_BYTE_LENGTH_KASUMI_F9,
2617 "KASUMI Generated auth tag not as expected");
2623 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2625 struct crypto_testsuite_params *ts_params = &testsuite_params;
2626 struct crypto_unittest_params *ut_params = &unittest_params;
2629 unsigned plaintext_pad_len;
2630 unsigned plaintext_len;
2633 /* Verify the capabilities */
2634 struct rte_cryptodev_sym_capability_idx cap_idx;
2635 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2636 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2637 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2641 /* Create KASUMI session */
2642 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2643 tdata->key.data, tdata->key.len,
2644 0, tdata->digest.len,
2645 RTE_CRYPTO_AUTH_OP_VERIFY,
2646 RTE_CRYPTO_AUTH_KASUMI_F9);
2649 /* alloc mbuf and set payload */
2650 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2652 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2653 rte_pktmbuf_tailroom(ut_params->ibuf));
2655 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2656 /* Append data which is padded to a multiple */
2657 /* of the algorithms block size */
2658 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2659 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2661 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2663 /* Create KASUMI operation */
2664 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2668 RTE_CRYPTO_AUTH_OP_VERIFY,
2669 tdata->plaintext.len,
2674 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2677 ut_params->obuf = ut_params->op->sym->m_src;
2678 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2679 + plaintext_pad_len;
2682 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2691 test_snow3g_hash_generate_test_case_1(void)
2693 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2697 test_snow3g_hash_generate_test_case_2(void)
2699 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2703 test_snow3g_hash_generate_test_case_3(void)
2705 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2709 test_snow3g_hash_generate_test_case_4(void)
2711 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2715 test_snow3g_hash_generate_test_case_5(void)
2717 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2721 test_snow3g_hash_generate_test_case_6(void)
2723 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2727 test_snow3g_hash_verify_test_case_1(void)
2729 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2734 test_snow3g_hash_verify_test_case_2(void)
2736 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2740 test_snow3g_hash_verify_test_case_3(void)
2742 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2746 test_snow3g_hash_verify_test_case_4(void)
2748 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2752 test_snow3g_hash_verify_test_case_5(void)
2754 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2758 test_snow3g_hash_verify_test_case_6(void)
2760 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2764 test_kasumi_hash_generate_test_case_1(void)
2766 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2770 test_kasumi_hash_generate_test_case_2(void)
2772 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2776 test_kasumi_hash_generate_test_case_3(void)
2778 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2782 test_kasumi_hash_generate_test_case_4(void)
2784 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2788 test_kasumi_hash_generate_test_case_5(void)
2790 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2794 test_kasumi_hash_generate_test_case_6(void)
2796 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2800 test_kasumi_hash_verify_test_case_1(void)
2802 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2806 test_kasumi_hash_verify_test_case_2(void)
2808 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2812 test_kasumi_hash_verify_test_case_3(void)
2814 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2818 test_kasumi_hash_verify_test_case_4(void)
2820 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2824 test_kasumi_hash_verify_test_case_5(void)
2826 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2830 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2832 struct crypto_testsuite_params *ts_params = &testsuite_params;
2833 struct crypto_unittest_params *ut_params = &unittest_params;
2836 uint8_t *plaintext, *ciphertext;
2837 unsigned plaintext_pad_len;
2838 unsigned plaintext_len;
2840 /* Verify the capabilities */
2841 struct rte_cryptodev_sym_capability_idx cap_idx;
2842 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2843 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2844 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2848 /* Create KASUMI session */
2849 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2850 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2851 RTE_CRYPTO_CIPHER_KASUMI_F8,
2852 tdata->key.data, tdata->key.len,
2853 tdata->cipher_iv.len);
2857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2859 /* Clear mbuf payload */
2860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2861 rte_pktmbuf_tailroom(ut_params->ibuf));
2863 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2864 /* Append data which is padded to a multiple */
2865 /* of the algorithms block size */
2866 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2867 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2869 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2871 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2873 /* Create KASUMI operation */
2874 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2875 tdata->cipher_iv.len,
2876 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2877 tdata->validCipherOffsetInBits.len);
2881 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2885 ut_params->obuf = ut_params->op->sym->m_dst;
2886 if (ut_params->obuf)
2887 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2889 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2891 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2893 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2894 (tdata->validCipherOffsetInBits.len >> 3);
2896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2898 reference_ciphertext,
2899 tdata->validCipherLenInBits.len,
2900 "KASUMI Ciphertext data not as expected");
2905 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2907 struct crypto_testsuite_params *ts_params = &testsuite_params;
2908 struct crypto_unittest_params *ut_params = &unittest_params;
2912 unsigned int plaintext_pad_len;
2913 unsigned int plaintext_len;
2915 uint8_t buffer[10000];
2916 const uint8_t *ciphertext;
2918 struct rte_cryptodev_info dev_info;
2920 /* Verify the capabilities */
2921 struct rte_cryptodev_sym_capability_idx cap_idx;
2922 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2923 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2924 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2928 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2930 uint64_t feat_flags = dev_info.feature_flags;
2932 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2933 printf("Device doesn't support in-place scatter-gather. "
2938 /* Create KASUMI session */
2939 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2940 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2941 RTE_CRYPTO_CIPHER_KASUMI_F8,
2942 tdata->key.data, tdata->key.len,
2943 tdata->cipher_iv.len);
2947 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2950 /* Append data which is padded to a multiple */
2951 /* of the algorithms block size */
2952 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2954 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2955 plaintext_pad_len, 10, 0);
2957 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2959 /* Create KASUMI operation */
2960 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2961 tdata->cipher_iv.len,
2962 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2963 tdata->validCipherOffsetInBits.len);
2967 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2969 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2971 ut_params->obuf = ut_params->op->sym->m_dst;
2973 if (ut_params->obuf)
2974 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2975 plaintext_len, buffer);
2977 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2978 tdata->validCipherOffsetInBits.len >> 3,
2979 plaintext_len, buffer);
2982 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2984 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2985 (tdata->validCipherOffsetInBits.len >> 3);
2987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2989 reference_ciphertext,
2990 tdata->validCipherLenInBits.len,
2991 "KASUMI Ciphertext data not as expected");
2996 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 struct crypto_unittest_params *ut_params = &unittest_params;
3002 uint8_t *plaintext, *ciphertext;
3003 unsigned plaintext_pad_len;
3004 unsigned plaintext_len;
3006 /* Verify the capabilities */
3007 struct rte_cryptodev_sym_capability_idx cap_idx;
3008 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3009 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3010 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3014 /* Create KASUMI session */
3015 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3017 RTE_CRYPTO_CIPHER_KASUMI_F8,
3018 tdata->key.data, tdata->key.len,
3019 tdata->cipher_iv.len);
3023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3024 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3026 /* Clear mbuf payload */
3027 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3028 rte_pktmbuf_tailroom(ut_params->ibuf));
3030 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3031 /* Append data which is padded to a multiple */
3032 /* of the algorithms block size */
3033 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3034 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3036 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3037 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3039 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3041 /* Create KASUMI operation */
3042 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3043 tdata->cipher_iv.len,
3044 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3045 tdata->validCipherOffsetInBits.len);
3049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3051 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3053 ut_params->obuf = ut_params->op->sym->m_dst;
3054 if (ut_params->obuf)
3055 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3057 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3059 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3061 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3062 (tdata->validCipherOffsetInBits.len >> 3);
3064 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3066 reference_ciphertext,
3067 tdata->validCipherLenInBits.len,
3068 "KASUMI Ciphertext data not as expected");
3073 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3075 struct crypto_testsuite_params *ts_params = &testsuite_params;
3076 struct crypto_unittest_params *ut_params = &unittest_params;
3079 unsigned int plaintext_pad_len;
3080 unsigned int plaintext_len;
3082 const uint8_t *ciphertext;
3083 uint8_t buffer[2048];
3085 struct rte_cryptodev_info dev_info;
3087 /* Verify the capabilities */
3088 struct rte_cryptodev_sym_capability_idx cap_idx;
3089 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3090 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3091 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3095 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3097 uint64_t feat_flags = dev_info.feature_flags;
3098 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3099 printf("Device doesn't support out-of-place scatter-gather "
3100 "in both input and output mbufs. "
3105 /* Create KASUMI session */
3106 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3107 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3108 RTE_CRYPTO_CIPHER_KASUMI_F8,
3109 tdata->key.data, tdata->key.len,
3110 tdata->cipher_iv.len);
3114 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3115 /* Append data which is padded to a multiple */
3116 /* of the algorithms block size */
3117 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3119 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3120 plaintext_pad_len, 10, 0);
3121 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3122 plaintext_pad_len, 3, 0);
3124 /* Append data which is padded to a multiple */
3125 /* of the algorithms block size */
3126 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3128 /* Create KASUMI operation */
3129 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3130 tdata->cipher_iv.len,
3131 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3132 tdata->validCipherOffsetInBits.len);
3136 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3138 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3140 ut_params->obuf = ut_params->op->sym->m_dst;
3141 if (ut_params->obuf)
3142 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3143 plaintext_pad_len, buffer);
3145 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3146 tdata->validCipherOffsetInBits.len >> 3,
3147 plaintext_pad_len, buffer);
3149 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3150 (tdata->validCipherOffsetInBits.len >> 3);
3152 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3154 reference_ciphertext,
3155 tdata->validCipherLenInBits.len,
3156 "KASUMI Ciphertext data not as expected");
3162 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3164 struct crypto_testsuite_params *ts_params = &testsuite_params;
3165 struct crypto_unittest_params *ut_params = &unittest_params;
3168 uint8_t *ciphertext, *plaintext;
3169 unsigned ciphertext_pad_len;
3170 unsigned ciphertext_len;
3172 /* Verify the capabilities */
3173 struct rte_cryptodev_sym_capability_idx cap_idx;
3174 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3175 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3176 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3180 /* Create KASUMI session */
3181 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3182 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3183 RTE_CRYPTO_CIPHER_KASUMI_F8,
3184 tdata->key.data, tdata->key.len,
3185 tdata->cipher_iv.len);
3189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3190 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3192 /* Clear mbuf payload */
3193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3194 rte_pktmbuf_tailroom(ut_params->ibuf));
3196 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3197 /* Append data which is padded to a multiple */
3198 /* of the algorithms block size */
3199 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3200 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3201 ciphertext_pad_len);
3202 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3203 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3205 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3207 /* Create KASUMI operation */
3208 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3209 tdata->cipher_iv.len,
3210 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3211 tdata->validCipherOffsetInBits.len);
3215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3219 ut_params->obuf = ut_params->op->sym->m_dst;
3220 if (ut_params->obuf)
3221 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3223 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3225 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3227 const uint8_t *reference_plaintext = tdata->plaintext.data +
3228 (tdata->validCipherOffsetInBits.len >> 3);
3230 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3232 reference_plaintext,
3233 tdata->validCipherLenInBits.len,
3234 "KASUMI Plaintext data not as expected");
3239 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3241 struct crypto_testsuite_params *ts_params = &testsuite_params;
3242 struct crypto_unittest_params *ut_params = &unittest_params;
3245 uint8_t *ciphertext, *plaintext;
3246 unsigned ciphertext_pad_len;
3247 unsigned ciphertext_len;
3249 /* Verify the capabilities */
3250 struct rte_cryptodev_sym_capability_idx cap_idx;
3251 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3252 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3253 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3257 /* Create KASUMI session */
3258 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3259 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3260 RTE_CRYPTO_CIPHER_KASUMI_F8,
3261 tdata->key.data, tdata->key.len,
3262 tdata->cipher_iv.len);
3266 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3268 /* Clear mbuf payload */
3269 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3270 rte_pktmbuf_tailroom(ut_params->ibuf));
3272 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3273 /* Append data which is padded to a multiple */
3274 /* of the algorithms block size */
3275 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3276 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3277 ciphertext_pad_len);
3278 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3280 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3282 /* Create KASUMI operation */
3283 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3284 tdata->cipher_iv.len,
3285 tdata->ciphertext.len,
3286 tdata->validCipherOffsetInBits.len);
3290 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3292 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3294 ut_params->obuf = ut_params->op->sym->m_dst;
3295 if (ut_params->obuf)
3296 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3298 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3300 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3302 const uint8_t *reference_plaintext = tdata->plaintext.data +
3303 (tdata->validCipherOffsetInBits.len >> 3);
3305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3307 reference_plaintext,
3308 tdata->validCipherLenInBits.len,
3309 "KASUMI Plaintext data not as expected");
3314 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3316 struct crypto_testsuite_params *ts_params = &testsuite_params;
3317 struct crypto_unittest_params *ut_params = &unittest_params;
3320 uint8_t *plaintext, *ciphertext;
3321 unsigned plaintext_pad_len;
3322 unsigned plaintext_len;
3324 /* Verify the capabilities */
3325 struct rte_cryptodev_sym_capability_idx cap_idx;
3326 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3327 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3328 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3332 /* Create SNOW 3G session */
3333 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3334 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3336 tdata->key.data, tdata->key.len,
3337 tdata->cipher_iv.len);
3341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3343 /* Clear mbuf payload */
3344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3345 rte_pktmbuf_tailroom(ut_params->ibuf));
3347 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3348 /* Append data which is padded to a multiple of */
3349 /* the algorithms block size */
3350 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3351 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3353 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3355 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3357 /* Create SNOW 3G operation */
3358 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3359 tdata->cipher_iv.len,
3360 tdata->validCipherLenInBits.len,
3365 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3367 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3369 ut_params->obuf = ut_params->op->sym->m_dst;
3370 if (ut_params->obuf)
3371 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3373 ciphertext = plaintext;
3375 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3378 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3380 tdata->ciphertext.data,
3381 tdata->validDataLenInBits.len,
3382 "SNOW 3G Ciphertext data not as expected");
3388 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3390 struct crypto_testsuite_params *ts_params = &testsuite_params;
3391 struct crypto_unittest_params *ut_params = &unittest_params;
3392 uint8_t *plaintext, *ciphertext;
3395 unsigned plaintext_pad_len;
3396 unsigned plaintext_len;
3398 /* Verify the capabilities */
3399 struct rte_cryptodev_sym_capability_idx cap_idx;
3400 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3401 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3402 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3406 /* Create SNOW 3G session */
3407 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3408 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3409 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3410 tdata->key.data, tdata->key.len,
3411 tdata->cipher_iv.len);
3415 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3416 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3418 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3419 "Failed to allocate input buffer in mempool");
3420 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3421 "Failed to allocate output buffer in mempool");
3423 /* Clear mbuf payload */
3424 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3425 rte_pktmbuf_tailroom(ut_params->ibuf));
3427 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3428 /* Append data which is padded to a multiple of */
3429 /* the algorithms block size */
3430 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3431 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3433 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3434 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3436 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3438 /* Create SNOW 3G operation */
3439 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3440 tdata->cipher_iv.len,
3441 tdata->validCipherLenInBits.len,
3446 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3450 ut_params->obuf = ut_params->op->sym->m_dst;
3451 if (ut_params->obuf)
3452 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3454 ciphertext = plaintext;
3456 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3459 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3461 tdata->ciphertext.data,
3462 tdata->validDataLenInBits.len,
3463 "SNOW 3G Ciphertext data not as expected");
3468 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3470 struct crypto_testsuite_params *ts_params = &testsuite_params;
3471 struct crypto_unittest_params *ut_params = &unittest_params;
3474 unsigned int plaintext_pad_len;
3475 unsigned int plaintext_len;
3476 uint8_t buffer[10000];
3477 const uint8_t *ciphertext;
3479 struct rte_cryptodev_info dev_info;
3481 /* Verify the capabilities */
3482 struct rte_cryptodev_sym_capability_idx cap_idx;
3483 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3484 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3485 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3489 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3491 uint64_t feat_flags = dev_info.feature_flags;
3493 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3494 printf("Device doesn't support out-of-place scatter-gather "
3495 "in both input and output mbufs. "
3500 /* Create SNOW 3G session */
3501 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3502 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3503 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3504 tdata->key.data, tdata->key.len,
3505 tdata->cipher_iv.len);
3509 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3510 /* Append data which is padded to a multiple of */
3511 /* the algorithms block size */
3512 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3514 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3515 plaintext_pad_len, 10, 0);
3516 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3517 plaintext_pad_len, 3, 0);
3519 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3520 "Failed to allocate input buffer in mempool");
3521 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3522 "Failed to allocate output buffer in mempool");
3524 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3526 /* Create SNOW 3G operation */
3527 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3528 tdata->cipher_iv.len,
3529 tdata->validCipherLenInBits.len,
3534 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3536 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3538 ut_params->obuf = ut_params->op->sym->m_dst;
3539 if (ut_params->obuf)
3540 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3541 plaintext_len, buffer);
3543 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3544 plaintext_len, buffer);
3546 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3549 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3551 tdata->ciphertext.data,
3552 tdata->validDataLenInBits.len,
3553 "SNOW 3G Ciphertext data not as expected");
3558 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3560 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3562 uint8_t curr_byte, prev_byte;
3563 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3564 uint8_t lower_byte_mask = (1 << offset) - 1;
3567 prev_byte = buffer[0];
3568 buffer[0] >>= offset;
3570 for (i = 1; i < length_in_bytes; i++) {
3571 curr_byte = buffer[i];
3572 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3573 (curr_byte >> offset);
3574 prev_byte = curr_byte;
3579 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3581 struct crypto_testsuite_params *ts_params = &testsuite_params;
3582 struct crypto_unittest_params *ut_params = &unittest_params;
3583 uint8_t *plaintext, *ciphertext;
3585 uint32_t plaintext_len;
3586 uint32_t plaintext_pad_len;
3587 uint8_t extra_offset = 4;
3588 uint8_t *expected_ciphertext_shifted;
3589 struct rte_cryptodev_info dev_info;
3591 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3592 uint64_t feat_flags = dev_info.feature_flags;
3594 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3595 ((tdata->validDataLenInBits.len % 8) != 0)) {
3596 printf("Device doesn't support NON-Byte Aligned Data.\n");
3600 /* Verify the capabilities */
3601 struct rte_cryptodev_sym_capability_idx cap_idx;
3602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3603 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3608 /* Create SNOW 3G session */
3609 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3610 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3611 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3612 tdata->key.data, tdata->key.len,
3613 tdata->cipher_iv.len);
3617 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3618 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3620 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3621 "Failed to allocate input buffer in mempool");
3622 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3623 "Failed to allocate output buffer in mempool");
3625 /* Clear mbuf payload */
3626 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3627 rte_pktmbuf_tailroom(ut_params->ibuf));
3629 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3631 * Append data which is padded to a
3632 * multiple of the algorithms block size
3634 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3636 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3639 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3641 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3642 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3644 #ifdef RTE_APP_TEST_DEBUG
3645 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3647 /* Create SNOW 3G operation */
3648 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3649 tdata->cipher_iv.len,
3650 tdata->validCipherLenInBits.len,
3655 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3659 ut_params->obuf = ut_params->op->sym->m_dst;
3660 if (ut_params->obuf)
3661 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3663 ciphertext = plaintext;
3665 #ifdef RTE_APP_TEST_DEBUG
3666 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3669 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3671 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3672 "failed to reserve memory for ciphertext shifted\n");
3674 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3675 ceil_byte_length(tdata->ciphertext.len));
3676 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3679 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3681 expected_ciphertext_shifted,
3682 tdata->validDataLenInBits.len,
3684 "SNOW 3G Ciphertext data not as expected");
3688 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3690 struct crypto_testsuite_params *ts_params = &testsuite_params;
3691 struct crypto_unittest_params *ut_params = &unittest_params;
3695 uint8_t *plaintext, *ciphertext;
3696 unsigned ciphertext_pad_len;
3697 unsigned ciphertext_len;
3699 /* Verify the capabilities */
3700 struct rte_cryptodev_sym_capability_idx cap_idx;
3701 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3702 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3703 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3707 /* Create SNOW 3G session */
3708 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3709 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3710 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3711 tdata->key.data, tdata->key.len,
3712 tdata->cipher_iv.len);
3716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3718 /* Clear mbuf payload */
3719 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3720 rte_pktmbuf_tailroom(ut_params->ibuf));
3722 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3723 /* Append data which is padded to a multiple of */
3724 /* the algorithms block size */
3725 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3726 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3727 ciphertext_pad_len);
3728 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3730 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3732 /* Create SNOW 3G operation */
3733 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3734 tdata->cipher_iv.len,
3735 tdata->validCipherLenInBits.len,
3736 tdata->cipher.offset_bits);
3740 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3742 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3743 ut_params->obuf = ut_params->op->sym->m_dst;
3744 if (ut_params->obuf)
3745 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3747 plaintext = ciphertext;
3749 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3752 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3753 tdata->plaintext.data,
3754 tdata->validDataLenInBits.len,
3755 "SNOW 3G Plaintext data not as expected");
3759 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3761 struct crypto_testsuite_params *ts_params = &testsuite_params;
3762 struct crypto_unittest_params *ut_params = &unittest_params;
3766 uint8_t *plaintext, *ciphertext;
3767 unsigned ciphertext_pad_len;
3768 unsigned ciphertext_len;
3770 /* Verify the capabilities */
3771 struct rte_cryptodev_sym_capability_idx cap_idx;
3772 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3773 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3774 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3778 /* Create SNOW 3G session */
3779 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3780 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3781 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3782 tdata->key.data, tdata->key.len,
3783 tdata->cipher_iv.len);
3787 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3788 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3790 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3791 "Failed to allocate input buffer");
3792 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3793 "Failed to allocate output buffer");
3795 /* Clear mbuf payload */
3796 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3797 rte_pktmbuf_tailroom(ut_params->ibuf));
3799 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3800 rte_pktmbuf_tailroom(ut_params->obuf));
3802 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3803 /* Append data which is padded to a multiple of */
3804 /* the algorithms block size */
3805 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3806 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3807 ciphertext_pad_len);
3808 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3809 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3811 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3813 /* Create SNOW 3G operation */
3814 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3815 tdata->cipher_iv.len,
3816 tdata->validCipherLenInBits.len,
3821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3824 ut_params->obuf = ut_params->op->sym->m_dst;
3825 if (ut_params->obuf)
3826 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3828 plaintext = ciphertext;
3830 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3833 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3834 tdata->plaintext.data,
3835 tdata->validDataLenInBits.len,
3836 "SNOW 3G Plaintext data not as expected");
3841 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3843 struct crypto_testsuite_params *ts_params = &testsuite_params;
3844 struct crypto_unittest_params *ut_params = &unittest_params;
3848 uint8_t *plaintext, *ciphertext;
3849 unsigned int plaintext_pad_len;
3850 unsigned int plaintext_len;
3852 struct rte_cryptodev_info dev_info;
3853 struct rte_cryptodev_sym_capability_idx cap_idx;
3855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3856 uint64_t feat_flags = dev_info.feature_flags;
3858 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3859 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3860 (tdata->validDataLenInBits.len % 8 != 0))) {
3861 printf("Device doesn't support NON-Byte Aligned Data.\n");
3865 /* Check if device supports ZUC EEA3 */
3866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3867 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3869 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3873 /* Check if device supports ZUC EIA3 */
3874 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3875 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3877 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3881 /* Create ZUC session */
3882 retval = create_zuc_cipher_auth_encrypt_generate_session(
3883 ts_params->valid_devs[0],
3887 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3889 /* clear mbuf payload */
3890 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3891 rte_pktmbuf_tailroom(ut_params->ibuf));
3893 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3894 /* Append data which is padded to a multiple of */
3895 /* the algorithms block size */
3896 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3897 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3899 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3901 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3903 /* Create ZUC operation */
3904 retval = create_zuc_cipher_hash_generate_operation(tdata);
3908 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3910 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3911 ut_params->obuf = ut_params->op->sym->m_src;
3912 if (ut_params->obuf)
3913 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3915 ciphertext = plaintext;
3917 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3919 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3921 tdata->ciphertext.data,
3922 tdata->validDataLenInBits.len,
3923 "ZUC Ciphertext data not as expected");
3925 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3926 + plaintext_pad_len;
3929 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3933 "ZUC Generated auth tag not as expected");
3938 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3940 struct crypto_testsuite_params *ts_params = &testsuite_params;
3941 struct crypto_unittest_params *ut_params = &unittest_params;
3945 uint8_t *plaintext, *ciphertext;
3946 unsigned plaintext_pad_len;
3947 unsigned plaintext_len;
3949 /* Verify the capabilities */
3950 struct rte_cryptodev_sym_capability_idx cap_idx;
3951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3952 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3953 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3956 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3957 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3958 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3962 /* Create SNOW 3G session */
3963 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3964 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3965 RTE_CRYPTO_AUTH_OP_GENERATE,
3966 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3967 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3968 tdata->key.data, tdata->key.len,
3969 tdata->auth_iv.len, tdata->digest.len,
3970 tdata->cipher_iv.len);
3973 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3975 /* clear mbuf payload */
3976 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3977 rte_pktmbuf_tailroom(ut_params->ibuf));
3979 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3980 /* Append data which is padded to a multiple of */
3981 /* the algorithms block size */
3982 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3983 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3985 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3987 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3989 /* Create SNOW 3G operation */
3990 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3991 tdata->digest.len, tdata->auth_iv.data,
3993 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3994 tdata->cipher_iv.data, tdata->cipher_iv.len,
3995 tdata->validCipherLenInBits.len,
3997 tdata->validAuthLenInBits.len,
4003 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4005 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4006 ut_params->obuf = ut_params->op->sym->m_src;
4007 if (ut_params->obuf)
4008 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4010 ciphertext = plaintext;
4012 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4014 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4016 tdata->ciphertext.data,
4017 tdata->validDataLenInBits.len,
4018 "SNOW 3G Ciphertext data not as expected");
4020 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4021 + plaintext_pad_len;
4024 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4027 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4028 "SNOW 3G Generated auth tag not as expected");
4033 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4034 uint8_t op_mode, uint8_t verify)
4036 struct crypto_testsuite_params *ts_params = &testsuite_params;
4037 struct crypto_unittest_params *ut_params = &unittest_params;
4041 uint8_t *plaintext = NULL, *ciphertext = NULL;
4042 unsigned int plaintext_pad_len;
4043 unsigned int plaintext_len;
4044 unsigned int ciphertext_pad_len;
4045 unsigned int ciphertext_len;
4047 struct rte_cryptodev_info dev_info;
4049 /* Verify the capabilities */
4050 struct rte_cryptodev_sym_capability_idx cap_idx;
4051 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4052 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4053 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4057 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4062 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4064 uint64_t feat_flags = dev_info.feature_flags;
4066 if (op_mode == OUT_OF_PLACE) {
4067 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4068 printf("Device doesn't support digest encrypted.\n");
4073 /* Create SNOW 3G session */
4074 retval = create_wireless_algo_auth_cipher_session(
4075 ts_params->valid_devs[0],
4076 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4077 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4078 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4079 : RTE_CRYPTO_AUTH_OP_GENERATE),
4080 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4081 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4082 tdata->key.data, tdata->key.len,
4083 tdata->auth_iv.len, tdata->digest.len,
4084 tdata->cipher_iv.len);
4089 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4090 if (op_mode == OUT_OF_PLACE)
4091 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4093 /* clear mbuf payload */
4094 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4095 rte_pktmbuf_tailroom(ut_params->ibuf));
4096 if (op_mode == OUT_OF_PLACE)
4097 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4098 rte_pktmbuf_tailroom(ut_params->obuf));
4100 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4101 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4102 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4103 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4106 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4107 ciphertext_pad_len);
4108 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4109 if (op_mode == OUT_OF_PLACE)
4110 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4111 debug_hexdump(stdout, "ciphertext:", ciphertext,
4114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4116 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4117 if (op_mode == OUT_OF_PLACE)
4118 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4119 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4122 /* Create SNOW 3G operation */
4123 retval = create_wireless_algo_auth_cipher_operation(
4124 tdata->digest.data, tdata->digest.len,
4125 tdata->cipher_iv.data, tdata->cipher_iv.len,
4126 tdata->auth_iv.data, tdata->auth_iv.len,
4127 (tdata->digest.offset_bytes == 0 ?
4128 (verify ? ciphertext_pad_len : plaintext_pad_len)
4129 : tdata->digest.offset_bytes),
4130 tdata->validCipherLenInBits.len,
4131 tdata->cipher.offset_bits,
4132 tdata->validAuthLenInBits.len,
4133 tdata->auth.offset_bits,
4134 op_mode, 0, verify);
4139 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4142 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4144 ut_params->obuf = (op_mode == IN_PLACE ?
4145 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4148 if (ut_params->obuf)
4149 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4152 plaintext = ciphertext +
4153 (tdata->cipher.offset_bits >> 3);
4155 debug_hexdump(stdout, "plaintext:", plaintext,
4156 (tdata->plaintext.len >> 3) - tdata->digest.len);
4157 debug_hexdump(stdout, "plaintext expected:",
4158 tdata->plaintext.data,
4159 (tdata->plaintext.len >> 3) - tdata->digest.len);
4161 if (ut_params->obuf)
4162 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4165 ciphertext = plaintext;
4167 debug_hexdump(stdout, "ciphertext:", ciphertext,
4169 debug_hexdump(stdout, "ciphertext expected:",
4170 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4172 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4173 + (tdata->digest.offset_bytes == 0 ?
4174 plaintext_pad_len : tdata->digest.offset_bytes);
4176 debug_hexdump(stdout, "digest:", ut_params->digest,
4178 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4184 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4186 tdata->plaintext.data,
4187 tdata->plaintext.len >> 3,
4188 "SNOW 3G Plaintext data not as expected");
4190 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4192 tdata->ciphertext.data,
4193 tdata->validDataLenInBits.len,
4194 "SNOW 3G Ciphertext data not as expected");
4196 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4199 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4200 "SNOW 3G Generated auth tag not as expected");
4206 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4207 uint8_t op_mode, uint8_t verify)
4209 struct crypto_testsuite_params *ts_params = &testsuite_params;
4210 struct crypto_unittest_params *ut_params = &unittest_params;
4214 const uint8_t *plaintext = NULL;
4215 const uint8_t *ciphertext = NULL;
4216 const uint8_t *digest = NULL;
4217 unsigned int plaintext_pad_len;
4218 unsigned int plaintext_len;
4219 unsigned int ciphertext_pad_len;
4220 unsigned int ciphertext_len;
4221 uint8_t buffer[10000];
4222 uint8_t digest_buffer[10000];
4224 struct rte_cryptodev_info dev_info;
4226 /* Verify the capabilities */
4227 struct rte_cryptodev_sym_capability_idx cap_idx;
4228 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4229 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4230 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4233 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4234 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4235 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4239 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4241 uint64_t feat_flags = dev_info.feature_flags;
4243 if (op_mode == IN_PLACE) {
4244 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4245 printf("Device doesn't support in-place scatter-gather "
4246 "in both input and output mbufs.\n");
4250 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4251 printf("Device doesn't support out-of-place scatter-gather "
4252 "in both input and output mbufs.\n");
4255 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4256 printf("Device doesn't support digest encrypted.\n");
4261 /* Create SNOW 3G session */
4262 retval = create_wireless_algo_auth_cipher_session(
4263 ts_params->valid_devs[0],
4264 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4265 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4266 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4267 : RTE_CRYPTO_AUTH_OP_GENERATE),
4268 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4269 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4270 tdata->key.data, tdata->key.len,
4271 tdata->auth_iv.len, tdata->digest.len,
4272 tdata->cipher_iv.len);
4277 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4278 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4279 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4280 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4282 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4283 plaintext_pad_len, 15, 0);
4284 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4285 "Failed to allocate input buffer in mempool");
4287 if (op_mode == OUT_OF_PLACE) {
4288 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4289 plaintext_pad_len, 15, 0);
4290 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4291 "Failed to allocate output buffer in mempool");
4295 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4296 tdata->ciphertext.data);
4297 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4298 ciphertext_len, buffer);
4299 debug_hexdump(stdout, "ciphertext:", ciphertext,
4302 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4303 tdata->plaintext.data);
4304 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4305 plaintext_len, buffer);
4306 debug_hexdump(stdout, "plaintext:", plaintext,
4309 memset(buffer, 0, sizeof(buffer));
4311 /* Create SNOW 3G operation */
4312 retval = create_wireless_algo_auth_cipher_operation(
4313 tdata->digest.data, tdata->digest.len,
4314 tdata->cipher_iv.data, tdata->cipher_iv.len,
4315 tdata->auth_iv.data, tdata->auth_iv.len,
4316 (tdata->digest.offset_bytes == 0 ?
4317 (verify ? ciphertext_pad_len : plaintext_pad_len)
4318 : tdata->digest.offset_bytes),
4319 tdata->validCipherLenInBits.len,
4320 tdata->cipher.offset_bits,
4321 tdata->validAuthLenInBits.len,
4322 tdata->auth.offset_bits,
4323 op_mode, 1, verify);
4328 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4331 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4333 ut_params->obuf = (op_mode == IN_PLACE ?
4334 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4337 if (ut_params->obuf)
4338 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4339 plaintext_len, buffer);
4341 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4342 plaintext_len, buffer);
4344 debug_hexdump(stdout, "plaintext:", plaintext,
4345 (tdata->plaintext.len >> 3) - tdata->digest.len);
4346 debug_hexdump(stdout, "plaintext expected:",
4347 tdata->plaintext.data,
4348 (tdata->plaintext.len >> 3) - tdata->digest.len);
4350 if (ut_params->obuf)
4351 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4352 ciphertext_len, buffer);
4354 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4355 ciphertext_len, buffer);
4357 debug_hexdump(stdout, "ciphertext:", ciphertext,
4359 debug_hexdump(stdout, "ciphertext expected:",
4360 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4362 if (ut_params->obuf)
4363 digest = rte_pktmbuf_read(ut_params->obuf,
4364 (tdata->digest.offset_bytes == 0 ?
4365 plaintext_pad_len : tdata->digest.offset_bytes),
4366 tdata->digest.len, digest_buffer);
4368 digest = rte_pktmbuf_read(ut_params->ibuf,
4369 (tdata->digest.offset_bytes == 0 ?
4370 plaintext_pad_len : tdata->digest.offset_bytes),
4371 tdata->digest.len, digest_buffer);
4373 debug_hexdump(stdout, "digest:", digest,
4375 debug_hexdump(stdout, "digest expected:",
4376 tdata->digest.data, tdata->digest.len);
4381 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4383 tdata->plaintext.data,
4384 tdata->plaintext.len >> 3,
4385 "SNOW 3G Plaintext data not as expected");
4387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4389 tdata->ciphertext.data,
4390 tdata->validDataLenInBits.len,
4391 "SNOW 3G Ciphertext data not as expected");
4393 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4396 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4397 "SNOW 3G Generated auth tag not as expected");
4403 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4404 uint8_t op_mode, uint8_t verify)
4406 struct crypto_testsuite_params *ts_params = &testsuite_params;
4407 struct crypto_unittest_params *ut_params = &unittest_params;
4411 uint8_t *plaintext = NULL, *ciphertext = NULL;
4412 unsigned int plaintext_pad_len;
4413 unsigned int plaintext_len;
4414 unsigned int ciphertext_pad_len;
4415 unsigned int ciphertext_len;
4417 struct rte_cryptodev_info dev_info;
4419 /* Verify the capabilities */
4420 struct rte_cryptodev_sym_capability_idx cap_idx;
4421 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4422 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4426 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4427 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4428 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4432 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4434 uint64_t feat_flags = dev_info.feature_flags;
4436 if (op_mode == OUT_OF_PLACE) {
4437 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4438 printf("Device doesn't support digest encrypted.\n");
4443 /* Create KASUMI session */
4444 retval = create_wireless_algo_auth_cipher_session(
4445 ts_params->valid_devs[0],
4446 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4447 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4448 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4449 : RTE_CRYPTO_AUTH_OP_GENERATE),
4450 RTE_CRYPTO_AUTH_KASUMI_F9,
4451 RTE_CRYPTO_CIPHER_KASUMI_F8,
4452 tdata->key.data, tdata->key.len,
4453 0, tdata->digest.len,
4454 tdata->cipher_iv.len);
4459 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4460 if (op_mode == OUT_OF_PLACE)
4461 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4463 /* clear mbuf payload */
4464 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4465 rte_pktmbuf_tailroom(ut_params->ibuf));
4466 if (op_mode == OUT_OF_PLACE)
4467 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4468 rte_pktmbuf_tailroom(ut_params->obuf));
4470 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4471 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4472 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4473 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4476 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4477 ciphertext_pad_len);
4478 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4479 if (op_mode == OUT_OF_PLACE)
4480 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4481 debug_hexdump(stdout, "ciphertext:", ciphertext,
4484 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4486 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4487 if (op_mode == OUT_OF_PLACE)
4488 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4489 debug_hexdump(stdout, "plaintext:", plaintext,
4493 /* Create KASUMI operation */
4494 retval = create_wireless_algo_auth_cipher_operation(
4495 tdata->digest.data, tdata->digest.len,
4496 tdata->cipher_iv.data, tdata->cipher_iv.len,
4498 (tdata->digest.offset_bytes == 0 ?
4499 (verify ? ciphertext_pad_len : plaintext_pad_len)
4500 : tdata->digest.offset_bytes),
4501 tdata->validCipherLenInBits.len,
4502 tdata->validCipherOffsetInBits.len,
4503 tdata->validAuthLenInBits.len,
4505 op_mode, 0, verify);
4510 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4513 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4515 ut_params->obuf = (op_mode == IN_PLACE ?
4516 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4520 if (ut_params->obuf)
4521 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4524 plaintext = ciphertext;
4526 debug_hexdump(stdout, "plaintext:", plaintext,
4527 (tdata->plaintext.len >> 3) - tdata->digest.len);
4528 debug_hexdump(stdout, "plaintext expected:",
4529 tdata->plaintext.data,
4530 (tdata->plaintext.len >> 3) - tdata->digest.len);
4532 if (ut_params->obuf)
4533 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4536 ciphertext = plaintext;
4538 debug_hexdump(stdout, "ciphertext:", ciphertext,
4540 debug_hexdump(stdout, "ciphertext expected:",
4541 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4543 ut_params->digest = rte_pktmbuf_mtod(
4544 ut_params->obuf, uint8_t *) +
4545 (tdata->digest.offset_bytes == 0 ?
4546 plaintext_pad_len : tdata->digest.offset_bytes);
4548 debug_hexdump(stdout, "digest:", ut_params->digest,
4550 debug_hexdump(stdout, "digest expected:",
4551 tdata->digest.data, tdata->digest.len);
4556 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4558 tdata->plaintext.data,
4559 tdata->plaintext.len >> 3,
4560 "KASUMI Plaintext data not as expected");
4562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4564 tdata->ciphertext.data,
4565 tdata->ciphertext.len >> 3,
4566 "KASUMI Ciphertext data not as expected");
4568 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4571 DIGEST_BYTE_LENGTH_KASUMI_F9,
4572 "KASUMI Generated auth tag not as expected");
4578 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4579 uint8_t op_mode, uint8_t verify)
4581 struct crypto_testsuite_params *ts_params = &testsuite_params;
4582 struct crypto_unittest_params *ut_params = &unittest_params;
4586 const uint8_t *plaintext = NULL;
4587 const uint8_t *ciphertext = NULL;
4588 const uint8_t *digest = NULL;
4589 unsigned int plaintext_pad_len;
4590 unsigned int plaintext_len;
4591 unsigned int ciphertext_pad_len;
4592 unsigned int ciphertext_len;
4593 uint8_t buffer[10000];
4594 uint8_t digest_buffer[10000];
4596 struct rte_cryptodev_info dev_info;
4598 /* Verify the capabilities */
4599 struct rte_cryptodev_sym_capability_idx cap_idx;
4600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4601 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4606 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4611 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4613 uint64_t feat_flags = dev_info.feature_flags;
4615 if (op_mode == IN_PLACE) {
4616 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4617 printf("Device doesn't support in-place scatter-gather "
4618 "in both input and output mbufs.\n");
4622 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4623 printf("Device doesn't support out-of-place scatter-gather "
4624 "in both input and output mbufs.\n");
4627 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4628 printf("Device doesn't support digest encrypted.\n");
4633 /* Create KASUMI session */
4634 retval = create_wireless_algo_auth_cipher_session(
4635 ts_params->valid_devs[0],
4636 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4637 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4638 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4639 : RTE_CRYPTO_AUTH_OP_GENERATE),
4640 RTE_CRYPTO_AUTH_KASUMI_F9,
4641 RTE_CRYPTO_CIPHER_KASUMI_F8,
4642 tdata->key.data, tdata->key.len,
4643 0, tdata->digest.len,
4644 tdata->cipher_iv.len);
4649 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4650 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4651 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4652 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4654 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4655 plaintext_pad_len, 15, 0);
4656 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4657 "Failed to allocate input buffer in mempool");
4659 if (op_mode == OUT_OF_PLACE) {
4660 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4661 plaintext_pad_len, 15, 0);
4662 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4663 "Failed to allocate output buffer in mempool");
4667 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4668 tdata->ciphertext.data);
4669 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4670 ciphertext_len, buffer);
4671 debug_hexdump(stdout, "ciphertext:", ciphertext,
4674 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4675 tdata->plaintext.data);
4676 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4677 plaintext_len, buffer);
4678 debug_hexdump(stdout, "plaintext:", plaintext,
4681 memset(buffer, 0, sizeof(buffer));
4683 /* Create KASUMI operation */
4684 retval = create_wireless_algo_auth_cipher_operation(
4685 tdata->digest.data, tdata->digest.len,
4686 tdata->cipher_iv.data, tdata->cipher_iv.len,
4688 (tdata->digest.offset_bytes == 0 ?
4689 (verify ? ciphertext_pad_len : plaintext_pad_len)
4690 : tdata->digest.offset_bytes),
4691 tdata->validCipherLenInBits.len,
4692 tdata->validCipherOffsetInBits.len,
4693 tdata->validAuthLenInBits.len,
4695 op_mode, 1, verify);
4700 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4703 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4705 ut_params->obuf = (op_mode == IN_PLACE ?
4706 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4709 if (ut_params->obuf)
4710 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4711 plaintext_len, buffer);
4713 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4714 plaintext_len, buffer);
4716 debug_hexdump(stdout, "plaintext:", plaintext,
4717 (tdata->plaintext.len >> 3) - tdata->digest.len);
4718 debug_hexdump(stdout, "plaintext expected:",
4719 tdata->plaintext.data,
4720 (tdata->plaintext.len >> 3) - tdata->digest.len);
4722 if (ut_params->obuf)
4723 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4724 ciphertext_len, buffer);
4726 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4727 ciphertext_len, buffer);
4729 debug_hexdump(stdout, "ciphertext:", ciphertext,
4731 debug_hexdump(stdout, "ciphertext expected:",
4732 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4734 if (ut_params->obuf)
4735 digest = rte_pktmbuf_read(ut_params->obuf,
4736 (tdata->digest.offset_bytes == 0 ?
4737 plaintext_pad_len : tdata->digest.offset_bytes),
4738 tdata->digest.len, digest_buffer);
4740 digest = rte_pktmbuf_read(ut_params->ibuf,
4741 (tdata->digest.offset_bytes == 0 ?
4742 plaintext_pad_len : tdata->digest.offset_bytes),
4743 tdata->digest.len, digest_buffer);
4745 debug_hexdump(stdout, "digest:", digest,
4747 debug_hexdump(stdout, "digest expected:",
4748 tdata->digest.data, tdata->digest.len);
4753 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4755 tdata->plaintext.data,
4756 tdata->plaintext.len >> 3,
4757 "KASUMI Plaintext data not as expected");
4759 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4761 tdata->ciphertext.data,
4762 tdata->validDataLenInBits.len,
4763 "KASUMI Ciphertext data not as expected");
4765 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4768 DIGEST_BYTE_LENGTH_KASUMI_F9,
4769 "KASUMI Generated auth tag not as expected");
4775 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4777 struct crypto_testsuite_params *ts_params = &testsuite_params;
4778 struct crypto_unittest_params *ut_params = &unittest_params;
4782 uint8_t *plaintext, *ciphertext;
4783 unsigned plaintext_pad_len;
4784 unsigned plaintext_len;
4786 /* Verify the capabilities */
4787 struct rte_cryptodev_sym_capability_idx cap_idx;
4788 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4789 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4790 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4793 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4794 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4795 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4799 /* Create KASUMI session */
4800 retval = create_wireless_algo_cipher_auth_session(
4801 ts_params->valid_devs[0],
4802 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4803 RTE_CRYPTO_AUTH_OP_GENERATE,
4804 RTE_CRYPTO_AUTH_KASUMI_F9,
4805 RTE_CRYPTO_CIPHER_KASUMI_F8,
4806 tdata->key.data, tdata->key.len,
4807 0, tdata->digest.len,
4808 tdata->cipher_iv.len);
4812 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4814 /* clear mbuf payload */
4815 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4816 rte_pktmbuf_tailroom(ut_params->ibuf));
4818 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4819 /* Append data which is padded to a multiple of */
4820 /* the algorithms block size */
4821 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4822 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4824 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4826 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4828 /* Create KASUMI operation */
4829 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4830 tdata->digest.len, NULL, 0,
4831 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4832 tdata->cipher_iv.data, tdata->cipher_iv.len,
4833 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4834 tdata->validCipherOffsetInBits.len,
4835 tdata->validAuthLenInBits.len,
4841 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4843 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4845 if (ut_params->op->sym->m_dst)
4846 ut_params->obuf = ut_params->op->sym->m_dst;
4848 ut_params->obuf = ut_params->op->sym->m_src;
4850 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4851 tdata->validCipherOffsetInBits.len >> 3);
4853 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4854 + plaintext_pad_len;
4856 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4857 (tdata->validCipherOffsetInBits.len >> 3);
4859 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4861 reference_ciphertext,
4862 tdata->validCipherLenInBits.len,
4863 "KASUMI Ciphertext data not as expected");
4866 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4869 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4870 "KASUMI Generated auth tag not as expected");
4875 test_zuc_encryption(const struct wireless_test_data *tdata)
4877 struct crypto_testsuite_params *ts_params = &testsuite_params;
4878 struct crypto_unittest_params *ut_params = &unittest_params;
4881 uint8_t *plaintext, *ciphertext;
4882 unsigned plaintext_pad_len;
4883 unsigned plaintext_len;
4885 struct rte_cryptodev_sym_capability_idx cap_idx;
4887 /* Check if device supports ZUC EEA3 */
4888 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4889 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4891 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4895 /* Create ZUC session */
4896 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4897 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4898 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4899 tdata->key.data, tdata->key.len,
4900 tdata->cipher_iv.len);
4904 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4906 /* Clear mbuf payload */
4907 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4908 rte_pktmbuf_tailroom(ut_params->ibuf));
4910 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4911 /* Append data which is padded to a multiple */
4912 /* of the algorithms block size */
4913 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4914 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4916 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4918 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4920 /* Create ZUC operation */
4921 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4922 tdata->cipher_iv.len,
4923 tdata->plaintext.len,
4928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4930 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4932 ut_params->obuf = ut_params->op->sym->m_dst;
4933 if (ut_params->obuf)
4934 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4936 ciphertext = plaintext;
4938 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4941 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4943 tdata->ciphertext.data,
4944 tdata->validCipherLenInBits.len,
4945 "ZUC Ciphertext data not as expected");
4950 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4952 struct crypto_testsuite_params *ts_params = &testsuite_params;
4953 struct crypto_unittest_params *ut_params = &unittest_params;
4957 unsigned int plaintext_pad_len;
4958 unsigned int plaintext_len;
4959 const uint8_t *ciphertext;
4960 uint8_t ciphertext_buffer[2048];
4961 struct rte_cryptodev_info dev_info;
4963 struct rte_cryptodev_sym_capability_idx cap_idx;
4965 /* Check if device supports ZUC EEA3 */
4966 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4967 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4969 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4973 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4975 uint64_t feat_flags = dev_info.feature_flags;
4977 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4978 printf("Device doesn't support in-place scatter-gather. "
4983 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4985 /* Append data which is padded to a multiple */
4986 /* of the algorithms block size */
4987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4989 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4990 plaintext_pad_len, 10, 0);
4992 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4993 tdata->plaintext.data);
4995 /* Create ZUC session */
4996 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4997 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4998 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4999 tdata->key.data, tdata->key.len,
5000 tdata->cipher_iv.len);
5004 /* Clear mbuf payload */
5006 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5008 /* Create ZUC operation */
5009 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5010 tdata->cipher_iv.len, tdata->plaintext.len,
5015 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5017 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5019 ut_params->obuf = ut_params->op->sym->m_dst;
5020 if (ut_params->obuf)
5021 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5022 0, plaintext_len, ciphertext_buffer);
5024 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5025 0, plaintext_len, ciphertext_buffer);
5028 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5031 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5033 tdata->ciphertext.data,
5034 tdata->validCipherLenInBits.len,
5035 "ZUC Ciphertext data not as expected");
5041 test_zuc_authentication(const struct wireless_test_data *tdata)
5043 struct crypto_testsuite_params *ts_params = &testsuite_params;
5044 struct crypto_unittest_params *ut_params = &unittest_params;
5047 unsigned plaintext_pad_len;
5048 unsigned plaintext_len;
5051 struct rte_cryptodev_sym_capability_idx cap_idx;
5052 struct rte_cryptodev_info dev_info;
5054 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5055 uint64_t feat_flags = dev_info.feature_flags;
5057 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5058 (tdata->validAuthLenInBits.len % 8 != 0)) {
5059 printf("Device doesn't support NON-Byte Aligned Data.\n");
5063 /* Check if device supports ZUC EIA3 */
5064 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5065 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5067 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5071 /* Create ZUC session */
5072 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5073 tdata->key.data, tdata->key.len,
5074 tdata->auth_iv.len, tdata->digest.len,
5075 RTE_CRYPTO_AUTH_OP_GENERATE,
5076 RTE_CRYPTO_AUTH_ZUC_EIA3);
5080 /* alloc mbuf and set payload */
5081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5084 rte_pktmbuf_tailroom(ut_params->ibuf));
5086 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5087 /* Append data which is padded to a multiple of */
5088 /* the algorithms block size */
5089 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5090 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5092 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5094 /* Create ZUC operation */
5095 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5096 tdata->auth_iv.data, tdata->auth_iv.len,
5097 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5098 tdata->validAuthLenInBits.len,
5103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5105 ut_params->obuf = ut_params->op->sym->m_src;
5106 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5107 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5108 + plaintext_pad_len;
5111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5115 "ZUC Generated auth tag not as expected");
5121 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5122 uint8_t op_mode, uint8_t verify)
5124 struct crypto_testsuite_params *ts_params = &testsuite_params;
5125 struct crypto_unittest_params *ut_params = &unittest_params;
5129 uint8_t *plaintext = NULL, *ciphertext = NULL;
5130 unsigned int plaintext_pad_len;
5131 unsigned int plaintext_len;
5132 unsigned int ciphertext_pad_len;
5133 unsigned int ciphertext_len;
5135 struct rte_cryptodev_info dev_info;
5136 struct rte_cryptodev_sym_capability_idx cap_idx;
5138 /* Check if device supports ZUC EIA3 */
5139 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5140 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5142 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5146 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5148 uint64_t feat_flags = dev_info.feature_flags;
5150 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5151 printf("Device doesn't support digest encrypted.\n");
5154 if (op_mode == IN_PLACE) {
5155 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5156 printf("Device doesn't support in-place scatter-gather "
5157 "in both input and output mbufs.\n");
5161 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5162 printf("Device doesn't support out-of-place scatter-gather "
5163 "in both input and output mbufs.\n");
5168 /* Create ZUC session */
5169 retval = create_wireless_algo_auth_cipher_session(
5170 ts_params->valid_devs[0],
5171 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5172 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5173 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5174 : RTE_CRYPTO_AUTH_OP_GENERATE),
5175 RTE_CRYPTO_AUTH_ZUC_EIA3,
5176 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5177 tdata->key.data, tdata->key.len,
5178 tdata->auth_iv.len, tdata->digest.len,
5179 tdata->cipher_iv.len);
5184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5185 if (op_mode == OUT_OF_PLACE)
5186 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5188 /* clear mbuf payload */
5189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5190 rte_pktmbuf_tailroom(ut_params->ibuf));
5191 if (op_mode == OUT_OF_PLACE)
5192 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5193 rte_pktmbuf_tailroom(ut_params->obuf));
5195 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5196 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5197 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5198 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5201 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5202 ciphertext_pad_len);
5203 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5204 if (op_mode == OUT_OF_PLACE)
5205 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5206 debug_hexdump(stdout, "ciphertext:", ciphertext,
5209 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5211 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5212 if (op_mode == OUT_OF_PLACE)
5213 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5214 debug_hexdump(stdout, "plaintext:", plaintext,
5218 /* Create ZUC operation */
5219 retval = create_wireless_algo_auth_cipher_operation(
5220 tdata->digest.data, tdata->digest.len,
5221 tdata->cipher_iv.data, tdata->cipher_iv.len,
5222 tdata->auth_iv.data, tdata->auth_iv.len,
5223 (tdata->digest.offset_bytes == 0 ?
5224 (verify ? ciphertext_pad_len : plaintext_pad_len)
5225 : tdata->digest.offset_bytes),
5226 tdata->validCipherLenInBits.len,
5227 tdata->validCipherOffsetInBits.len,
5228 tdata->validAuthLenInBits.len,
5230 op_mode, 0, verify);
5235 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5238 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5240 ut_params->obuf = (op_mode == IN_PLACE ?
5241 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5245 if (ut_params->obuf)
5246 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5249 plaintext = ciphertext;
5251 debug_hexdump(stdout, "plaintext:", plaintext,
5252 (tdata->plaintext.len >> 3) - tdata->digest.len);
5253 debug_hexdump(stdout, "plaintext expected:",
5254 tdata->plaintext.data,
5255 (tdata->plaintext.len >> 3) - tdata->digest.len);
5257 if (ut_params->obuf)
5258 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5261 ciphertext = plaintext;
5263 debug_hexdump(stdout, "ciphertext:", ciphertext,
5265 debug_hexdump(stdout, "ciphertext expected:",
5266 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5268 ut_params->digest = rte_pktmbuf_mtod(
5269 ut_params->obuf, uint8_t *) +
5270 (tdata->digest.offset_bytes == 0 ?
5271 plaintext_pad_len : tdata->digest.offset_bytes);
5273 debug_hexdump(stdout, "digest:", ut_params->digest,
5275 debug_hexdump(stdout, "digest expected:",
5276 tdata->digest.data, tdata->digest.len);
5281 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5283 tdata->plaintext.data,
5284 tdata->plaintext.len >> 3,
5285 "ZUC Plaintext data not as expected");
5287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5289 tdata->ciphertext.data,
5290 tdata->ciphertext.len >> 3,
5291 "ZUC Ciphertext data not as expected");
5293 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5296 DIGEST_BYTE_LENGTH_KASUMI_F9,
5297 "ZUC Generated auth tag not as expected");
5303 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5304 uint8_t op_mode, uint8_t verify)
5306 struct crypto_testsuite_params *ts_params = &testsuite_params;
5307 struct crypto_unittest_params *ut_params = &unittest_params;
5311 const uint8_t *plaintext = NULL;
5312 const uint8_t *ciphertext = NULL;
5313 const uint8_t *digest = NULL;
5314 unsigned int plaintext_pad_len;
5315 unsigned int plaintext_len;
5316 unsigned int ciphertext_pad_len;
5317 unsigned int ciphertext_len;
5318 uint8_t buffer[10000];
5319 uint8_t digest_buffer[10000];
5321 struct rte_cryptodev_info dev_info;
5322 struct rte_cryptodev_sym_capability_idx cap_idx;
5324 /* Check if device supports ZUC EIA3 */
5325 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5326 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5328 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5332 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5334 uint64_t feat_flags = dev_info.feature_flags;
5336 if (op_mode == IN_PLACE) {
5337 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5338 printf("Device doesn't support in-place scatter-gather "
5339 "in both input and output mbufs.\n");
5343 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5344 printf("Device doesn't support out-of-place scatter-gather "
5345 "in both input and output mbufs.\n");
5348 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5349 printf("Device doesn't support digest encrypted.\n");
5354 /* Create ZUC session */
5355 retval = create_wireless_algo_auth_cipher_session(
5356 ts_params->valid_devs[0],
5357 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5358 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5359 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5360 : RTE_CRYPTO_AUTH_OP_GENERATE),
5361 RTE_CRYPTO_AUTH_ZUC_EIA3,
5362 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5363 tdata->key.data, tdata->key.len,
5364 tdata->auth_iv.len, tdata->digest.len,
5365 tdata->cipher_iv.len);
5370 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5371 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5372 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5373 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5375 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5376 plaintext_pad_len, 15, 0);
5377 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5378 "Failed to allocate input buffer in mempool");
5380 if (op_mode == OUT_OF_PLACE) {
5381 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5382 plaintext_pad_len, 15, 0);
5383 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5384 "Failed to allocate output buffer in mempool");
5388 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5389 tdata->ciphertext.data);
5390 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5391 ciphertext_len, buffer);
5392 debug_hexdump(stdout, "ciphertext:", ciphertext,
5395 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5396 tdata->plaintext.data);
5397 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5398 plaintext_len, buffer);
5399 debug_hexdump(stdout, "plaintext:", plaintext,
5402 memset(buffer, 0, sizeof(buffer));
5404 /* Create ZUC operation */
5405 retval = create_wireless_algo_auth_cipher_operation(
5406 tdata->digest.data, tdata->digest.len,
5407 tdata->cipher_iv.data, tdata->cipher_iv.len,
5409 (tdata->digest.offset_bytes == 0 ?
5410 (verify ? ciphertext_pad_len : plaintext_pad_len)
5411 : tdata->digest.offset_bytes),
5412 tdata->validCipherLenInBits.len,
5413 tdata->validCipherOffsetInBits.len,
5414 tdata->validAuthLenInBits.len,
5416 op_mode, 1, verify);
5421 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5426 ut_params->obuf = (op_mode == IN_PLACE ?
5427 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5430 if (ut_params->obuf)
5431 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5432 plaintext_len, buffer);
5434 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5435 plaintext_len, buffer);
5437 debug_hexdump(stdout, "plaintext:", plaintext,
5438 (tdata->plaintext.len >> 3) - tdata->digest.len);
5439 debug_hexdump(stdout, "plaintext expected:",
5440 tdata->plaintext.data,
5441 (tdata->plaintext.len >> 3) - tdata->digest.len);
5443 if (ut_params->obuf)
5444 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5445 ciphertext_len, buffer);
5447 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5448 ciphertext_len, buffer);
5450 debug_hexdump(stdout, "ciphertext:", ciphertext,
5452 debug_hexdump(stdout, "ciphertext expected:",
5453 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5455 if (ut_params->obuf)
5456 digest = rte_pktmbuf_read(ut_params->obuf,
5457 (tdata->digest.offset_bytes == 0 ?
5458 plaintext_pad_len : tdata->digest.offset_bytes),
5459 tdata->digest.len, digest_buffer);
5461 digest = rte_pktmbuf_read(ut_params->ibuf,
5462 (tdata->digest.offset_bytes == 0 ?
5463 plaintext_pad_len : tdata->digest.offset_bytes),
5464 tdata->digest.len, digest_buffer);
5466 debug_hexdump(stdout, "digest:", digest,
5468 debug_hexdump(stdout, "digest expected:",
5469 tdata->digest.data, tdata->digest.len);
5474 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5476 tdata->plaintext.data,
5477 tdata->plaintext.len >> 3,
5478 "ZUC Plaintext data not as expected");
5480 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5482 tdata->ciphertext.data,
5483 tdata->validDataLenInBits.len,
5484 "ZUC Ciphertext data not as expected");
5486 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5489 DIGEST_BYTE_LENGTH_KASUMI_F9,
5490 "ZUC Generated auth tag not as expected");
5496 test_kasumi_encryption_test_case_1(void)
5498 return test_kasumi_encryption(&kasumi_test_case_1);
5502 test_kasumi_encryption_test_case_1_sgl(void)
5504 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5508 test_kasumi_encryption_test_case_1_oop(void)
5510 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5514 test_kasumi_encryption_test_case_1_oop_sgl(void)
5516 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5520 test_kasumi_encryption_test_case_2(void)
5522 return test_kasumi_encryption(&kasumi_test_case_2);
5526 test_kasumi_encryption_test_case_3(void)
5528 return test_kasumi_encryption(&kasumi_test_case_3);
5532 test_kasumi_encryption_test_case_4(void)
5534 return test_kasumi_encryption(&kasumi_test_case_4);
5538 test_kasumi_encryption_test_case_5(void)
5540 return test_kasumi_encryption(&kasumi_test_case_5);
5544 test_kasumi_decryption_test_case_1(void)
5546 return test_kasumi_decryption(&kasumi_test_case_1);
5550 test_kasumi_decryption_test_case_1_oop(void)
5552 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5556 test_kasumi_decryption_test_case_2(void)
5558 return test_kasumi_decryption(&kasumi_test_case_2);
5562 test_kasumi_decryption_test_case_3(void)
5564 return test_kasumi_decryption(&kasumi_test_case_3);
5568 test_kasumi_decryption_test_case_4(void)
5570 return test_kasumi_decryption(&kasumi_test_case_4);
5574 test_kasumi_decryption_test_case_5(void)
5576 return test_kasumi_decryption(&kasumi_test_case_5);
5579 test_snow3g_encryption_test_case_1(void)
5581 return test_snow3g_encryption(&snow3g_test_case_1);
5585 test_snow3g_encryption_test_case_1_oop(void)
5587 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5591 test_snow3g_encryption_test_case_1_oop_sgl(void)
5593 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5598 test_snow3g_encryption_test_case_1_offset_oop(void)
5600 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5604 test_snow3g_encryption_test_case_2(void)
5606 return test_snow3g_encryption(&snow3g_test_case_2);
5610 test_snow3g_encryption_test_case_3(void)
5612 return test_snow3g_encryption(&snow3g_test_case_3);
5616 test_snow3g_encryption_test_case_4(void)
5618 return test_snow3g_encryption(&snow3g_test_case_4);
5622 test_snow3g_encryption_test_case_5(void)
5624 return test_snow3g_encryption(&snow3g_test_case_5);
5628 test_snow3g_decryption_test_case_1(void)
5630 return test_snow3g_decryption(&snow3g_test_case_1);
5634 test_snow3g_decryption_test_case_1_oop(void)
5636 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5640 test_snow3g_decryption_test_case_2(void)
5642 return test_snow3g_decryption(&snow3g_test_case_2);
5646 test_snow3g_decryption_test_case_3(void)
5648 return test_snow3g_decryption(&snow3g_test_case_3);
5652 test_snow3g_decryption_test_case_4(void)
5654 return test_snow3g_decryption(&snow3g_test_case_4);
5658 test_snow3g_decryption_test_case_5(void)
5660 return test_snow3g_decryption(&snow3g_test_case_5);
5664 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5665 * Pattern digest from snow3g_test_data must be allocated as
5666 * 4 last bytes in plaintext.
5669 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5670 struct snow3g_hash_test_data *output)
5672 if ((pattern != NULL) && (output != NULL)) {
5673 output->key.len = pattern->key.len;
5675 memcpy(output->key.data,
5676 pattern->key.data, pattern->key.len);
5678 output->auth_iv.len = pattern->auth_iv.len;
5680 memcpy(output->auth_iv.data,
5681 pattern->auth_iv.data, pattern->auth_iv.len);
5683 output->plaintext.len = pattern->plaintext.len;
5685 memcpy(output->plaintext.data,
5686 pattern->plaintext.data, pattern->plaintext.len >> 3);
5688 output->digest.len = pattern->digest.len;
5690 memcpy(output->digest.data,
5691 &pattern->plaintext.data[pattern->digest.offset_bytes],
5692 pattern->digest.len);
5694 output->validAuthLenInBits.len =
5695 pattern->validAuthLenInBits.len;
5700 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5703 test_snow3g_decryption_with_digest_test_case_1(void)
5705 struct snow3g_hash_test_data snow3g_hash_data;
5708 * Function prepare data for hash veryfication test case.
5709 * Digest is allocated in 4 last bytes in plaintext, pattern.
5711 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5713 return test_snow3g_decryption(&snow3g_test_case_7) &
5714 test_snow3g_authentication_verify(&snow3g_hash_data);
5718 test_snow3g_cipher_auth_test_case_1(void)
5720 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5724 test_snow3g_auth_cipher_test_case_1(void)
5726 return test_snow3g_auth_cipher(
5727 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5731 test_snow3g_auth_cipher_test_case_2(void)
5733 return test_snow3g_auth_cipher(
5734 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5738 test_snow3g_auth_cipher_test_case_2_oop(void)
5740 return test_snow3g_auth_cipher(
5741 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5745 test_snow3g_auth_cipher_part_digest_enc(void)
5747 return test_snow3g_auth_cipher(
5748 &snow3g_auth_cipher_partial_digest_encryption,
5753 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5755 return test_snow3g_auth_cipher(
5756 &snow3g_auth_cipher_partial_digest_encryption,
5761 test_snow3g_auth_cipher_test_case_3_sgl(void)
5763 return test_snow3g_auth_cipher_sgl(
5764 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5768 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5770 return test_snow3g_auth_cipher_sgl(
5771 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5775 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5777 return test_snow3g_auth_cipher_sgl(
5778 &snow3g_auth_cipher_partial_digest_encryption,
5783 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5785 return test_snow3g_auth_cipher_sgl(
5786 &snow3g_auth_cipher_partial_digest_encryption,
5791 test_snow3g_auth_cipher_verify_test_case_1(void)
5793 return test_snow3g_auth_cipher(
5794 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5798 test_snow3g_auth_cipher_verify_test_case_2(void)
5800 return test_snow3g_auth_cipher(
5801 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5805 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5807 return test_snow3g_auth_cipher(
5808 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5812 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5814 return test_snow3g_auth_cipher(
5815 &snow3g_auth_cipher_partial_digest_encryption,
5820 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5822 return test_snow3g_auth_cipher(
5823 &snow3g_auth_cipher_partial_digest_encryption,
5828 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5830 return test_snow3g_auth_cipher_sgl(
5831 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5835 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5837 return test_snow3g_auth_cipher_sgl(
5838 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5842 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5844 return test_snow3g_auth_cipher_sgl(
5845 &snow3g_auth_cipher_partial_digest_encryption,
5850 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5852 return test_snow3g_auth_cipher_sgl(
5853 &snow3g_auth_cipher_partial_digest_encryption,
5858 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5860 return test_snow3g_auth_cipher(
5861 &snow3g_test_case_7, IN_PLACE, 0);
5865 test_kasumi_auth_cipher_test_case_1(void)
5867 return test_kasumi_auth_cipher(
5868 &kasumi_test_case_3, IN_PLACE, 0);
5872 test_kasumi_auth_cipher_test_case_2(void)
5874 return test_kasumi_auth_cipher(
5875 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5879 test_kasumi_auth_cipher_test_case_2_oop(void)
5881 return test_kasumi_auth_cipher(
5882 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5886 test_kasumi_auth_cipher_test_case_2_sgl(void)
5888 return test_kasumi_auth_cipher_sgl(
5889 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5893 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5895 return test_kasumi_auth_cipher_sgl(
5896 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5900 test_kasumi_auth_cipher_verify_test_case_1(void)
5902 return test_kasumi_auth_cipher(
5903 &kasumi_test_case_3, IN_PLACE, 1);
5907 test_kasumi_auth_cipher_verify_test_case_2(void)
5909 return test_kasumi_auth_cipher(
5910 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5914 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5916 return test_kasumi_auth_cipher(
5917 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5921 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5923 return test_kasumi_auth_cipher_sgl(
5924 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5928 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5930 return test_kasumi_auth_cipher_sgl(
5931 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5935 test_kasumi_cipher_auth_test_case_1(void)
5937 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5941 test_zuc_encryption_test_case_1(void)
5943 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5947 test_zuc_encryption_test_case_2(void)
5949 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5953 test_zuc_encryption_test_case_3(void)
5955 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5959 test_zuc_encryption_test_case_4(void)
5961 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5965 test_zuc_encryption_test_case_5(void)
5967 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5971 test_zuc_encryption_test_case_6_sgl(void)
5973 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5977 test_zuc_hash_generate_test_case_1(void)
5979 return test_zuc_authentication(&zuc_test_case_auth_1b);
5983 test_zuc_hash_generate_test_case_2(void)
5985 return test_zuc_authentication(&zuc_test_case_auth_90b);
5989 test_zuc_hash_generate_test_case_3(void)
5991 return test_zuc_authentication(&zuc_test_case_auth_577b);
5995 test_zuc_hash_generate_test_case_4(void)
5997 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6001 test_zuc_hash_generate_test_case_5(void)
6003 return test_zuc_authentication(&zuc_test_auth_5670b);
6007 test_zuc_hash_generate_test_case_6(void)
6009 return test_zuc_authentication(&zuc_test_case_auth_128b);
6013 test_zuc_hash_generate_test_case_7(void)
6015 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6019 test_zuc_hash_generate_test_case_8(void)
6021 return test_zuc_authentication(&zuc_test_case_auth_584b);
6025 test_zuc_cipher_auth_test_case_1(void)
6027 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6031 test_zuc_cipher_auth_test_case_2(void)
6033 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6037 test_zuc_auth_cipher_test_case_1(void)
6039 return test_zuc_auth_cipher(
6040 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6044 test_zuc_auth_cipher_test_case_1_oop(void)
6046 return test_zuc_auth_cipher(
6047 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6051 test_zuc_auth_cipher_test_case_1_sgl(void)
6053 return test_zuc_auth_cipher_sgl(
6054 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6058 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6060 return test_zuc_auth_cipher_sgl(
6061 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6065 test_zuc_auth_cipher_verify_test_case_1(void)
6067 return test_zuc_auth_cipher(
6068 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6072 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6074 return test_zuc_auth_cipher(
6075 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6079 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6081 return test_zuc_auth_cipher_sgl(
6082 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6086 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6088 return test_zuc_auth_cipher_sgl(
6089 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6093 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6095 uint8_t dev_id = testsuite_params.valid_devs[0];
6097 struct rte_cryptodev_sym_capability_idx cap_idx;
6099 /* Check if device supports particular cipher algorithm */
6100 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6101 cap_idx.algo.cipher = tdata->cipher_algo;
6102 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6105 /* Check if device supports particular hash algorithm */
6106 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6107 cap_idx.algo.auth = tdata->auth_algo;
6108 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6115 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6116 uint8_t op_mode, uint8_t verify)
6118 struct crypto_testsuite_params *ts_params = &testsuite_params;
6119 struct crypto_unittest_params *ut_params = &unittest_params;
6123 uint8_t *plaintext = NULL, *ciphertext = NULL;
6124 unsigned int plaintext_pad_len;
6125 unsigned int plaintext_len;
6126 unsigned int ciphertext_pad_len;
6127 unsigned int ciphertext_len;
6129 struct rte_cryptodev_info dev_info;
6130 struct rte_crypto_op *op;
6132 /* Check if device supports particular algorithms separately */
6133 if (test_mixed_check_if_unsupported(tdata))
6136 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6138 uint64_t feat_flags = dev_info.feature_flags;
6140 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6141 printf("Device doesn't support digest encrypted.\n");
6145 /* Create the session */
6147 retval = create_wireless_algo_cipher_auth_session(
6148 ts_params->valid_devs[0],
6149 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6150 RTE_CRYPTO_AUTH_OP_VERIFY,
6153 tdata->auth_key.data, tdata->auth_key.len,
6154 tdata->auth_iv.len, tdata->digest_enc.len,
6155 tdata->cipher_iv.len);
6157 retval = create_wireless_algo_auth_cipher_session(
6158 ts_params->valid_devs[0],
6159 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6160 RTE_CRYPTO_AUTH_OP_GENERATE,
6163 tdata->auth_key.data, tdata->auth_key.len,
6164 tdata->auth_iv.len, tdata->digest_enc.len,
6165 tdata->cipher_iv.len);
6169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6170 if (op_mode == OUT_OF_PLACE)
6171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6173 /* clear mbuf payload */
6174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6175 rte_pktmbuf_tailroom(ut_params->ibuf));
6176 if (op_mode == OUT_OF_PLACE)
6177 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6178 rte_pktmbuf_tailroom(ut_params->obuf));
6180 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6181 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6182 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6183 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6186 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6187 ciphertext_pad_len);
6188 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6189 if (op_mode == OUT_OF_PLACE)
6190 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6191 debug_hexdump(stdout, "ciphertext:", ciphertext,
6194 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6196 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6197 if (op_mode == OUT_OF_PLACE)
6198 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6199 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6202 /* Create the operation */
6203 retval = create_wireless_algo_auth_cipher_operation(
6204 tdata->digest_enc.data, tdata->digest_enc.len,
6205 tdata->cipher_iv.data, tdata->cipher_iv.len,
6206 tdata->auth_iv.data, tdata->auth_iv.len,
6207 (tdata->digest_enc.offset == 0 ?
6209 : tdata->digest_enc.offset),
6210 tdata->validCipherLen.len_bits,
6211 tdata->cipher.offset_bits,
6212 tdata->validAuthLen.len_bits,
6213 tdata->auth.offset_bits,
6214 op_mode, 0, verify);
6219 op = process_crypto_request(ts_params->valid_devs[0],
6222 /* Check if the op failed because the device doesn't */
6223 /* support this particular combination of algorithms */
6224 if (op == NULL && ut_params->op->status ==
6225 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6226 printf("Device doesn't support this mixed combination. "
6232 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6234 ut_params->obuf = (op_mode == IN_PLACE ?
6235 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6238 if (ut_params->obuf)
6239 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6242 plaintext = ciphertext +
6243 (tdata->cipher.offset_bits >> 3);
6245 debug_hexdump(stdout, "plaintext:", plaintext,
6246 tdata->plaintext.len_bits >> 3);
6247 debug_hexdump(stdout, "plaintext expected:",
6248 tdata->plaintext.data,
6249 tdata->plaintext.len_bits >> 3);
6251 if (ut_params->obuf)
6252 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6255 ciphertext = plaintext;
6257 debug_hexdump(stdout, "ciphertext:", ciphertext,
6259 debug_hexdump(stdout, "ciphertext expected:",
6260 tdata->ciphertext.data,
6261 tdata->ciphertext.len_bits >> 3);
6263 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6264 + (tdata->digest_enc.offset == 0 ?
6265 plaintext_pad_len : tdata->digest_enc.offset);
6267 debug_hexdump(stdout, "digest:", ut_params->digest,
6268 tdata->digest_enc.len);
6269 debug_hexdump(stdout, "digest expected:",
6270 tdata->digest_enc.data,
6271 tdata->digest_enc.len);
6276 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6278 tdata->plaintext.data,
6279 tdata->plaintext.len_bits >> 3,
6280 "Plaintext data not as expected");
6282 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6284 tdata->ciphertext.data,
6285 tdata->validDataLen.len_bits,
6286 "Ciphertext data not as expected");
6288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6290 tdata->digest_enc.data,
6291 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6292 "Generated auth tag not as expected");
6295 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6296 "crypto op processing failed");
6302 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6303 uint8_t op_mode, uint8_t verify)
6305 struct crypto_testsuite_params *ts_params = &testsuite_params;
6306 struct crypto_unittest_params *ut_params = &unittest_params;
6310 const uint8_t *plaintext = NULL;
6311 const uint8_t *ciphertext = NULL;
6312 const uint8_t *digest = NULL;
6313 unsigned int plaintext_pad_len;
6314 unsigned int plaintext_len;
6315 unsigned int ciphertext_pad_len;
6316 unsigned int ciphertext_len;
6317 uint8_t buffer[10000];
6318 uint8_t digest_buffer[10000];
6320 struct rte_cryptodev_info dev_info;
6321 struct rte_crypto_op *op;
6323 /* Check if device supports particular algorithms */
6324 if (test_mixed_check_if_unsupported(tdata))
6327 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6329 uint64_t feat_flags = dev_info.feature_flags;
6331 if (op_mode == IN_PLACE) {
6332 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6333 printf("Device doesn't support in-place scatter-gather "
6334 "in both input and output mbufs.\n");
6338 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6339 printf("Device doesn't support out-of-place scatter-gather "
6340 "in both input and output mbufs.\n");
6343 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6344 printf("Device doesn't support digest encrypted.\n");
6349 /* Create the session */
6351 retval = create_wireless_algo_cipher_auth_session(
6352 ts_params->valid_devs[0],
6353 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6354 RTE_CRYPTO_AUTH_OP_VERIFY,
6357 tdata->auth_key.data, tdata->auth_key.len,
6358 tdata->auth_iv.len, tdata->digest_enc.len,
6359 tdata->cipher_iv.len);
6361 retval = create_wireless_algo_auth_cipher_session(
6362 ts_params->valid_devs[0],
6363 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6364 RTE_CRYPTO_AUTH_OP_GENERATE,
6367 tdata->auth_key.data, tdata->auth_key.len,
6368 tdata->auth_iv.len, tdata->digest_enc.len,
6369 tdata->cipher_iv.len);
6373 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6374 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6375 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6376 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6378 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6379 ciphertext_pad_len, 15, 0);
6380 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6381 "Failed to allocate input buffer in mempool");
6383 if (op_mode == OUT_OF_PLACE) {
6384 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6385 plaintext_pad_len, 15, 0);
6386 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6387 "Failed to allocate output buffer in mempool");
6391 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6392 tdata->ciphertext.data);
6393 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6394 ciphertext_len, buffer);
6395 debug_hexdump(stdout, "ciphertext:", ciphertext,
6398 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6399 tdata->plaintext.data);
6400 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6401 plaintext_len, buffer);
6402 debug_hexdump(stdout, "plaintext:", plaintext,
6405 memset(buffer, 0, sizeof(buffer));
6407 /* Create the operation */
6408 retval = create_wireless_algo_auth_cipher_operation(
6409 tdata->digest_enc.data, tdata->digest_enc.len,
6410 tdata->cipher_iv.data, tdata->cipher_iv.len,
6411 tdata->auth_iv.data, tdata->auth_iv.len,
6412 (tdata->digest_enc.offset == 0 ?
6414 : tdata->digest_enc.offset),
6415 tdata->validCipherLen.len_bits,
6416 tdata->cipher.offset_bits,
6417 tdata->validAuthLen.len_bits,
6418 tdata->auth.offset_bits,
6419 op_mode, 1, verify);
6424 op = process_crypto_request(ts_params->valid_devs[0],
6427 /* Check if the op failed because the device doesn't */
6428 /* support this particular combination of algorithms */
6429 if (op == NULL && ut_params->op->status ==
6430 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6431 printf("Device doesn't support this mixed combination. "
6438 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6440 ut_params->obuf = (op_mode == IN_PLACE ?
6441 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6444 if (ut_params->obuf)
6445 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6446 plaintext_len, buffer);
6448 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6449 plaintext_len, buffer);
6451 debug_hexdump(stdout, "plaintext:", plaintext,
6452 (tdata->plaintext.len_bits >> 3) -
6453 tdata->digest_enc.len);
6454 debug_hexdump(stdout, "plaintext expected:",
6455 tdata->plaintext.data,
6456 (tdata->plaintext.len_bits >> 3) -
6457 tdata->digest_enc.len);
6459 if (ut_params->obuf)
6460 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6461 ciphertext_len, buffer);
6463 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6464 ciphertext_len, buffer);
6466 debug_hexdump(stdout, "ciphertext:", ciphertext,
6468 debug_hexdump(stdout, "ciphertext expected:",
6469 tdata->ciphertext.data,
6470 tdata->ciphertext.len_bits >> 3);
6472 if (ut_params->obuf)
6473 digest = rte_pktmbuf_read(ut_params->obuf,
6474 (tdata->digest_enc.offset == 0 ?
6476 tdata->digest_enc.offset),
6477 tdata->digest_enc.len, digest_buffer);
6479 digest = rte_pktmbuf_read(ut_params->ibuf,
6480 (tdata->digest_enc.offset == 0 ?
6482 tdata->digest_enc.offset),
6483 tdata->digest_enc.len, digest_buffer);
6485 debug_hexdump(stdout, "digest:", digest,
6486 tdata->digest_enc.len);
6487 debug_hexdump(stdout, "digest expected:",
6488 tdata->digest_enc.data, tdata->digest_enc.len);
6493 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6495 tdata->plaintext.data,
6496 tdata->plaintext.len_bits >> 3,
6497 "Plaintext data not as expected");
6499 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6501 tdata->ciphertext.data,
6502 tdata->validDataLen.len_bits,
6503 "Ciphertext data not as expected");
6504 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6506 tdata->digest_enc.data,
6507 tdata->digest_enc.len,
6508 "Generated auth tag not as expected");
6511 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6512 "crypto op processing failed");
6517 /** AUTH AES CMAC + CIPHER AES CTR */
6520 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6522 return test_mixed_auth_cipher(
6523 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6527 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6529 return test_mixed_auth_cipher(
6530 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6534 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6536 return test_mixed_auth_cipher_sgl(
6537 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6541 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6543 return test_mixed_auth_cipher_sgl(
6544 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6548 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6550 return test_mixed_auth_cipher(
6551 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6555 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6557 return test_mixed_auth_cipher(
6558 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6562 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6564 return test_mixed_auth_cipher_sgl(
6565 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6569 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6571 return test_mixed_auth_cipher_sgl(
6572 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6575 /** MIXED AUTH + CIPHER */
6578 test_auth_zuc_cipher_snow_test_case_1(void)
6580 return test_mixed_auth_cipher(
6581 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6585 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6587 return test_mixed_auth_cipher(
6588 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6592 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6594 return test_mixed_auth_cipher(
6595 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6599 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6601 return test_mixed_auth_cipher(
6602 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6606 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6608 return test_mixed_auth_cipher(
6609 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6613 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6615 return test_mixed_auth_cipher(
6616 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6620 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6622 return test_mixed_auth_cipher(
6623 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6627 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6629 return test_mixed_auth_cipher(
6630 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6634 test_auth_snow_cipher_zuc_test_case_1(void)
6636 return test_mixed_auth_cipher(
6637 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6641 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6643 return test_mixed_auth_cipher(
6644 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6648 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6650 return test_mixed_auth_cipher(
6651 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6655 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6657 return test_mixed_auth_cipher(
6658 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6662 test_auth_null_cipher_snow_test_case_1(void)
6664 return test_mixed_auth_cipher(
6665 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6669 test_verify_auth_null_cipher_snow_test_case_1(void)
6671 return test_mixed_auth_cipher(
6672 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6676 test_auth_null_cipher_zuc_test_case_1(void)
6678 return test_mixed_auth_cipher(
6679 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6683 test_verify_auth_null_cipher_zuc_test_case_1(void)
6685 return test_mixed_auth_cipher(
6686 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6690 test_auth_snow_cipher_null_test_case_1(void)
6692 return test_mixed_auth_cipher(
6693 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6697 test_verify_auth_snow_cipher_null_test_case_1(void)
6699 return test_mixed_auth_cipher(
6700 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6704 test_auth_zuc_cipher_null_test_case_1(void)
6706 return test_mixed_auth_cipher(
6707 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6711 test_verify_auth_zuc_cipher_null_test_case_1(void)
6713 return test_mixed_auth_cipher(
6714 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6718 test_auth_null_cipher_aes_ctr_test_case_1(void)
6720 return test_mixed_auth_cipher(
6721 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6725 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6727 return test_mixed_auth_cipher(
6728 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6732 test_auth_aes_cmac_cipher_null_test_case_1(void)
6734 return test_mixed_auth_cipher(
6735 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6739 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6741 return test_mixed_auth_cipher(
6742 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6745 /* ***** AEAD algorithm Tests ***** */
6748 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6749 enum rte_crypto_aead_operation op,
6750 const uint8_t *key, const uint8_t key_len,
6751 const uint16_t aad_len, const uint8_t auth_len,
6754 uint8_t aead_key[key_len];
6756 struct crypto_testsuite_params *ts_params = &testsuite_params;
6757 struct crypto_unittest_params *ut_params = &unittest_params;
6759 memcpy(aead_key, key, key_len);
6761 /* Setup AEAD Parameters */
6762 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6763 ut_params->aead_xform.next = NULL;
6764 ut_params->aead_xform.aead.algo = algo;
6765 ut_params->aead_xform.aead.op = op;
6766 ut_params->aead_xform.aead.key.data = aead_key;
6767 ut_params->aead_xform.aead.key.length = key_len;
6768 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6769 ut_params->aead_xform.aead.iv.length = iv_len;
6770 ut_params->aead_xform.aead.digest_length = auth_len;
6771 ut_params->aead_xform.aead.aad_length = aad_len;
6773 debug_hexdump(stdout, "key:", key, key_len);
6775 /* Create Crypto session*/
6776 ut_params->sess = rte_cryptodev_sym_session_create(
6777 ts_params->session_mpool);
6779 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6780 &ut_params->aead_xform,
6781 ts_params->session_priv_mpool);
6783 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6789 create_aead_xform(struct rte_crypto_op *op,
6790 enum rte_crypto_aead_algorithm algo,
6791 enum rte_crypto_aead_operation aead_op,
6792 uint8_t *key, const uint8_t key_len,
6793 const uint8_t aad_len, const uint8_t auth_len,
6796 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6797 "failed to allocate space for crypto transform");
6799 struct rte_crypto_sym_op *sym_op = op->sym;
6801 /* Setup AEAD Parameters */
6802 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6803 sym_op->xform->next = NULL;
6804 sym_op->xform->aead.algo = algo;
6805 sym_op->xform->aead.op = aead_op;
6806 sym_op->xform->aead.key.data = key;
6807 sym_op->xform->aead.key.length = key_len;
6808 sym_op->xform->aead.iv.offset = IV_OFFSET;
6809 sym_op->xform->aead.iv.length = iv_len;
6810 sym_op->xform->aead.digest_length = auth_len;
6811 sym_op->xform->aead.aad_length = aad_len;
6813 debug_hexdump(stdout, "key:", key, key_len);
6819 create_aead_operation(enum rte_crypto_aead_operation op,
6820 const struct aead_test_data *tdata)
6822 struct crypto_testsuite_params *ts_params = &testsuite_params;
6823 struct crypto_unittest_params *ut_params = &unittest_params;
6825 uint8_t *plaintext, *ciphertext;
6826 unsigned int aad_pad_len, plaintext_pad_len;
6828 /* Generate Crypto op data structure */
6829 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6830 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6831 TEST_ASSERT_NOT_NULL(ut_params->op,
6832 "Failed to allocate symmetric crypto operation struct");
6834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6836 /* Append aad data */
6837 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6838 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6839 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6841 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6842 "no room to append aad");
6844 sym_op->aead.aad.phys_addr =
6845 rte_pktmbuf_iova(ut_params->ibuf);
6846 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6847 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6848 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6851 /* Append IV at the end of the crypto operation*/
6852 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6853 uint8_t *, IV_OFFSET);
6855 /* Copy IV 1 byte after the IV pointer, according to the API */
6856 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6857 debug_hexdump(stdout, "iv:", iv_ptr,
6860 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6861 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6863 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6864 "no room to append aad");
6866 sym_op->aead.aad.phys_addr =
6867 rte_pktmbuf_iova(ut_params->ibuf);
6868 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6869 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6872 /* Append IV at the end of the crypto operation*/
6873 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6874 uint8_t *, IV_OFFSET);
6876 if (tdata->iv.len == 0) {
6877 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6878 debug_hexdump(stdout, "iv:", iv_ptr,
6881 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6882 debug_hexdump(stdout, "iv:", iv_ptr,
6887 /* Append plaintext/ciphertext */
6888 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6889 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6890 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6892 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6894 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6895 debug_hexdump(stdout, "plaintext:", plaintext,
6896 tdata->plaintext.len);
6898 if (ut_params->obuf) {
6899 ciphertext = (uint8_t *)rte_pktmbuf_append(
6901 plaintext_pad_len + aad_pad_len);
6902 TEST_ASSERT_NOT_NULL(ciphertext,
6903 "no room to append ciphertext");
6905 memset(ciphertext + aad_pad_len, 0,
6906 tdata->ciphertext.len);
6909 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6910 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6912 TEST_ASSERT_NOT_NULL(ciphertext,
6913 "no room to append ciphertext");
6915 memcpy(ciphertext, tdata->ciphertext.data,
6916 tdata->ciphertext.len);
6917 debug_hexdump(stdout, "ciphertext:", ciphertext,
6918 tdata->ciphertext.len);
6920 if (ut_params->obuf) {
6921 plaintext = (uint8_t *)rte_pktmbuf_append(
6923 plaintext_pad_len + aad_pad_len);
6924 TEST_ASSERT_NOT_NULL(plaintext,
6925 "no room to append plaintext");
6927 memset(plaintext + aad_pad_len, 0,
6928 tdata->plaintext.len);
6932 /* Append digest data */
6933 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6934 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6935 ut_params->obuf ? ut_params->obuf :
6937 tdata->auth_tag.len);
6938 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6939 "no room to append digest");
6940 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6941 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6942 ut_params->obuf ? ut_params->obuf :
6947 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6948 ut_params->ibuf, tdata->auth_tag.len);
6949 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6950 "no room to append digest");
6951 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6953 plaintext_pad_len + aad_pad_len);
6955 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6956 tdata->auth_tag.len);
6957 debug_hexdump(stdout, "digest:",
6958 sym_op->aead.digest.data,
6959 tdata->auth_tag.len);
6962 sym_op->aead.data.length = tdata->plaintext.len;
6963 sym_op->aead.data.offset = aad_pad_len;
6969 test_authenticated_encryption(const struct aead_test_data *tdata)
6971 struct crypto_testsuite_params *ts_params = &testsuite_params;
6972 struct crypto_unittest_params *ut_params = &unittest_params;
6975 uint8_t *ciphertext, *auth_tag;
6976 uint16_t plaintext_pad_len;
6979 /* Verify the capabilities */
6980 struct rte_cryptodev_sym_capability_idx cap_idx;
6981 const struct rte_cryptodev_symmetric_capability *capability;
6982 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6983 cap_idx.algo.aead = tdata->algo;
6984 capability = rte_cryptodev_sym_capability_get(
6985 ts_params->valid_devs[0], &cap_idx);
6986 if (capability == NULL)
6988 if (rte_cryptodev_sym_capability_check_aead(
6989 capability, tdata->key.len, tdata->auth_tag.len,
6990 tdata->aad.len, tdata->iv.len))
6993 /* Create AEAD session */
6994 retval = create_aead_session(ts_params->valid_devs[0],
6996 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6997 tdata->key.data, tdata->key.len,
6998 tdata->aad.len, tdata->auth_tag.len,
7003 if (tdata->aad.len > MBUF_SIZE) {
7004 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7005 /* Populate full size of add data */
7006 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7007 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7011 /* clear mbuf payload */
7012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7013 rte_pktmbuf_tailroom(ut_params->ibuf));
7015 /* Create AEAD operation */
7016 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7020 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7022 ut_params->op->sym->m_src = ut_params->ibuf;
7024 /* Process crypto operation */
7025 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7026 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7028 TEST_ASSERT_NOT_NULL(
7029 process_crypto_request(ts_params->valid_devs[0],
7030 ut_params->op), "failed to process sym crypto op");
7032 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7033 "crypto op processing failed");
7035 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7037 if (ut_params->op->sym->m_dst) {
7038 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7040 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7041 uint8_t *, plaintext_pad_len);
7043 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7045 ut_params->op->sym->cipher.data.offset);
7046 auth_tag = ciphertext + plaintext_pad_len;
7049 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7050 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7053 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7055 tdata->ciphertext.data,
7056 tdata->ciphertext.len,
7057 "Ciphertext data not as expected");
7059 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7061 tdata->auth_tag.data,
7062 tdata->auth_tag.len,
7063 "Generated auth tag not as expected");
7069 #ifdef RTE_LIBRTE_SECURITY
7070 /* Basic algorithm run function for async inplace mode.
7071 * Creates a session from input parameters and runs one operation
7072 * on input_vec. Checks the output of the crypto operation against
7076 test_pdcp_proto(int i, int oop,
7077 enum rte_crypto_cipher_operation opc,
7078 enum rte_crypto_auth_operation opa,
7080 unsigned int input_vec_len,
7081 uint8_t *output_vec,
7082 unsigned int output_vec_len)
7084 struct crypto_testsuite_params *ts_params = &testsuite_params;
7085 struct crypto_unittest_params *ut_params = &unittest_params;
7087 int ret = TEST_SUCCESS;
7088 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7089 rte_cryptodev_get_sec_ctx(
7090 ts_params->valid_devs[0]);
7092 /* Verify the capabilities */
7093 struct rte_security_capability_idx sec_cap_idx;
7095 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7096 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7097 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7098 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7101 /* Generate test mbuf data */
7102 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7104 /* clear mbuf payload */
7105 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7106 rte_pktmbuf_tailroom(ut_params->ibuf));
7108 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7110 memcpy(plaintext, input_vec, input_vec_len);
7112 /* Out of place support */
7115 * For out-op-place we need to alloc another mbuf
7117 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7118 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7121 /* Set crypto type as IPSEC */
7122 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7124 /* Setup Cipher Parameters */
7125 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7126 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7127 ut_params->cipher_xform.cipher.op = opc;
7128 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7129 ut_params->cipher_xform.cipher.key.length =
7130 pdcp_test_params[i].cipher_key_len;
7131 ut_params->cipher_xform.cipher.iv.length = 0;
7133 /* Setup HMAC Parameters if ICV header is required */
7134 if (pdcp_test_params[i].auth_alg != 0) {
7135 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7136 ut_params->auth_xform.next = NULL;
7137 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7138 ut_params->auth_xform.auth.op = opa;
7139 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7140 ut_params->auth_xform.auth.key.length =
7141 pdcp_test_params[i].auth_key_len;
7143 ut_params->cipher_xform.next = &ut_params->auth_xform;
7145 ut_params->cipher_xform.next = NULL;
7148 struct rte_security_session_conf sess_conf = {
7149 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7150 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7152 .bearer = pdcp_test_bearer[i],
7153 .domain = pdcp_test_params[i].domain,
7154 .pkt_dir = pdcp_test_packet_direction[i],
7155 .sn_size = pdcp_test_data_sn_size[i],
7156 .hfn = pdcp_test_hfn[i],
7157 .hfn_threshold = pdcp_test_hfn_threshold[i],
7159 .crypto_xform = &ut_params->cipher_xform
7162 /* Create security session */
7163 ut_params->sec_session = rte_security_session_create(ctx,
7164 &sess_conf, ts_params->session_priv_mpool);
7166 if (!ut_params->sec_session) {
7167 printf("TestCase %s()-%d line %d failed %s: ",
7168 __func__, i, __LINE__, "Failed to allocate session");
7173 /* Generate crypto op data structure */
7174 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7175 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7176 if (!ut_params->op) {
7177 printf("TestCase %s()-%d line %d failed %s: ",
7178 __func__, i, __LINE__,
7179 "Failed to allocate symmetric crypto operation struct");
7184 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7186 /* set crypto operation source mbuf */
7187 ut_params->op->sym->m_src = ut_params->ibuf;
7189 ut_params->op->sym->m_dst = ut_params->obuf;
7191 /* Process crypto operation */
7192 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7194 printf("TestCase %s()-%d line %d failed %s: ",
7195 __func__, i, __LINE__,
7196 "failed to process sym crypto op");
7201 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7202 printf("TestCase %s()-%d line %d failed %s: ",
7203 __func__, i, __LINE__, "crypto op processing failed");
7209 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7212 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7216 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7217 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7218 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7219 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7225 rte_crypto_op_free(ut_params->op);
7226 ut_params->op = NULL;
7228 if (ut_params->sec_session)
7229 rte_security_session_destroy(ctx, ut_params->sec_session);
7230 ut_params->sec_session = NULL;
7232 rte_pktmbuf_free(ut_params->ibuf);
7233 ut_params->ibuf = NULL;
7235 rte_pktmbuf_free(ut_params->obuf);
7236 ut_params->obuf = NULL;
7243 test_pdcp_proto_SGL(int i, int oop,
7244 enum rte_crypto_cipher_operation opc,
7245 enum rte_crypto_auth_operation opa,
7247 unsigned int input_vec_len,
7248 uint8_t *output_vec,
7249 unsigned int output_vec_len,
7251 uint32_t fragsz_oop)
7253 struct crypto_testsuite_params *ts_params = &testsuite_params;
7254 struct crypto_unittest_params *ut_params = &unittest_params;
7256 struct rte_mbuf *buf, *buf_oop = NULL;
7257 int ret = TEST_SUCCESS;
7261 unsigned int trn_data = 0;
7262 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7263 rte_cryptodev_get_sec_ctx(
7264 ts_params->valid_devs[0]);
7266 /* Verify the capabilities */
7267 struct rte_security_capability_idx sec_cap_idx;
7269 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7270 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7271 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7272 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7275 if (fragsz > input_vec_len)
7276 fragsz = input_vec_len;
7278 uint16_t plaintext_len = fragsz;
7279 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7281 if (fragsz_oop > output_vec_len)
7282 frag_size_oop = output_vec_len;
7285 if (input_vec_len % fragsz != 0) {
7286 if (input_vec_len / fragsz + 1 > 16)
7288 } else if (input_vec_len / fragsz > 16)
7291 /* Out of place support */
7294 * For out-op-place we need to alloc another mbuf
7296 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7297 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7298 buf_oop = ut_params->obuf;
7301 /* Generate test mbuf data */
7302 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7304 /* clear mbuf payload */
7305 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7306 rte_pktmbuf_tailroom(ut_params->ibuf));
7308 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7310 memcpy(plaintext, input_vec, plaintext_len);
7311 trn_data += plaintext_len;
7313 buf = ut_params->ibuf;
7316 * Loop until no more fragments
7319 while (trn_data < input_vec_len) {
7321 to_trn = (input_vec_len - trn_data < fragsz) ?
7322 (input_vec_len - trn_data) : fragsz;
7324 to_trn_tbl[ecx++] = to_trn;
7326 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7329 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7330 rte_pktmbuf_tailroom(buf));
7333 if (oop && !fragsz_oop) {
7335 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7336 buf_oop = buf_oop->next;
7337 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7338 0, rte_pktmbuf_tailroom(buf_oop));
7339 rte_pktmbuf_append(buf_oop, to_trn);
7342 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7345 memcpy(plaintext, input_vec + trn_data, to_trn);
7349 ut_params->ibuf->nb_segs = segs;
7352 if (fragsz_oop && oop) {
7356 trn_data = frag_size_oop;
7357 while (trn_data < output_vec_len) {
7360 (output_vec_len - trn_data <
7362 (output_vec_len - trn_data) :
7365 to_trn_tbl[ecx++] = to_trn;
7368 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7369 buf_oop = buf_oop->next;
7370 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7371 0, rte_pktmbuf_tailroom(buf_oop));
7372 rte_pktmbuf_append(buf_oop, to_trn);
7376 ut_params->obuf->nb_segs = segs;
7379 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7381 /* Setup Cipher Parameters */
7382 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7383 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7384 ut_params->cipher_xform.cipher.op = opc;
7385 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7386 ut_params->cipher_xform.cipher.key.length =
7387 pdcp_test_params[i].cipher_key_len;
7388 ut_params->cipher_xform.cipher.iv.length = 0;
7390 /* Setup HMAC Parameters if ICV header is required */
7391 if (pdcp_test_params[i].auth_alg != 0) {
7392 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7393 ut_params->auth_xform.next = NULL;
7394 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7395 ut_params->auth_xform.auth.op = opa;
7396 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7397 ut_params->auth_xform.auth.key.length =
7398 pdcp_test_params[i].auth_key_len;
7400 ut_params->cipher_xform.next = &ut_params->auth_xform;
7402 ut_params->cipher_xform.next = NULL;
7405 struct rte_security_session_conf sess_conf = {
7406 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7407 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7409 .bearer = pdcp_test_bearer[i],
7410 .domain = pdcp_test_params[i].domain,
7411 .pkt_dir = pdcp_test_packet_direction[i],
7412 .sn_size = pdcp_test_data_sn_size[i],
7413 .hfn = pdcp_test_hfn[i],
7414 .hfn_threshold = pdcp_test_hfn_threshold[i],
7416 .crypto_xform = &ut_params->cipher_xform
7419 /* Create security session */
7420 ut_params->sec_session = rte_security_session_create(ctx,
7421 &sess_conf, ts_params->session_priv_mpool);
7423 if (!ut_params->sec_session) {
7424 printf("TestCase %s()-%d line %d failed %s: ",
7425 __func__, i, __LINE__, "Failed to allocate session");
7430 /* Generate crypto op data structure */
7431 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7432 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7433 if (!ut_params->op) {
7434 printf("TestCase %s()-%d line %d failed %s: ",
7435 __func__, i, __LINE__,
7436 "Failed to allocate symmetric crypto operation struct");
7441 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7443 /* set crypto operation source mbuf */
7444 ut_params->op->sym->m_src = ut_params->ibuf;
7446 ut_params->op->sym->m_dst = ut_params->obuf;
7448 /* Process crypto operation */
7449 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7451 printf("TestCase %s()-%d line %d failed %s: ",
7452 __func__, i, __LINE__,
7453 "failed to process sym crypto op");
7458 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7459 printf("TestCase %s()-%d line %d failed %s: ",
7460 __func__, i, __LINE__, "crypto op processing failed");
7466 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7469 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7473 fragsz = frag_size_oop;
7474 if (memcmp(ciphertext, output_vec, fragsz)) {
7475 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7476 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7477 rte_hexdump(stdout, "reference", output_vec, fragsz);
7482 buf = ut_params->op->sym->m_src->next;
7484 buf = ut_params->op->sym->m_dst->next;
7486 unsigned int off = fragsz;
7490 ciphertext = rte_pktmbuf_mtod(buf,
7492 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7493 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7494 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7495 rte_hexdump(stdout, "reference", output_vec + off,
7500 off += to_trn_tbl[ecx++];
7504 rte_crypto_op_free(ut_params->op);
7505 ut_params->op = NULL;
7507 if (ut_params->sec_session)
7508 rte_security_session_destroy(ctx, ut_params->sec_session);
7509 ut_params->sec_session = NULL;
7511 rte_pktmbuf_free(ut_params->ibuf);
7512 ut_params->ibuf = NULL;
7514 rte_pktmbuf_free(ut_params->obuf);
7515 ut_params->obuf = NULL;
7522 test_pdcp_proto_cplane_encap(int i)
7524 return test_pdcp_proto(i, 0,
7525 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7526 RTE_CRYPTO_AUTH_OP_GENERATE,
7527 pdcp_test_data_in[i],
7528 pdcp_test_data_in_len[i],
7529 pdcp_test_data_out[i],
7530 pdcp_test_data_in_len[i]+4);
7534 test_pdcp_proto_uplane_encap(int i)
7536 return test_pdcp_proto(i, 0,
7537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7538 RTE_CRYPTO_AUTH_OP_GENERATE,
7539 pdcp_test_data_in[i],
7540 pdcp_test_data_in_len[i],
7541 pdcp_test_data_out[i],
7542 pdcp_test_data_in_len[i]);
7547 test_pdcp_proto_uplane_encap_with_int(int i)
7549 return test_pdcp_proto(i, 0,
7550 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7551 RTE_CRYPTO_AUTH_OP_GENERATE,
7552 pdcp_test_data_in[i],
7553 pdcp_test_data_in_len[i],
7554 pdcp_test_data_out[i],
7555 pdcp_test_data_in_len[i] + 4);
7559 test_pdcp_proto_cplane_decap(int i)
7561 return test_pdcp_proto(i, 0,
7562 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7563 RTE_CRYPTO_AUTH_OP_VERIFY,
7564 pdcp_test_data_out[i],
7565 pdcp_test_data_in_len[i] + 4,
7566 pdcp_test_data_in[i],
7567 pdcp_test_data_in_len[i]);
7571 test_pdcp_proto_uplane_decap(int i)
7573 return test_pdcp_proto(i, 0,
7574 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7575 RTE_CRYPTO_AUTH_OP_VERIFY,
7576 pdcp_test_data_out[i],
7577 pdcp_test_data_in_len[i],
7578 pdcp_test_data_in[i],
7579 pdcp_test_data_in_len[i]);
7583 test_pdcp_proto_uplane_decap_with_int(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7587 RTE_CRYPTO_AUTH_OP_VERIFY,
7588 pdcp_test_data_out[i],
7589 pdcp_test_data_in_len[i] + 4,
7590 pdcp_test_data_in[i],
7591 pdcp_test_data_in_len[i]);
7595 test_PDCP_PROTO_SGL_in_place_32B(void)
7597 /* i can be used for running any PDCP case
7598 * In this case it is uplane 12-bit AES-SNOW DL encap
7600 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7601 return test_pdcp_proto_SGL(i, IN_PLACE,
7602 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7603 RTE_CRYPTO_AUTH_OP_GENERATE,
7604 pdcp_test_data_in[i],
7605 pdcp_test_data_in_len[i],
7606 pdcp_test_data_out[i],
7607 pdcp_test_data_in_len[i]+4,
7611 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7613 /* i can be used for running any PDCP case
7614 * In this case it is uplane 18-bit NULL-NULL DL encap
7616 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7617 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7618 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7619 RTE_CRYPTO_AUTH_OP_GENERATE,
7620 pdcp_test_data_in[i],
7621 pdcp_test_data_in_len[i],
7622 pdcp_test_data_out[i],
7623 pdcp_test_data_in_len[i]+4,
7627 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7629 /* i can be used for running any PDCP case
7630 * In this case it is uplane 18-bit AES DL encap
7632 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7634 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7635 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7636 RTE_CRYPTO_AUTH_OP_GENERATE,
7637 pdcp_test_data_in[i],
7638 pdcp_test_data_in_len[i],
7639 pdcp_test_data_out[i],
7640 pdcp_test_data_in_len[i],
7644 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7646 /* i can be used for running any PDCP case
7647 * In this case it is cplane 12-bit AES-ZUC DL encap
7649 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7650 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7651 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7652 RTE_CRYPTO_AUTH_OP_GENERATE,
7653 pdcp_test_data_in[i],
7654 pdcp_test_data_in_len[i],
7655 pdcp_test_data_out[i],
7656 pdcp_test_data_in_len[i]+4,
7661 test_PDCP_PROTO_all(void)
7663 struct crypto_testsuite_params *ts_params = &testsuite_params;
7664 struct rte_cryptodev_info dev_info;
7667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7668 uint64_t feat_flags = dev_info.feature_flags;
7670 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7673 status = test_PDCP_PROTO_cplane_encap_all();
7674 status += test_PDCP_PROTO_cplane_decap_all();
7675 status += test_PDCP_PROTO_uplane_encap_all();
7676 status += test_PDCP_PROTO_uplane_decap_all();
7677 status += test_PDCP_PROTO_SGL_in_place_32B();
7678 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7679 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7680 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7685 return TEST_SUCCESS;
7690 test_AES_GCM_authenticated_encryption_test_case_1(void)
7692 return test_authenticated_encryption(&gcm_test_case_1);
7696 test_AES_GCM_authenticated_encryption_test_case_2(void)
7698 return test_authenticated_encryption(&gcm_test_case_2);
7702 test_AES_GCM_authenticated_encryption_test_case_3(void)
7704 return test_authenticated_encryption(&gcm_test_case_3);
7708 test_AES_GCM_authenticated_encryption_test_case_4(void)
7710 return test_authenticated_encryption(&gcm_test_case_4);
7714 test_AES_GCM_authenticated_encryption_test_case_5(void)
7716 return test_authenticated_encryption(&gcm_test_case_5);
7720 test_AES_GCM_authenticated_encryption_test_case_6(void)
7722 return test_authenticated_encryption(&gcm_test_case_6);
7726 test_AES_GCM_authenticated_encryption_test_case_7(void)
7728 return test_authenticated_encryption(&gcm_test_case_7);
7732 test_AES_GCM_authenticated_encryption_test_case_8(void)
7734 return test_authenticated_encryption(&gcm_test_case_8);
7738 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7740 return test_authenticated_encryption(&gcm_J0_test_case_1);
7744 test_AES_GCM_auth_encryption_test_case_192_1(void)
7746 return test_authenticated_encryption(&gcm_test_case_192_1);
7750 test_AES_GCM_auth_encryption_test_case_192_2(void)
7752 return test_authenticated_encryption(&gcm_test_case_192_2);
7756 test_AES_GCM_auth_encryption_test_case_192_3(void)
7758 return test_authenticated_encryption(&gcm_test_case_192_3);
7762 test_AES_GCM_auth_encryption_test_case_192_4(void)
7764 return test_authenticated_encryption(&gcm_test_case_192_4);
7768 test_AES_GCM_auth_encryption_test_case_192_5(void)
7770 return test_authenticated_encryption(&gcm_test_case_192_5);
7774 test_AES_GCM_auth_encryption_test_case_192_6(void)
7776 return test_authenticated_encryption(&gcm_test_case_192_6);
7780 test_AES_GCM_auth_encryption_test_case_192_7(void)
7782 return test_authenticated_encryption(&gcm_test_case_192_7);
7786 test_AES_GCM_auth_encryption_test_case_256_1(void)
7788 return test_authenticated_encryption(&gcm_test_case_256_1);
7792 test_AES_GCM_auth_encryption_test_case_256_2(void)
7794 return test_authenticated_encryption(&gcm_test_case_256_2);
7798 test_AES_GCM_auth_encryption_test_case_256_3(void)
7800 return test_authenticated_encryption(&gcm_test_case_256_3);
7804 test_AES_GCM_auth_encryption_test_case_256_4(void)
7806 return test_authenticated_encryption(&gcm_test_case_256_4);
7810 test_AES_GCM_auth_encryption_test_case_256_5(void)
7812 return test_authenticated_encryption(&gcm_test_case_256_5);
7816 test_AES_GCM_auth_encryption_test_case_256_6(void)
7818 return test_authenticated_encryption(&gcm_test_case_256_6);
7822 test_AES_GCM_auth_encryption_test_case_256_7(void)
7824 return test_authenticated_encryption(&gcm_test_case_256_7);
7828 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7830 return test_authenticated_encryption(&gcm_test_case_aad_1);
7834 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7836 return test_authenticated_encryption(&gcm_test_case_aad_2);
7840 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7842 struct aead_test_data tdata;
7845 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7846 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7847 tdata.iv.data[0] += 1;
7848 res = test_authenticated_encryption(&tdata);
7849 if (res == -ENOTSUP)
7851 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7852 return TEST_SUCCESS;
7856 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7858 struct aead_test_data tdata;
7861 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7862 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7863 tdata.plaintext.data[0] += 1;
7864 res = test_authenticated_encryption(&tdata);
7865 if (res == -ENOTSUP)
7867 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7868 return TEST_SUCCESS;
7872 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7874 struct aead_test_data tdata;
7877 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7878 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7879 tdata.ciphertext.data[0] += 1;
7880 res = test_authenticated_encryption(&tdata);
7881 if (res == -ENOTSUP)
7883 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7884 return TEST_SUCCESS;
7888 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7890 struct aead_test_data tdata;
7893 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7894 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7896 res = test_authenticated_encryption(&tdata);
7897 if (res == -ENOTSUP)
7899 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7900 return TEST_SUCCESS;
7904 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7906 struct aead_test_data tdata;
7907 uint8_t aad[gcm_test_case_7.aad.len];
7910 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7911 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7912 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7914 tdata.aad.data = aad;
7915 res = test_authenticated_encryption(&tdata);
7916 if (res == -ENOTSUP)
7918 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7919 return TEST_SUCCESS;
7923 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7925 struct aead_test_data tdata;
7928 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7929 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7930 tdata.auth_tag.data[0] += 1;
7931 res = test_authenticated_encryption(&tdata);
7932 if (res == -ENOTSUP)
7934 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7935 return TEST_SUCCESS;
7939 test_authenticated_decryption(const struct aead_test_data *tdata)
7941 struct crypto_testsuite_params *ts_params = &testsuite_params;
7942 struct crypto_unittest_params *ut_params = &unittest_params;
7948 /* Verify the capabilities */
7949 struct rte_cryptodev_sym_capability_idx cap_idx;
7950 const struct rte_cryptodev_symmetric_capability *capability;
7951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7952 cap_idx.algo.aead = tdata->algo;
7953 capability = rte_cryptodev_sym_capability_get(
7954 ts_params->valid_devs[0], &cap_idx);
7955 if (capability == NULL)
7957 if (rte_cryptodev_sym_capability_check_aead(
7958 capability, tdata->key.len, tdata->auth_tag.len,
7959 tdata->aad.len, tdata->iv.len))
7962 /* Create AEAD session */
7963 retval = create_aead_session(ts_params->valid_devs[0],
7965 RTE_CRYPTO_AEAD_OP_DECRYPT,
7966 tdata->key.data, tdata->key.len,
7967 tdata->aad.len, tdata->auth_tag.len,
7972 /* alloc mbuf and set payload */
7973 if (tdata->aad.len > MBUF_SIZE) {
7974 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7975 /* Populate full size of add data */
7976 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7977 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7979 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7981 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7982 rte_pktmbuf_tailroom(ut_params->ibuf));
7984 /* Create AEAD operation */
7985 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7989 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7991 ut_params->op->sym->m_src = ut_params->ibuf;
7993 /* Process crypto operation */
7994 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7995 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7997 TEST_ASSERT_NOT_NULL(
7998 process_crypto_request(ts_params->valid_devs[0],
7999 ut_params->op), "failed to process sym crypto op");
8001 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8002 "crypto op processing failed");
8004 if (ut_params->op->sym->m_dst)
8005 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8008 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8010 ut_params->op->sym->cipher.data.offset);
8012 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8015 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8017 tdata->plaintext.data,
8018 tdata->plaintext.len,
8019 "Plaintext data not as expected");
8021 TEST_ASSERT_EQUAL(ut_params->op->status,
8022 RTE_CRYPTO_OP_STATUS_SUCCESS,
8023 "Authentication failed");
8029 test_AES_GCM_authenticated_decryption_test_case_1(void)
8031 return test_authenticated_decryption(&gcm_test_case_1);
8035 test_AES_GCM_authenticated_decryption_test_case_2(void)
8037 return test_authenticated_decryption(&gcm_test_case_2);
8041 test_AES_GCM_authenticated_decryption_test_case_3(void)
8043 return test_authenticated_decryption(&gcm_test_case_3);
8047 test_AES_GCM_authenticated_decryption_test_case_4(void)
8049 return test_authenticated_decryption(&gcm_test_case_4);
8053 test_AES_GCM_authenticated_decryption_test_case_5(void)
8055 return test_authenticated_decryption(&gcm_test_case_5);
8059 test_AES_GCM_authenticated_decryption_test_case_6(void)
8061 return test_authenticated_decryption(&gcm_test_case_6);
8065 test_AES_GCM_authenticated_decryption_test_case_7(void)
8067 return test_authenticated_decryption(&gcm_test_case_7);
8071 test_AES_GCM_authenticated_decryption_test_case_8(void)
8073 return test_authenticated_decryption(&gcm_test_case_8);
8077 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8079 return test_authenticated_decryption(&gcm_J0_test_case_1);
8083 test_AES_GCM_auth_decryption_test_case_192_1(void)
8085 return test_authenticated_decryption(&gcm_test_case_192_1);
8089 test_AES_GCM_auth_decryption_test_case_192_2(void)
8091 return test_authenticated_decryption(&gcm_test_case_192_2);
8095 test_AES_GCM_auth_decryption_test_case_192_3(void)
8097 return test_authenticated_decryption(&gcm_test_case_192_3);
8101 test_AES_GCM_auth_decryption_test_case_192_4(void)
8103 return test_authenticated_decryption(&gcm_test_case_192_4);
8107 test_AES_GCM_auth_decryption_test_case_192_5(void)
8109 return test_authenticated_decryption(&gcm_test_case_192_5);
8113 test_AES_GCM_auth_decryption_test_case_192_6(void)
8115 return test_authenticated_decryption(&gcm_test_case_192_6);
8119 test_AES_GCM_auth_decryption_test_case_192_7(void)
8121 return test_authenticated_decryption(&gcm_test_case_192_7);
8125 test_AES_GCM_auth_decryption_test_case_256_1(void)
8127 return test_authenticated_decryption(&gcm_test_case_256_1);
8131 test_AES_GCM_auth_decryption_test_case_256_2(void)
8133 return test_authenticated_decryption(&gcm_test_case_256_2);
8137 test_AES_GCM_auth_decryption_test_case_256_3(void)
8139 return test_authenticated_decryption(&gcm_test_case_256_3);
8143 test_AES_GCM_auth_decryption_test_case_256_4(void)
8145 return test_authenticated_decryption(&gcm_test_case_256_4);
8149 test_AES_GCM_auth_decryption_test_case_256_5(void)
8151 return test_authenticated_decryption(&gcm_test_case_256_5);
8155 test_AES_GCM_auth_decryption_test_case_256_6(void)
8157 return test_authenticated_decryption(&gcm_test_case_256_6);
8161 test_AES_GCM_auth_decryption_test_case_256_7(void)
8163 return test_authenticated_decryption(&gcm_test_case_256_7);
8167 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8169 return test_authenticated_decryption(&gcm_test_case_aad_1);
8173 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8175 return test_authenticated_decryption(&gcm_test_case_aad_2);
8179 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8181 struct aead_test_data tdata;
8184 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8185 tdata.iv.data[0] += 1;
8186 res = test_authenticated_decryption(&tdata);
8187 if (res == -ENOTSUP)
8189 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8190 return TEST_SUCCESS;
8194 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8196 struct aead_test_data tdata;
8199 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8200 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8201 tdata.plaintext.data[0] += 1;
8202 res = test_authenticated_decryption(&tdata);
8203 if (res == -ENOTSUP)
8205 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8206 return TEST_SUCCESS;
8210 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8212 struct aead_test_data tdata;
8215 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8216 tdata.ciphertext.data[0] += 1;
8217 res = test_authenticated_decryption(&tdata);
8218 if (res == -ENOTSUP)
8220 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8221 return TEST_SUCCESS;
8225 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8227 struct aead_test_data tdata;
8230 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8232 res = test_authenticated_decryption(&tdata);
8233 if (res == -ENOTSUP)
8235 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8236 return TEST_SUCCESS;
8240 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8242 struct aead_test_data tdata;
8243 uint8_t aad[gcm_test_case_7.aad.len];
8246 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8247 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8249 tdata.aad.data = aad;
8250 res = test_authenticated_decryption(&tdata);
8251 if (res == -ENOTSUP)
8253 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8254 return TEST_SUCCESS;
8258 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8260 struct aead_test_data tdata;
8263 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8264 tdata.auth_tag.data[0] += 1;
8265 res = test_authenticated_decryption(&tdata);
8266 if (res == -ENOTSUP)
8268 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8269 return TEST_SUCCESS;
8273 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8275 struct crypto_testsuite_params *ts_params = &testsuite_params;
8276 struct crypto_unittest_params *ut_params = &unittest_params;
8279 uint8_t *ciphertext, *auth_tag;
8280 uint16_t plaintext_pad_len;
8282 /* Verify the capabilities */
8283 struct rte_cryptodev_sym_capability_idx cap_idx;
8284 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8285 cap_idx.algo.aead = tdata->algo;
8286 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8290 /* not supported with CPU crypto */
8291 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8294 /* Create AEAD session */
8295 retval = create_aead_session(ts_params->valid_devs[0],
8297 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8298 tdata->key.data, tdata->key.len,
8299 tdata->aad.len, tdata->auth_tag.len,
8304 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8305 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8307 /* clear mbuf payload */
8308 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8309 rte_pktmbuf_tailroom(ut_params->ibuf));
8310 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8311 rte_pktmbuf_tailroom(ut_params->obuf));
8313 /* Create AEAD operation */
8314 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8318 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8320 ut_params->op->sym->m_src = ut_params->ibuf;
8321 ut_params->op->sym->m_dst = ut_params->obuf;
8323 /* Process crypto operation */
8324 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8325 ut_params->op), "failed to process sym crypto op");
8327 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8328 "crypto op processing failed");
8330 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8332 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8333 ut_params->op->sym->cipher.data.offset);
8334 auth_tag = ciphertext + plaintext_pad_len;
8336 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8337 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8342 tdata->ciphertext.data,
8343 tdata->ciphertext.len,
8344 "Ciphertext data not as expected");
8346 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8348 tdata->auth_tag.data,
8349 tdata->auth_tag.len,
8350 "Generated auth tag not as expected");
8357 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8359 return test_authenticated_encryption_oop(&gcm_test_case_5);
8363 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8365 struct crypto_testsuite_params *ts_params = &testsuite_params;
8366 struct crypto_unittest_params *ut_params = &unittest_params;
8371 /* Verify the capabilities */
8372 struct rte_cryptodev_sym_capability_idx cap_idx;
8373 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8374 cap_idx.algo.aead = tdata->algo;
8375 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8379 /* not supported with CPU crypto */
8380 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8383 /* Create AEAD session */
8384 retval = create_aead_session(ts_params->valid_devs[0],
8386 RTE_CRYPTO_AEAD_OP_DECRYPT,
8387 tdata->key.data, tdata->key.len,
8388 tdata->aad.len, tdata->auth_tag.len,
8393 /* alloc mbuf and set payload */
8394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8395 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8397 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8398 rte_pktmbuf_tailroom(ut_params->ibuf));
8399 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8400 rte_pktmbuf_tailroom(ut_params->obuf));
8402 /* Create AEAD operation */
8403 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8407 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8409 ut_params->op->sym->m_src = ut_params->ibuf;
8410 ut_params->op->sym->m_dst = ut_params->obuf;
8412 /* Process crypto operation */
8413 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8414 ut_params->op), "failed to process sym crypto op");
8416 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8417 "crypto op processing failed");
8419 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8420 ut_params->op->sym->cipher.data.offset);
8422 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8425 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8427 tdata->plaintext.data,
8428 tdata->plaintext.len,
8429 "Plaintext data not as expected");
8431 TEST_ASSERT_EQUAL(ut_params->op->status,
8432 RTE_CRYPTO_OP_STATUS_SUCCESS,
8433 "Authentication failed");
8438 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8440 return test_authenticated_decryption_oop(&gcm_test_case_5);
8444 test_authenticated_encryption_sessionless(
8445 const struct aead_test_data *tdata)
8447 struct crypto_testsuite_params *ts_params = &testsuite_params;
8448 struct crypto_unittest_params *ut_params = &unittest_params;
8451 uint8_t *ciphertext, *auth_tag;
8452 uint16_t plaintext_pad_len;
8453 uint8_t key[tdata->key.len + 1];
8454 struct rte_cryptodev_info dev_info;
8456 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8457 uint64_t feat_flags = dev_info.feature_flags;
8459 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8460 printf("Device doesn't support Sessionless ops.\n");
8464 /* not supported with CPU crypto */
8465 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8468 /* Verify the capabilities */
8469 struct rte_cryptodev_sym_capability_idx cap_idx;
8470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8471 cap_idx.algo.aead = tdata->algo;
8472 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8478 /* clear mbuf payload */
8479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8480 rte_pktmbuf_tailroom(ut_params->ibuf));
8482 /* Create AEAD operation */
8483 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8487 /* Create GCM xform */
8488 memcpy(key, tdata->key.data, tdata->key.len);
8489 retval = create_aead_xform(ut_params->op,
8491 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8492 key, tdata->key.len,
8493 tdata->aad.len, tdata->auth_tag.len,
8498 ut_params->op->sym->m_src = ut_params->ibuf;
8500 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8501 RTE_CRYPTO_OP_SESSIONLESS,
8502 "crypto op session type not sessionless");
8504 /* Process crypto operation */
8505 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8506 ut_params->op), "failed to process sym crypto op");
8508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8510 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8511 "crypto op status not success");
8513 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8515 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8516 ut_params->op->sym->cipher.data.offset);
8517 auth_tag = ciphertext + plaintext_pad_len;
8519 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8520 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8525 tdata->ciphertext.data,
8526 tdata->ciphertext.len,
8527 "Ciphertext data not as expected");
8529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8531 tdata->auth_tag.data,
8532 tdata->auth_tag.len,
8533 "Generated auth tag not as expected");
8540 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8542 return test_authenticated_encryption_sessionless(
8547 test_authenticated_decryption_sessionless(
8548 const struct aead_test_data *tdata)
8550 struct crypto_testsuite_params *ts_params = &testsuite_params;
8551 struct crypto_unittest_params *ut_params = &unittest_params;
8555 uint8_t key[tdata->key.len + 1];
8556 struct rte_cryptodev_info dev_info;
8558 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8559 uint64_t feat_flags = dev_info.feature_flags;
8561 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8562 printf("Device doesn't support Sessionless ops.\n");
8566 /* not supported with CPU crypto */
8567 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8570 /* Verify the capabilities */
8571 struct rte_cryptodev_sym_capability_idx cap_idx;
8572 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8573 cap_idx.algo.aead = tdata->algo;
8574 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8578 /* alloc mbuf and set payload */
8579 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8581 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8582 rte_pktmbuf_tailroom(ut_params->ibuf));
8584 /* Create AEAD operation */
8585 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8589 /* Create AEAD xform */
8590 memcpy(key, tdata->key.data, tdata->key.len);
8591 retval = create_aead_xform(ut_params->op,
8593 RTE_CRYPTO_AEAD_OP_DECRYPT,
8594 key, tdata->key.len,
8595 tdata->aad.len, tdata->auth_tag.len,
8600 ut_params->op->sym->m_src = ut_params->ibuf;
8602 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8603 RTE_CRYPTO_OP_SESSIONLESS,
8604 "crypto op session type not sessionless");
8606 /* Process crypto operation */
8607 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8608 ut_params->op), "failed to process sym crypto op");
8610 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8612 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8613 "crypto op status not success");
8615 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8616 ut_params->op->sym->cipher.data.offset);
8618 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8621 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8623 tdata->plaintext.data,
8624 tdata->plaintext.len,
8625 "Plaintext data not as expected");
8627 TEST_ASSERT_EQUAL(ut_params->op->status,
8628 RTE_CRYPTO_OP_STATUS_SUCCESS,
8629 "Authentication failed");
8634 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8636 return test_authenticated_decryption_sessionless(
8641 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8643 return test_authenticated_encryption(&ccm_test_case_128_1);
8647 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8649 return test_authenticated_encryption(&ccm_test_case_128_2);
8653 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8655 return test_authenticated_encryption(&ccm_test_case_128_3);
8659 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8661 return test_authenticated_decryption(&ccm_test_case_128_1);
8665 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8667 return test_authenticated_decryption(&ccm_test_case_128_2);
8671 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8673 return test_authenticated_decryption(&ccm_test_case_128_3);
8677 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8679 return test_authenticated_encryption(&ccm_test_case_192_1);
8683 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8685 return test_authenticated_encryption(&ccm_test_case_192_2);
8689 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8691 return test_authenticated_encryption(&ccm_test_case_192_3);
8695 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8697 return test_authenticated_decryption(&ccm_test_case_192_1);
8701 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8703 return test_authenticated_decryption(&ccm_test_case_192_2);
8707 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8709 return test_authenticated_decryption(&ccm_test_case_192_3);
8713 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8715 return test_authenticated_encryption(&ccm_test_case_256_1);
8719 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8721 return test_authenticated_encryption(&ccm_test_case_256_2);
8725 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8727 return test_authenticated_encryption(&ccm_test_case_256_3);
8731 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8733 return test_authenticated_decryption(&ccm_test_case_256_1);
8737 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8739 return test_authenticated_decryption(&ccm_test_case_256_2);
8743 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8745 return test_authenticated_decryption(&ccm_test_case_256_3);
8751 struct crypto_testsuite_params *ts_params = &testsuite_params;
8752 struct rte_cryptodev_stats stats;
8753 struct rte_cryptodev *dev;
8754 cryptodev_stats_get_t temp_pfn;
8756 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8759 /* Verify the capabilities */
8760 struct rte_cryptodev_sym_capability_idx cap_idx;
8761 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8762 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8763 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8767 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8768 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8772 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8773 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8774 &stats) == -ENODEV),
8775 "rte_cryptodev_stats_get invalid dev failed");
8776 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8777 "rte_cryptodev_stats_get invalid Param failed");
8778 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8779 temp_pfn = dev->dev_ops->stats_get;
8780 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8781 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8783 "rte_cryptodev_stats_get invalid Param failed");
8784 dev->dev_ops->stats_get = temp_pfn;
8786 /* Test expected values */
8788 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8790 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8792 "rte_cryptodev_stats_get failed");
8793 TEST_ASSERT((stats.enqueued_count == 1),
8794 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8795 TEST_ASSERT((stats.dequeued_count == 1),
8796 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8797 TEST_ASSERT((stats.enqueue_err_count == 0),
8798 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8799 TEST_ASSERT((stats.dequeue_err_count == 0),
8800 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8802 /* invalid device but should ignore and not reset device stats*/
8803 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8804 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8806 "rte_cryptodev_stats_get failed");
8807 TEST_ASSERT((stats.enqueued_count == 1),
8808 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8810 /* check that a valid reset clears stats */
8811 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8812 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8814 "rte_cryptodev_stats_get failed");
8815 TEST_ASSERT((stats.enqueued_count == 0),
8816 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8817 TEST_ASSERT((stats.dequeued_count == 0),
8818 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8820 return TEST_SUCCESS;
8823 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8824 struct crypto_unittest_params *ut_params,
8825 enum rte_crypto_auth_operation op,
8826 const struct HMAC_MD5_vector *test_case)
8830 memcpy(key, test_case->key.data, test_case->key.len);
8832 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8833 ut_params->auth_xform.next = NULL;
8834 ut_params->auth_xform.auth.op = op;
8836 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8838 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8839 ut_params->auth_xform.auth.key.length = test_case->key.len;
8840 ut_params->auth_xform.auth.key.data = key;
8842 ut_params->sess = rte_cryptodev_sym_session_create(
8843 ts_params->session_mpool);
8845 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8846 ut_params->sess, &ut_params->auth_xform,
8847 ts_params->session_priv_mpool);
8849 if (ut_params->sess == NULL)
8852 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8854 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8855 rte_pktmbuf_tailroom(ut_params->ibuf));
8860 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8861 const struct HMAC_MD5_vector *test_case,
8862 uint8_t **plaintext)
8864 uint16_t plaintext_pad_len;
8866 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8868 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8871 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8873 memcpy(*plaintext, test_case->plaintext.data,
8874 test_case->plaintext.len);
8876 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8877 ut_params->ibuf, MD5_DIGEST_LEN);
8878 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8879 "no room to append digest");
8880 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8881 ut_params->ibuf, plaintext_pad_len);
8883 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8884 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8885 test_case->auth_tag.len);
8888 sym_op->auth.data.offset = 0;
8889 sym_op->auth.data.length = test_case->plaintext.len;
8891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8892 ut_params->op->sym->m_src = ut_params->ibuf;
8898 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8900 uint16_t plaintext_pad_len;
8901 uint8_t *plaintext, *auth_tag;
8903 struct crypto_testsuite_params *ts_params = &testsuite_params;
8904 struct crypto_unittest_params *ut_params = &unittest_params;
8906 /* Verify the capabilities */
8907 struct rte_cryptodev_sym_capability_idx cap_idx;
8908 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8909 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8910 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8914 if (MD5_HMAC_create_session(ts_params, ut_params,
8915 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8918 /* Generate Crypto op data structure */
8919 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8920 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8921 TEST_ASSERT_NOT_NULL(ut_params->op,
8922 "Failed to allocate symmetric crypto operation struct");
8924 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8927 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8930 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8931 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8934 TEST_ASSERT_NOT_NULL(
8935 process_crypto_request(ts_params->valid_devs[0],
8937 "failed to process sym crypto op");
8939 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8940 "crypto op processing failed");
8942 if (ut_params->op->sym->m_dst) {
8943 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8944 uint8_t *, plaintext_pad_len);
8946 auth_tag = plaintext + plaintext_pad_len;
8949 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8951 test_case->auth_tag.data,
8952 test_case->auth_tag.len,
8953 "HMAC_MD5 generated tag not as expected");
8955 return TEST_SUCCESS;
8959 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8963 struct crypto_testsuite_params *ts_params = &testsuite_params;
8964 struct crypto_unittest_params *ut_params = &unittest_params;
8966 /* Verify the capabilities */
8967 struct rte_cryptodev_sym_capability_idx cap_idx;
8968 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8969 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8970 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8974 if (MD5_HMAC_create_session(ts_params, ut_params,
8975 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8979 /* Generate Crypto op data structure */
8980 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8981 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8982 TEST_ASSERT_NOT_NULL(ut_params->op,
8983 "Failed to allocate symmetric crypto operation struct");
8985 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8988 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8989 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8992 TEST_ASSERT_NOT_NULL(
8993 process_crypto_request(ts_params->valid_devs[0],
8995 "failed to process sym crypto op");
8997 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8998 "HMAC_MD5 crypto op processing failed");
9000 return TEST_SUCCESS;
9004 test_MD5_HMAC_generate_case_1(void)
9006 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9010 test_MD5_HMAC_verify_case_1(void)
9012 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9016 test_MD5_HMAC_generate_case_2(void)
9018 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9022 test_MD5_HMAC_verify_case_2(void)
9024 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9028 test_multi_session(void)
9030 struct crypto_testsuite_params *ts_params = &testsuite_params;
9031 struct crypto_unittest_params *ut_params = &unittest_params;
9033 struct rte_cryptodev_info dev_info;
9034 struct rte_cryptodev_sym_session **sessions;
9038 /* Verify the capabilities */
9039 struct rte_cryptodev_sym_capability_idx cap_idx;
9040 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9041 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9042 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9045 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9046 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9047 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9051 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9052 aes_cbc_key, hmac_sha512_key);
9055 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9057 sessions = rte_malloc(NULL,
9058 (sizeof(struct rte_cryptodev_sym_session *) *
9059 MAX_NB_SESSIONS) + 1, 0);
9061 /* Create multiple crypto sessions*/
9062 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9064 sessions[i] = rte_cryptodev_sym_session_create(
9065 ts_params->session_mpool);
9067 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9068 sessions[i], &ut_params->auth_xform,
9069 ts_params->session_priv_mpool);
9070 TEST_ASSERT_NOT_NULL(sessions[i],
9071 "Session creation failed at session number %u",
9074 /* Attempt to send a request on each session */
9075 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9079 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9080 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9082 "Failed to perform decrypt on request number %u.", i);
9083 /* free crypto operation structure */
9085 rte_crypto_op_free(ut_params->op);
9088 * free mbuf - both obuf and ibuf are usually the same,
9089 * so check if they point at the same address is necessary,
9090 * to avoid freeing the mbuf twice.
9092 if (ut_params->obuf) {
9093 rte_pktmbuf_free(ut_params->obuf);
9094 if (ut_params->ibuf == ut_params->obuf)
9095 ut_params->ibuf = 0;
9096 ut_params->obuf = 0;
9098 if (ut_params->ibuf) {
9099 rte_pktmbuf_free(ut_params->ibuf);
9100 ut_params->ibuf = 0;
9104 /* Next session create should fail */
9105 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9106 sessions[i], &ut_params->auth_xform,
9107 ts_params->session_priv_mpool);
9108 TEST_ASSERT_NULL(sessions[i],
9109 "Session creation succeeded unexpectedly!");
9111 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9112 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9114 rte_cryptodev_sym_session_free(sessions[i]);
9119 return TEST_SUCCESS;
9122 struct multi_session_params {
9123 struct crypto_unittest_params ut_params;
9124 uint8_t *cipher_key;
9126 const uint8_t *cipher;
9127 const uint8_t *digest;
9131 #define MB_SESSION_NUMBER 3
9134 test_multi_session_random_usage(void)
9136 struct crypto_testsuite_params *ts_params = &testsuite_params;
9137 struct rte_cryptodev_info dev_info;
9138 struct rte_cryptodev_sym_session **sessions;
9140 struct multi_session_params ut_paramz[] = {
9143 .cipher_key = ms_aes_cbc_key0,
9144 .hmac_key = ms_hmac_key0,
9145 .cipher = ms_aes_cbc_cipher0,
9146 .digest = ms_hmac_digest0,
9147 .iv = ms_aes_cbc_iv0
9150 .cipher_key = ms_aes_cbc_key1,
9151 .hmac_key = ms_hmac_key1,
9152 .cipher = ms_aes_cbc_cipher1,
9153 .digest = ms_hmac_digest1,
9154 .iv = ms_aes_cbc_iv1
9157 .cipher_key = ms_aes_cbc_key2,
9158 .hmac_key = ms_hmac_key2,
9159 .cipher = ms_aes_cbc_cipher2,
9160 .digest = ms_hmac_digest2,
9161 .iv = ms_aes_cbc_iv2
9166 /* Verify the capabilities */
9167 struct rte_cryptodev_sym_capability_idx cap_idx;
9168 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9169 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9170 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9174 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9175 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9179 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9181 sessions = rte_malloc(NULL,
9182 (sizeof(struct rte_cryptodev_sym_session *)
9183 * MAX_NB_SESSIONS) + 1, 0);
9185 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9186 sessions[i] = rte_cryptodev_sym_session_create(
9187 ts_params->session_mpool);
9189 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9190 sizeof(struct crypto_unittest_params));
9192 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9193 &ut_paramz[i].ut_params,
9194 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9196 /* Create multiple crypto sessions*/
9197 rte_cryptodev_sym_session_init(
9198 ts_params->valid_devs[0],
9200 &ut_paramz[i].ut_params.auth_xform,
9201 ts_params->session_priv_mpool);
9203 TEST_ASSERT_NOT_NULL(sessions[i],
9204 "Session creation failed at session number %u",
9210 for (i = 0; i < 40000; i++) {
9212 j = rand() % MB_SESSION_NUMBER;
9214 TEST_ASSERT_SUCCESS(
9215 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9217 &ut_paramz[j].ut_params,
9218 ts_params, ut_paramz[j].cipher,
9219 ut_paramz[j].digest,
9221 "Failed to perform decrypt on request number %u.", i);
9223 if (ut_paramz[j].ut_params.op)
9224 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9227 * free mbuf - both obuf and ibuf are usually the same,
9228 * so check if they point at the same address is necessary,
9229 * to avoid freeing the mbuf twice.
9231 if (ut_paramz[j].ut_params.obuf) {
9232 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9233 if (ut_paramz[j].ut_params.ibuf
9234 == ut_paramz[j].ut_params.obuf)
9235 ut_paramz[j].ut_params.ibuf = 0;
9236 ut_paramz[j].ut_params.obuf = 0;
9238 if (ut_paramz[j].ut_params.ibuf) {
9239 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9240 ut_paramz[j].ut_params.ibuf = 0;
9244 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9245 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9247 rte_cryptodev_sym_session_free(sessions[i]);
9252 return TEST_SUCCESS;
9256 test_null_cipher_only_operation(void)
9258 struct crypto_testsuite_params *ts_params = &testsuite_params;
9259 struct crypto_unittest_params *ut_params = &unittest_params;
9261 /* Verify the capabilities */
9262 struct rte_cryptodev_sym_capability_idx cap_idx;
9263 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9264 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9265 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9269 /* Generate test mbuf data and space for digest */
9270 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9271 catch_22_quote, QUOTE_512_BYTES, 0);
9273 /* Setup Cipher Parameters */
9274 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9275 ut_params->cipher_xform.next = NULL;
9277 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9278 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9280 ut_params->sess = rte_cryptodev_sym_session_create(
9281 ts_params->session_mpool);
9283 /* Create Crypto session*/
9284 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9286 &ut_params->cipher_xform,
9287 ts_params->session_priv_mpool);
9288 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9290 /* Generate Crypto op data structure */
9291 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9292 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9293 TEST_ASSERT_NOT_NULL(ut_params->op,
9294 "Failed to allocate symmetric crypto operation struct");
9296 /* Set crypto operation data parameters */
9297 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9299 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9301 /* set crypto operation source mbuf */
9302 sym_op->m_src = ut_params->ibuf;
9304 sym_op->cipher.data.offset = 0;
9305 sym_op->cipher.data.length = QUOTE_512_BYTES;
9307 /* Process crypto operation */
9308 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9310 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9312 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9313 "crypto operation processing failed");
9316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9317 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9320 "Ciphertext data not as expected");
9322 return TEST_SUCCESS;
9324 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9325 0xab, 0xab, 0xab, 0xab,
9326 0xab, 0xab, 0xab, 0xab,
9327 0xab, 0xab, 0xab, 0xab};
9329 test_null_auth_only_operation(void)
9331 struct crypto_testsuite_params *ts_params = &testsuite_params;
9332 struct crypto_unittest_params *ut_params = &unittest_params;
9335 /* Verify the capabilities */
9336 struct rte_cryptodev_sym_capability_idx cap_idx;
9337 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9338 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9339 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9343 /* Generate test mbuf data and space for digest */
9344 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9345 catch_22_quote, QUOTE_512_BYTES, 0);
9347 /* create a pointer for digest, but don't expect anything to be written
9348 * here in a NULL auth algo so no mbuf append done.
9350 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9352 /* prefill the memory pointed to by digest */
9353 memcpy(digest, orig_data, sizeof(orig_data));
9355 /* Setup HMAC Parameters */
9356 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9357 ut_params->auth_xform.next = NULL;
9359 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9360 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9362 ut_params->sess = rte_cryptodev_sym_session_create(
9363 ts_params->session_mpool);
9365 /* Create Crypto session*/
9366 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9367 ut_params->sess, &ut_params->auth_xform,
9368 ts_params->session_priv_mpool);
9369 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9371 /* Generate Crypto op data structure */
9372 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9373 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9374 TEST_ASSERT_NOT_NULL(ut_params->op,
9375 "Failed to allocate symmetric crypto operation struct");
9377 /* Set crypto operation data parameters */
9378 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9380 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9382 sym_op->m_src = ut_params->ibuf;
9384 sym_op->auth.data.offset = 0;
9385 sym_op->auth.data.length = QUOTE_512_BYTES;
9386 sym_op->auth.digest.data = digest;
9387 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9390 /* Process crypto operation */
9391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9393 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9396 "crypto operation processing failed");
9397 /* Make sure memory pointed to by digest hasn't been overwritten */
9398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9402 "Memory at digest ptr overwritten unexpectedly");
9404 return TEST_SUCCESS;
9409 test_null_cipher_auth_operation(void)
9411 struct crypto_testsuite_params *ts_params = &testsuite_params;
9412 struct crypto_unittest_params *ut_params = &unittest_params;
9415 /* Verify the capabilities */
9416 struct rte_cryptodev_sym_capability_idx cap_idx;
9417 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9418 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9423 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9424 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9428 /* Generate test mbuf data and space for digest */
9429 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9430 catch_22_quote, QUOTE_512_BYTES, 0);
9432 /* create a pointer for digest, but don't expect anything to be written
9433 * here in a NULL auth algo so no mbuf append done.
9435 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9437 /* prefill the memory pointed to by digest */
9438 memcpy(digest, orig_data, sizeof(orig_data));
9440 /* Setup Cipher Parameters */
9441 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9442 ut_params->cipher_xform.next = &ut_params->auth_xform;
9444 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9445 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9447 /* Setup HMAC Parameters */
9448 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9449 ut_params->auth_xform.next = NULL;
9451 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9452 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9454 ut_params->sess = rte_cryptodev_sym_session_create(
9455 ts_params->session_mpool);
9457 /* Create Crypto session*/
9458 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9459 ut_params->sess, &ut_params->cipher_xform,
9460 ts_params->session_priv_mpool);
9461 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9463 /* Generate Crypto op data structure */
9464 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9465 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9466 TEST_ASSERT_NOT_NULL(ut_params->op,
9467 "Failed to allocate symmetric crypto operation struct");
9469 /* Set crypto operation data parameters */
9470 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9472 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9474 sym_op->m_src = ut_params->ibuf;
9476 sym_op->cipher.data.offset = 0;
9477 sym_op->cipher.data.length = QUOTE_512_BYTES;
9479 sym_op->auth.data.offset = 0;
9480 sym_op->auth.data.length = QUOTE_512_BYTES;
9481 sym_op->auth.digest.data = digest;
9482 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9485 /* Process crypto operation */
9486 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9488 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9490 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9491 "crypto operation processing failed");
9494 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9495 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9498 "Ciphertext data not as expected");
9499 /* Make sure memory pointed to by digest hasn't been overwritten */
9500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9504 "Memory at digest ptr overwritten unexpectedly");
9506 return TEST_SUCCESS;
9510 test_null_auth_cipher_operation(void)
9512 struct crypto_testsuite_params *ts_params = &testsuite_params;
9513 struct crypto_unittest_params *ut_params = &unittest_params;
9516 /* Verify the capabilities */
9517 struct rte_cryptodev_sym_capability_idx cap_idx;
9518 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9519 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9523 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9524 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9525 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9529 /* Generate test mbuf data */
9530 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9531 catch_22_quote, QUOTE_512_BYTES, 0);
9533 /* create a pointer for digest, but don't expect anything to be written
9534 * here in a NULL auth algo so no mbuf append done.
9536 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9538 /* prefill the memory pointed to by digest */
9539 memcpy(digest, orig_data, sizeof(orig_data));
9541 /* Setup Cipher Parameters */
9542 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9543 ut_params->cipher_xform.next = NULL;
9545 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9546 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9548 /* Setup HMAC Parameters */
9549 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9550 ut_params->auth_xform.next = &ut_params->cipher_xform;
9552 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9553 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9555 ut_params->sess = rte_cryptodev_sym_session_create(
9556 ts_params->session_mpool);
9558 /* Create Crypto session*/
9559 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9560 ut_params->sess, &ut_params->cipher_xform,
9561 ts_params->session_priv_mpool);
9562 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9564 /* Generate Crypto op data structure */
9565 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9566 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9567 TEST_ASSERT_NOT_NULL(ut_params->op,
9568 "Failed to allocate symmetric crypto operation struct");
9570 /* Set crypto operation data parameters */
9571 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9573 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9575 sym_op->m_src = ut_params->ibuf;
9577 sym_op->cipher.data.offset = 0;
9578 sym_op->cipher.data.length = QUOTE_512_BYTES;
9580 sym_op->auth.data.offset = 0;
9581 sym_op->auth.data.length = QUOTE_512_BYTES;
9582 sym_op->auth.digest.data = digest;
9583 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9586 /* Process crypto operation */
9587 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9589 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9591 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9592 "crypto operation processing failed");
9595 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9596 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9599 "Ciphertext data not as expected");
9600 /* Make sure memory pointed to by digest hasn't been overwritten */
9601 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9605 "Memory at digest ptr overwritten unexpectedly");
9607 return TEST_SUCCESS;
9612 test_null_invalid_operation(void)
9614 struct crypto_testsuite_params *ts_params = &testsuite_params;
9615 struct crypto_unittest_params *ut_params = &unittest_params;
9618 /* This test is for NULL PMD only */
9619 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9620 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9623 /* Setup Cipher Parameters */
9624 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9625 ut_params->cipher_xform.next = NULL;
9627 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9628 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9630 ut_params->sess = rte_cryptodev_sym_session_create(
9631 ts_params->session_mpool);
9633 /* Create Crypto session*/
9634 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9635 ut_params->sess, &ut_params->cipher_xform,
9636 ts_params->session_priv_mpool);
9637 TEST_ASSERT(ret < 0,
9638 "Session creation succeeded unexpectedly");
9641 /* Setup HMAC Parameters */
9642 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9643 ut_params->auth_xform.next = NULL;
9645 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9646 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9648 ut_params->sess = rte_cryptodev_sym_session_create(
9649 ts_params->session_mpool);
9651 /* Create Crypto session*/
9652 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9653 ut_params->sess, &ut_params->auth_xform,
9654 ts_params->session_priv_mpool);
9655 TEST_ASSERT(ret < 0,
9656 "Session creation succeeded unexpectedly");
9658 return TEST_SUCCESS;
9662 #define NULL_BURST_LENGTH (32)
9665 test_null_burst_operation(void)
9667 struct crypto_testsuite_params *ts_params = &testsuite_params;
9668 struct crypto_unittest_params *ut_params = &unittest_params;
9670 unsigned i, burst_len = NULL_BURST_LENGTH;
9672 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9673 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9675 /* This test is for NULL PMD only */
9676 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9677 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9680 /* Setup Cipher Parameters */
9681 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9682 ut_params->cipher_xform.next = &ut_params->auth_xform;
9684 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9685 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9687 /* Setup HMAC Parameters */
9688 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9689 ut_params->auth_xform.next = NULL;
9691 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9692 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9694 ut_params->sess = rte_cryptodev_sym_session_create(
9695 ts_params->session_mpool);
9697 /* Create Crypto session*/
9698 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9699 ut_params->sess, &ut_params->cipher_xform,
9700 ts_params->session_priv_mpool);
9701 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9703 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9704 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9705 burst_len, "failed to generate burst of crypto ops");
9707 /* Generate an operation for each mbuf in burst */
9708 for (i = 0; i < burst_len; i++) {
9709 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9711 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9713 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9717 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9719 burst[i]->sym->m_src = m;
9722 /* Process crypto operation */
9723 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9724 0, burst, burst_len),
9726 "Error enqueuing burst");
9728 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9729 0, burst_dequeued, burst_len),
9731 "Error dequeuing burst");
9734 for (i = 0; i < burst_len; i++) {
9736 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9737 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9739 "data not as expected");
9741 rte_pktmbuf_free(burst[i]->sym->m_src);
9742 rte_crypto_op_free(burst[i]);
9745 return TEST_SUCCESS;
9749 generate_gmac_large_plaintext(uint8_t *data)
9753 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9754 memcpy(&data[i], &data[0], 32);
9758 create_gmac_operation(enum rte_crypto_auth_operation op,
9759 const struct gmac_test_data *tdata)
9761 struct crypto_testsuite_params *ts_params = &testsuite_params;
9762 struct crypto_unittest_params *ut_params = &unittest_params;
9763 struct rte_crypto_sym_op *sym_op;
9765 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9767 /* Generate Crypto op data structure */
9768 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9769 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9770 TEST_ASSERT_NOT_NULL(ut_params->op,
9771 "Failed to allocate symmetric crypto operation struct");
9773 sym_op = ut_params->op->sym;
9775 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9776 ut_params->ibuf, tdata->gmac_tag.len);
9777 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9778 "no room to append digest");
9780 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9781 ut_params->ibuf, plaintext_pad_len);
9783 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9784 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9785 tdata->gmac_tag.len);
9786 debug_hexdump(stdout, "digest:",
9787 sym_op->auth.digest.data,
9788 tdata->gmac_tag.len);
9791 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9792 uint8_t *, IV_OFFSET);
9794 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9796 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9798 sym_op->cipher.data.length = 0;
9799 sym_op->cipher.data.offset = 0;
9801 sym_op->auth.data.offset = 0;
9802 sym_op->auth.data.length = tdata->plaintext.len;
9807 static int create_gmac_session(uint8_t dev_id,
9808 const struct gmac_test_data *tdata,
9809 enum rte_crypto_auth_operation auth_op)
9811 uint8_t auth_key[tdata->key.len];
9813 struct crypto_testsuite_params *ts_params = &testsuite_params;
9814 struct crypto_unittest_params *ut_params = &unittest_params;
9816 memcpy(auth_key, tdata->key.data, tdata->key.len);
9818 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9819 ut_params->auth_xform.next = NULL;
9821 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9822 ut_params->auth_xform.auth.op = auth_op;
9823 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9824 ut_params->auth_xform.auth.key.length = tdata->key.len;
9825 ut_params->auth_xform.auth.key.data = auth_key;
9826 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9827 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9830 ut_params->sess = rte_cryptodev_sym_session_create(
9831 ts_params->session_mpool);
9833 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9834 &ut_params->auth_xform,
9835 ts_params->session_priv_mpool);
9837 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9843 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9845 struct crypto_testsuite_params *ts_params = &testsuite_params;
9846 struct crypto_unittest_params *ut_params = &unittest_params;
9850 uint8_t *auth_tag, *plaintext;
9851 uint16_t plaintext_pad_len;
9853 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9854 "No GMAC length in the source data");
9856 /* Verify the capabilities */
9857 struct rte_cryptodev_sym_capability_idx cap_idx;
9858 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9859 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9860 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9864 retval = create_gmac_session(ts_params->valid_devs[0],
9865 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9870 if (tdata->plaintext.len > MBUF_SIZE)
9871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9874 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9875 "Failed to allocate input buffer in mempool");
9877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9878 rte_pktmbuf_tailroom(ut_params->ibuf));
9880 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9882 * Runtime generate the large plain text instead of use hard code
9883 * plain text vector. It is done to avoid create huge source file
9884 * with the test vector.
9886 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9887 generate_gmac_large_plaintext(tdata->plaintext.data);
9889 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9891 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9893 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9894 debug_hexdump(stdout, "plaintext:", plaintext,
9895 tdata->plaintext.len);
9897 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9903 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9905 ut_params->op->sym->m_src = ut_params->ibuf;
9907 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9908 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9911 TEST_ASSERT_NOT_NULL(
9912 process_crypto_request(ts_params->valid_devs[0],
9913 ut_params->op), "failed to process sym crypto op");
9915 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9916 "crypto op processing failed");
9918 if (ut_params->op->sym->m_dst) {
9919 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9920 uint8_t *, plaintext_pad_len);
9922 auth_tag = plaintext + plaintext_pad_len;
9925 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9929 tdata->gmac_tag.data,
9930 tdata->gmac_tag.len,
9931 "GMAC Generated auth tag not as expected");
9937 test_AES_GMAC_authentication_test_case_1(void)
9939 return test_AES_GMAC_authentication(&gmac_test_case_1);
9943 test_AES_GMAC_authentication_test_case_2(void)
9945 return test_AES_GMAC_authentication(&gmac_test_case_2);
9949 test_AES_GMAC_authentication_test_case_3(void)
9951 return test_AES_GMAC_authentication(&gmac_test_case_3);
9955 test_AES_GMAC_authentication_test_case_4(void)
9957 return test_AES_GMAC_authentication(&gmac_test_case_4);
9961 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9963 struct crypto_testsuite_params *ts_params = &testsuite_params;
9964 struct crypto_unittest_params *ut_params = &unittest_params;
9966 uint32_t plaintext_pad_len;
9969 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9970 "No GMAC length in the source data");
9972 /* Verify the capabilities */
9973 struct rte_cryptodev_sym_capability_idx cap_idx;
9974 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9975 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9976 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9980 retval = create_gmac_session(ts_params->valid_devs[0],
9981 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9986 if (tdata->plaintext.len > MBUF_SIZE)
9987 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9989 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9990 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9991 "Failed to allocate input buffer in mempool");
9993 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9994 rte_pktmbuf_tailroom(ut_params->ibuf));
9996 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9999 * Runtime generate the large plain text instead of use hard code
10000 * plain text vector. It is done to avoid create huge source file
10001 * with the test vector.
10003 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10004 generate_gmac_large_plaintext(tdata->plaintext.data);
10006 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10007 plaintext_pad_len);
10008 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10010 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10011 debug_hexdump(stdout, "plaintext:", plaintext,
10012 tdata->plaintext.len);
10014 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10020 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10022 ut_params->op->sym->m_src = ut_params->ibuf;
10024 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10025 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10028 TEST_ASSERT_NOT_NULL(
10029 process_crypto_request(ts_params->valid_devs[0],
10030 ut_params->op), "failed to process sym crypto op");
10032 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10033 "crypto op processing failed");
10040 test_AES_GMAC_authentication_verify_test_case_1(void)
10042 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10046 test_AES_GMAC_authentication_verify_test_case_2(void)
10048 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10052 test_AES_GMAC_authentication_verify_test_case_3(void)
10054 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10058 test_AES_GMAC_authentication_verify_test_case_4(void)
10060 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10063 struct test_crypto_vector {
10064 enum rte_crypto_cipher_algorithm crypto_algo;
10065 unsigned int cipher_offset;
10066 unsigned int cipher_len;
10079 const uint8_t *data;
10084 const uint8_t *data;
10088 enum rte_crypto_auth_algorithm auth_algo;
10089 unsigned int auth_offset;
10097 const uint8_t *data;
10107 static const struct test_crypto_vector
10108 hmac_sha1_test_crypto_vector = {
10109 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10111 .data = plaintext_hash,
10116 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10117 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10118 0xDE, 0xF4, 0xDE, 0xAD
10124 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10125 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10126 0x3F, 0x91, 0x64, 0x59
10132 static const struct test_crypto_vector
10133 aes128_gmac_test_vector = {
10134 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10136 .data = plaintext_hash,
10141 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10142 0x08, 0x09, 0x0A, 0x0B
10148 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10149 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10155 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10156 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10162 static const struct test_crypto_vector
10163 aes128cbc_hmac_sha1_test_vector = {
10164 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10165 .cipher_offset = 0,
10169 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10170 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10176 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10177 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10182 .data = plaintext_hash,
10186 .data = ciphertext512_aes128cbc,
10189 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10193 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10194 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10195 0xDE, 0xF4, 0xDE, 0xAD
10201 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10202 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10203 0x18, 0x8C, 0x1D, 0x32
10209 static const struct test_crypto_vector
10210 aes128cbc_hmac_sha1_aad_test_vector = {
10211 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10212 .cipher_offset = 12,
10216 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10217 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10223 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10224 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10229 .data = plaintext_hash,
10233 .data = ciphertext512_aes128cbc_aad,
10236 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10240 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10241 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10242 0xDE, 0xF4, 0xDE, 0xAD
10248 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10249 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10250 0x62, 0x8D, 0x62, 0x65
10257 data_corruption(uint8_t *data)
10263 tag_corruption(uint8_t *data, unsigned int tag_offset)
10265 data[tag_offset] += 1;
10269 create_auth_session(struct crypto_unittest_params *ut_params,
10271 const struct test_crypto_vector *reference,
10272 enum rte_crypto_auth_operation auth_op)
10274 struct crypto_testsuite_params *ts_params = &testsuite_params;
10275 uint8_t auth_key[reference->auth_key.len + 1];
10277 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10279 /* Setup Authentication Parameters */
10280 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10281 ut_params->auth_xform.auth.op = auth_op;
10282 ut_params->auth_xform.next = NULL;
10283 ut_params->auth_xform.auth.algo = reference->auth_algo;
10284 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10285 ut_params->auth_xform.auth.key.data = auth_key;
10286 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10288 /* Create Crypto session*/
10289 ut_params->sess = rte_cryptodev_sym_session_create(
10290 ts_params->session_mpool);
10292 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10293 &ut_params->auth_xform,
10294 ts_params->session_priv_mpool);
10296 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10302 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10304 const struct test_crypto_vector *reference,
10305 enum rte_crypto_auth_operation auth_op,
10306 enum rte_crypto_cipher_operation cipher_op)
10308 struct crypto_testsuite_params *ts_params = &testsuite_params;
10309 uint8_t cipher_key[reference->cipher_key.len + 1];
10310 uint8_t auth_key[reference->auth_key.len + 1];
10312 memcpy(cipher_key, reference->cipher_key.data,
10313 reference->cipher_key.len);
10314 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10316 /* Setup Authentication Parameters */
10317 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10318 ut_params->auth_xform.auth.op = auth_op;
10319 ut_params->auth_xform.auth.algo = reference->auth_algo;
10320 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10321 ut_params->auth_xform.auth.key.data = auth_key;
10322 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10324 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10325 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10326 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10328 ut_params->auth_xform.next = &ut_params->cipher_xform;
10330 /* Setup Cipher Parameters */
10331 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10332 ut_params->cipher_xform.next = NULL;
10333 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10334 ut_params->cipher_xform.cipher.op = cipher_op;
10335 ut_params->cipher_xform.cipher.key.data = cipher_key;
10336 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10337 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10338 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10341 /* Create Crypto session*/
10342 ut_params->sess = rte_cryptodev_sym_session_create(
10343 ts_params->session_mpool);
10345 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10346 &ut_params->auth_xform,
10347 ts_params->session_priv_mpool);
10349 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10355 create_auth_operation(struct crypto_testsuite_params *ts_params,
10356 struct crypto_unittest_params *ut_params,
10357 const struct test_crypto_vector *reference,
10358 unsigned int auth_generate)
10360 /* Generate Crypto op data structure */
10361 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10362 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10363 TEST_ASSERT_NOT_NULL(ut_params->op,
10364 "Failed to allocate pktmbuf offload");
10366 /* Set crypto operation data parameters */
10367 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10369 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10371 /* set crypto operation source mbuf */
10372 sym_op->m_src = ut_params->ibuf;
10375 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10376 ut_params->ibuf, reference->digest.len);
10378 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10379 "no room to append auth tag");
10381 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10382 ut_params->ibuf, reference->plaintext.len);
10385 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10387 memcpy(sym_op->auth.digest.data,
10388 reference->digest.data,
10389 reference->digest.len);
10391 debug_hexdump(stdout, "digest:",
10392 sym_op->auth.digest.data,
10393 reference->digest.len);
10395 sym_op->auth.data.length = reference->plaintext.len;
10396 sym_op->auth.data.offset = 0;
10402 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10403 struct crypto_unittest_params *ut_params,
10404 const struct test_crypto_vector *reference,
10405 unsigned int auth_generate)
10407 /* Generate Crypto op data structure */
10408 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10409 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10410 TEST_ASSERT_NOT_NULL(ut_params->op,
10411 "Failed to allocate pktmbuf offload");
10413 /* Set crypto operation data parameters */
10414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10416 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10418 /* set crypto operation source mbuf */
10419 sym_op->m_src = ut_params->ibuf;
10422 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10423 ut_params->ibuf, reference->digest.len);
10425 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10426 "no room to append auth tag");
10428 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10429 ut_params->ibuf, reference->ciphertext.len);
10432 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10434 memcpy(sym_op->auth.digest.data,
10435 reference->digest.data,
10436 reference->digest.len);
10438 debug_hexdump(stdout, "digest:",
10439 sym_op->auth.digest.data,
10440 reference->digest.len);
10442 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10443 reference->iv.data, reference->iv.len);
10445 sym_op->cipher.data.length = 0;
10446 sym_op->cipher.data.offset = 0;
10448 sym_op->auth.data.length = reference->plaintext.len;
10449 sym_op->auth.data.offset = 0;
10455 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10456 struct crypto_unittest_params *ut_params,
10457 const struct test_crypto_vector *reference,
10458 unsigned int auth_generate)
10460 /* Generate Crypto op data structure */
10461 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10462 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10463 TEST_ASSERT_NOT_NULL(ut_params->op,
10464 "Failed to allocate pktmbuf offload");
10466 /* Set crypto operation data parameters */
10467 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10469 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10471 /* set crypto operation source mbuf */
10472 sym_op->m_src = ut_params->ibuf;
10475 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10476 ut_params->ibuf, reference->digest.len);
10478 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10479 "no room to append auth tag");
10481 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10482 ut_params->ibuf, reference->ciphertext.len);
10485 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10487 memcpy(sym_op->auth.digest.data,
10488 reference->digest.data,
10489 reference->digest.len);
10491 debug_hexdump(stdout, "digest:",
10492 sym_op->auth.digest.data,
10493 reference->digest.len);
10495 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10496 reference->iv.data, reference->iv.len);
10498 sym_op->cipher.data.length = reference->cipher_len;
10499 sym_op->cipher.data.offset = reference->cipher_offset;
10501 sym_op->auth.data.length = reference->plaintext.len;
10502 sym_op->auth.data.offset = reference->auth_offset;
10508 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10509 struct crypto_unittest_params *ut_params,
10510 const struct test_crypto_vector *reference)
10512 return create_auth_operation(ts_params, ut_params, reference, 0);
10516 create_auth_verify_GMAC_operation(
10517 struct crypto_testsuite_params *ts_params,
10518 struct crypto_unittest_params *ut_params,
10519 const struct test_crypto_vector *reference)
10521 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10525 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10526 struct crypto_unittest_params *ut_params,
10527 const struct test_crypto_vector *reference)
10529 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10533 test_authentication_verify_fail_when_data_corruption(
10534 struct crypto_testsuite_params *ts_params,
10535 struct crypto_unittest_params *ut_params,
10536 const struct test_crypto_vector *reference,
10537 unsigned int data_corrupted)
10541 uint8_t *plaintext;
10543 /* Verify the capabilities */
10544 struct rte_cryptodev_sym_capability_idx cap_idx;
10545 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10546 cap_idx.algo.auth = reference->auth_algo;
10547 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10551 /* Create session */
10552 retval = create_auth_session(ut_params,
10553 ts_params->valid_devs[0],
10555 RTE_CRYPTO_AUTH_OP_VERIFY);
10559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10560 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10561 "Failed to allocate input buffer in mempool");
10563 /* clear mbuf payload */
10564 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10565 rte_pktmbuf_tailroom(ut_params->ibuf));
10567 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10568 reference->plaintext.len);
10569 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10570 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10572 debug_hexdump(stdout, "plaintext:", plaintext,
10573 reference->plaintext.len);
10575 /* Create operation */
10576 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10581 if (data_corrupted)
10582 data_corruption(plaintext);
10584 tag_corruption(plaintext, reference->plaintext.len);
10586 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10587 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10589 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10590 RTE_CRYPTO_OP_STATUS_SUCCESS,
10591 "authentication not failed");
10593 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10595 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10602 test_authentication_verify_GMAC_fail_when_corruption(
10603 struct crypto_testsuite_params *ts_params,
10604 struct crypto_unittest_params *ut_params,
10605 const struct test_crypto_vector *reference,
10606 unsigned int data_corrupted)
10609 uint8_t *plaintext;
10611 /* Verify the capabilities */
10612 struct rte_cryptodev_sym_capability_idx cap_idx;
10613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10614 cap_idx.algo.auth = reference->auth_algo;
10615 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10619 /* Create session */
10620 retval = create_auth_cipher_session(ut_params,
10621 ts_params->valid_devs[0],
10623 RTE_CRYPTO_AUTH_OP_VERIFY,
10624 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10628 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10629 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10630 "Failed to allocate input buffer in mempool");
10632 /* clear mbuf payload */
10633 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10634 rte_pktmbuf_tailroom(ut_params->ibuf));
10636 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10637 reference->plaintext.len);
10638 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10639 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10641 debug_hexdump(stdout, "plaintext:", plaintext,
10642 reference->plaintext.len);
10644 /* Create operation */
10645 retval = create_auth_verify_GMAC_operation(ts_params,
10652 if (data_corrupted)
10653 data_corruption(plaintext);
10655 tag_corruption(plaintext, reference->aad.len);
10657 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10658 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10660 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10661 RTE_CRYPTO_OP_STATUS_SUCCESS,
10662 "authentication not failed");
10664 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10666 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10673 test_authenticated_decryption_fail_when_corruption(
10674 struct crypto_testsuite_params *ts_params,
10675 struct crypto_unittest_params *ut_params,
10676 const struct test_crypto_vector *reference,
10677 unsigned int data_corrupted)
10681 uint8_t *ciphertext;
10683 /* Verify the capabilities */
10684 struct rte_cryptodev_sym_capability_idx cap_idx;
10685 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10686 cap_idx.algo.auth = reference->auth_algo;
10687 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10690 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10691 cap_idx.algo.cipher = reference->crypto_algo;
10692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10696 /* Create session */
10697 retval = create_auth_cipher_session(ut_params,
10698 ts_params->valid_devs[0],
10700 RTE_CRYPTO_AUTH_OP_VERIFY,
10701 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10705 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10706 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10707 "Failed to allocate input buffer in mempool");
10709 /* clear mbuf payload */
10710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10711 rte_pktmbuf_tailroom(ut_params->ibuf));
10713 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10714 reference->ciphertext.len);
10715 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10716 memcpy(ciphertext, reference->ciphertext.data,
10717 reference->ciphertext.len);
10719 /* Create operation */
10720 retval = create_cipher_auth_verify_operation(ts_params,
10727 if (data_corrupted)
10728 data_corruption(ciphertext);
10730 tag_corruption(ciphertext, reference->ciphertext.len);
10732 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10733 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10735 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10736 RTE_CRYPTO_OP_STATUS_SUCCESS,
10737 "authentication not failed");
10739 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10741 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10748 test_authenticated_encryt_with_esn(
10749 struct crypto_testsuite_params *ts_params,
10750 struct crypto_unittest_params *ut_params,
10751 const struct test_crypto_vector *reference)
10755 uint8_t *authciphertext, *plaintext, *auth_tag;
10756 uint16_t plaintext_pad_len;
10757 uint8_t cipher_key[reference->cipher_key.len + 1];
10758 uint8_t auth_key[reference->auth_key.len + 1];
10760 /* Verify the capabilities */
10761 struct rte_cryptodev_sym_capability_idx cap_idx;
10762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10763 cap_idx.algo.auth = reference->auth_algo;
10764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10768 cap_idx.algo.cipher = reference->crypto_algo;
10769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10773 /* Create session */
10774 memcpy(cipher_key, reference->cipher_key.data,
10775 reference->cipher_key.len);
10776 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10778 /* Setup Cipher Parameters */
10779 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10780 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10781 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10782 ut_params->cipher_xform.cipher.key.data = cipher_key;
10783 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10784 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10785 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10787 ut_params->cipher_xform.next = &ut_params->auth_xform;
10789 /* Setup Authentication Parameters */
10790 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10791 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10792 ut_params->auth_xform.auth.algo = reference->auth_algo;
10793 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10794 ut_params->auth_xform.auth.key.data = auth_key;
10795 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10796 ut_params->auth_xform.next = NULL;
10798 /* Create Crypto session*/
10799 ut_params->sess = rte_cryptodev_sym_session_create(
10800 ts_params->session_mpool);
10802 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10804 &ut_params->cipher_xform,
10805 ts_params->session_priv_mpool);
10807 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10809 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10810 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10811 "Failed to allocate input buffer in mempool");
10813 /* clear mbuf payload */
10814 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10815 rte_pktmbuf_tailroom(ut_params->ibuf));
10817 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10818 reference->plaintext.len);
10819 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10820 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10822 /* Create operation */
10823 retval = create_cipher_auth_operation(ts_params,
10830 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10831 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10834 ut_params->op = process_crypto_request(
10835 ts_params->valid_devs[0], ut_params->op);
10837 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10839 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10840 "crypto op processing failed");
10842 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10844 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10845 ut_params->op->sym->auth.data.offset);
10846 auth_tag = authciphertext + plaintext_pad_len;
10847 debug_hexdump(stdout, "ciphertext:", authciphertext,
10848 reference->ciphertext.len);
10849 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10851 /* Validate obuf */
10852 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10854 reference->ciphertext.data,
10855 reference->ciphertext.len,
10856 "Ciphertext data not as expected");
10858 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10860 reference->digest.data,
10861 reference->digest.len,
10862 "Generated digest not as expected");
10864 return TEST_SUCCESS;
10869 test_authenticated_decrypt_with_esn(
10870 struct crypto_testsuite_params *ts_params,
10871 struct crypto_unittest_params *ut_params,
10872 const struct test_crypto_vector *reference)
10876 uint8_t *ciphertext;
10877 uint8_t cipher_key[reference->cipher_key.len + 1];
10878 uint8_t auth_key[reference->auth_key.len + 1];
10880 /* Verify the capabilities */
10881 struct rte_cryptodev_sym_capability_idx cap_idx;
10882 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10883 cap_idx.algo.auth = reference->auth_algo;
10884 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10887 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10888 cap_idx.algo.cipher = reference->crypto_algo;
10889 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10893 /* Create session */
10894 memcpy(cipher_key, reference->cipher_key.data,
10895 reference->cipher_key.len);
10896 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10898 /* Setup Authentication Parameters */
10899 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10900 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10901 ut_params->auth_xform.auth.algo = reference->auth_algo;
10902 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10903 ut_params->auth_xform.auth.key.data = auth_key;
10904 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10905 ut_params->auth_xform.next = &ut_params->cipher_xform;
10907 /* Setup Cipher Parameters */
10908 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10909 ut_params->cipher_xform.next = NULL;
10910 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10911 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10912 ut_params->cipher_xform.cipher.key.data = cipher_key;
10913 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10914 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10915 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10917 /* Create Crypto session*/
10918 ut_params->sess = rte_cryptodev_sym_session_create(
10919 ts_params->session_mpool);
10921 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10923 &ut_params->auth_xform,
10924 ts_params->session_priv_mpool);
10926 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10929 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10930 "Failed to allocate input buffer in mempool");
10932 /* clear mbuf payload */
10933 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10934 rte_pktmbuf_tailroom(ut_params->ibuf));
10936 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10937 reference->ciphertext.len);
10938 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10939 memcpy(ciphertext, reference->ciphertext.data,
10940 reference->ciphertext.len);
10942 /* Create operation */
10943 retval = create_cipher_auth_verify_operation(ts_params,
10950 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10951 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10954 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10957 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10958 TEST_ASSERT_EQUAL(ut_params->op->status,
10959 RTE_CRYPTO_OP_STATUS_SUCCESS,
10960 "crypto op processing passed");
10962 ut_params->obuf = ut_params->op->sym->m_src;
10963 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10969 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10970 const struct aead_test_data *tdata,
10971 void *digest_mem, uint64_t digest_phys)
10973 struct crypto_testsuite_params *ts_params = &testsuite_params;
10974 struct crypto_unittest_params *ut_params = &unittest_params;
10976 const unsigned int auth_tag_len = tdata->auth_tag.len;
10977 const unsigned int iv_len = tdata->iv.len;
10978 unsigned int aad_len = tdata->aad.len;
10979 unsigned int aad_len_pad = 0;
10981 /* Generate Crypto op data structure */
10982 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10983 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10984 TEST_ASSERT_NOT_NULL(ut_params->op,
10985 "Failed to allocate symmetric crypto operation struct");
10987 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10989 sym_op->aead.digest.data = digest_mem;
10991 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10992 "no room to append digest");
10994 sym_op->aead.digest.phys_addr = digest_phys;
10996 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10997 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10999 debug_hexdump(stdout, "digest:",
11000 sym_op->aead.digest.data,
11004 /* Append aad data */
11005 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11006 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11007 uint8_t *, IV_OFFSET);
11009 /* Copy IV 1 byte after the IV pointer, according to the API */
11010 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11012 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11014 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11015 ut_params->ibuf, aad_len);
11016 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11017 "no room to prepend aad");
11018 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11021 memset(sym_op->aead.aad.data, 0, aad_len);
11022 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11023 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11025 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11026 debug_hexdump(stdout, "aad:",
11027 sym_op->aead.aad.data, aad_len);
11029 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11030 uint8_t *, IV_OFFSET);
11032 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11034 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11036 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11037 ut_params->ibuf, aad_len_pad);
11038 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11039 "no room to prepend aad");
11040 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11043 memset(sym_op->aead.aad.data, 0, aad_len);
11044 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11046 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11047 debug_hexdump(stdout, "aad:",
11048 sym_op->aead.aad.data, aad_len);
11051 sym_op->aead.data.length = tdata->plaintext.len;
11052 sym_op->aead.data.offset = aad_len_pad;
11057 #define SGL_MAX_NO 16
11060 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11061 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11063 struct crypto_testsuite_params *ts_params = &testsuite_params;
11064 struct crypto_unittest_params *ut_params = &unittest_params;
11065 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11068 int to_trn_tbl[SGL_MAX_NO];
11070 unsigned int trn_data = 0;
11071 uint8_t *plaintext, *ciphertext, *auth_tag;
11072 struct rte_cryptodev_info dev_info;
11074 /* Verify the capabilities */
11075 struct rte_cryptodev_sym_capability_idx cap_idx;
11076 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11077 cap_idx.algo.aead = tdata->algo;
11078 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11082 /* OOP not supported with CPU crypto */
11083 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11086 /* Detailed check for the particular SGL support flag */
11087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11089 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11090 if (sgl_in && (!(dev_info.feature_flags &
11091 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11094 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11095 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11096 tdata->plaintext.len;
11097 if (sgl_in && !sgl_out) {
11098 if (!(dev_info.feature_flags &
11099 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11101 } else if (!sgl_in && sgl_out) {
11102 if (!(dev_info.feature_flags &
11103 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11105 } else if (sgl_in && sgl_out) {
11106 if (!(dev_info.feature_flags &
11107 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11112 if (fragsz > tdata->plaintext.len)
11113 fragsz = tdata->plaintext.len;
11115 uint16_t plaintext_len = fragsz;
11116 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11118 if (fragsz_oop > tdata->plaintext.len)
11119 frag_size_oop = tdata->plaintext.len;
11122 void *digest_mem = NULL;
11124 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11126 if (tdata->plaintext.len % fragsz != 0) {
11127 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11130 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11135 * For out-op-place we need to alloc another mbuf
11138 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11139 rte_pktmbuf_append(ut_params->obuf,
11140 frag_size_oop + prepend_len);
11141 buf_oop = ut_params->obuf;
11144 /* Create AEAD session */
11145 retval = create_aead_session(ts_params->valid_devs[0],
11147 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11148 tdata->key.data, tdata->key.len,
11149 tdata->aad.len, tdata->auth_tag.len,
11154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11156 /* clear mbuf payload */
11157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11158 rte_pktmbuf_tailroom(ut_params->ibuf));
11160 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11163 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11165 trn_data += plaintext_len;
11167 buf = ut_params->ibuf;
11170 * Loop until no more fragments
11173 while (trn_data < tdata->plaintext.len) {
11175 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11176 (tdata->plaintext.len - trn_data) : fragsz;
11178 to_trn_tbl[ecx++] = to_trn;
11180 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11183 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11184 rte_pktmbuf_tailroom(buf));
11187 if (oop && !fragsz_oop) {
11188 buf_last_oop = buf_oop->next =
11189 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11190 buf_oop = buf_oop->next;
11191 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11192 0, rte_pktmbuf_tailroom(buf_oop));
11193 rte_pktmbuf_append(buf_oop, to_trn);
11196 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11199 memcpy(plaintext, tdata->plaintext.data + trn_data,
11201 trn_data += to_trn;
11202 if (trn_data == tdata->plaintext.len) {
11205 digest_mem = rte_pktmbuf_append(buf_oop,
11206 tdata->auth_tag.len);
11208 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11209 tdata->auth_tag.len);
11213 uint64_t digest_phys = 0;
11215 ut_params->ibuf->nb_segs = segs;
11218 if (fragsz_oop && oop) {
11222 if (frag_size_oop == tdata->plaintext.len) {
11223 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11224 tdata->auth_tag.len);
11226 digest_phys = rte_pktmbuf_iova_offset(
11228 tdata->plaintext.len + prepend_len);
11231 trn_data = frag_size_oop;
11232 while (trn_data < tdata->plaintext.len) {
11235 (tdata->plaintext.len - trn_data <
11237 (tdata->plaintext.len - trn_data) :
11240 to_trn_tbl[ecx++] = to_trn;
11242 buf_last_oop = buf_oop->next =
11243 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11244 buf_oop = buf_oop->next;
11245 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11246 0, rte_pktmbuf_tailroom(buf_oop));
11247 rte_pktmbuf_append(buf_oop, to_trn);
11249 trn_data += to_trn;
11251 if (trn_data == tdata->plaintext.len) {
11252 digest_mem = rte_pktmbuf_append(buf_oop,
11253 tdata->auth_tag.len);
11257 ut_params->obuf->nb_segs = segs;
11261 * Place digest at the end of the last buffer
11264 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11265 if (oop && buf_last_oop)
11266 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11268 if (!digest_mem && !oop) {
11269 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11270 + tdata->auth_tag.len);
11271 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11272 tdata->plaintext.len);
11275 /* Create AEAD operation */
11276 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11277 tdata, digest_mem, digest_phys);
11282 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11284 ut_params->op->sym->m_src = ut_params->ibuf;
11286 ut_params->op->sym->m_dst = ut_params->obuf;
11288 /* Process crypto operation */
11289 if (oop == IN_PLACE &&
11290 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11291 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11293 TEST_ASSERT_NOT_NULL(
11294 process_crypto_request(ts_params->valid_devs[0],
11295 ut_params->op), "failed to process sym crypto op");
11297 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11298 "crypto op processing failed");
11301 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11302 uint8_t *, prepend_len);
11304 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11305 uint8_t *, prepend_len);
11309 fragsz = fragsz_oop;
11311 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11313 tdata->ciphertext.data,
11315 "Ciphertext data not as expected");
11317 buf = ut_params->op->sym->m_src->next;
11319 buf = ut_params->op->sym->m_dst->next;
11321 unsigned int off = fragsz;
11325 ciphertext = rte_pktmbuf_mtod(buf,
11328 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11330 tdata->ciphertext.data + off,
11332 "Ciphertext data not as expected");
11334 off += to_trn_tbl[ecx++];
11338 auth_tag = digest_mem;
11339 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11341 tdata->auth_tag.data,
11342 tdata->auth_tag.len,
11343 "Generated auth tag not as expected");
11349 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11351 return test_authenticated_encryption_SGL(
11352 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11356 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11358 return test_authenticated_encryption_SGL(
11359 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11363 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11365 return test_authenticated_encryption_SGL(
11366 &gcm_test_case_8, OUT_OF_PLACE, 400,
11367 gcm_test_case_8.plaintext.len);
11371 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11373 /* This test is not for OPENSSL PMD */
11374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11375 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11378 return test_authenticated_encryption_SGL(
11379 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11383 test_authentication_verify_fail_when_data_corrupted(
11384 struct crypto_testsuite_params *ts_params,
11385 struct crypto_unittest_params *ut_params,
11386 const struct test_crypto_vector *reference)
11388 return test_authentication_verify_fail_when_data_corruption(
11389 ts_params, ut_params, reference, 1);
11393 test_authentication_verify_fail_when_tag_corrupted(
11394 struct crypto_testsuite_params *ts_params,
11395 struct crypto_unittest_params *ut_params,
11396 const struct test_crypto_vector *reference)
11398 return test_authentication_verify_fail_when_data_corruption(
11399 ts_params, ut_params, reference, 0);
11403 test_authentication_verify_GMAC_fail_when_data_corrupted(
11404 struct crypto_testsuite_params *ts_params,
11405 struct crypto_unittest_params *ut_params,
11406 const struct test_crypto_vector *reference)
11408 return test_authentication_verify_GMAC_fail_when_corruption(
11409 ts_params, ut_params, reference, 1);
11413 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11414 struct crypto_testsuite_params *ts_params,
11415 struct crypto_unittest_params *ut_params,
11416 const struct test_crypto_vector *reference)
11418 return test_authentication_verify_GMAC_fail_when_corruption(
11419 ts_params, ut_params, reference, 0);
11423 test_authenticated_decryption_fail_when_data_corrupted(
11424 struct crypto_testsuite_params *ts_params,
11425 struct crypto_unittest_params *ut_params,
11426 const struct test_crypto_vector *reference)
11428 return test_authenticated_decryption_fail_when_corruption(
11429 ts_params, ut_params, reference, 1);
11433 test_authenticated_decryption_fail_when_tag_corrupted(
11434 struct crypto_testsuite_params *ts_params,
11435 struct crypto_unittest_params *ut_params,
11436 const struct test_crypto_vector *reference)
11438 return test_authenticated_decryption_fail_when_corruption(
11439 ts_params, ut_params, reference, 0);
11443 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11445 return test_authentication_verify_fail_when_data_corrupted(
11446 &testsuite_params, &unittest_params,
11447 &hmac_sha1_test_crypto_vector);
11451 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11453 return test_authentication_verify_fail_when_tag_corrupted(
11454 &testsuite_params, &unittest_params,
11455 &hmac_sha1_test_crypto_vector);
11459 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11461 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11462 &testsuite_params, &unittest_params,
11463 &aes128_gmac_test_vector);
11467 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11469 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11470 &testsuite_params, &unittest_params,
11471 &aes128_gmac_test_vector);
11475 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11477 return test_authenticated_decryption_fail_when_data_corrupted(
11480 &aes128cbc_hmac_sha1_test_vector);
11484 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11486 return test_authenticated_decryption_fail_when_tag_corrupted(
11489 &aes128cbc_hmac_sha1_test_vector);
11493 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11495 return test_authenticated_encryt_with_esn(
11498 &aes128cbc_hmac_sha1_aad_test_vector);
11502 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11504 return test_authenticated_decrypt_with_esn(
11507 &aes128cbc_hmac_sha1_aad_test_vector);
11510 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11512 /* global AESNI slave IDs for the scheduler test */
11513 uint8_t aesni_ids[2];
11516 test_scheduler_attach_slave_op(void)
11518 struct crypto_testsuite_params *ts_params = &testsuite_params;
11519 uint8_t sched_id = ts_params->valid_devs[0];
11520 uint32_t nb_devs, i, nb_devs_attached = 0;
11522 char vdev_name[32];
11524 /* create 2 AESNI_MB if necessary */
11525 nb_devs = rte_cryptodev_device_count_by_driver(
11526 rte_cryptodev_driver_id_get(
11527 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11529 for (i = nb_devs; i < 2; i++) {
11530 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11531 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11533 ret = rte_vdev_init(vdev_name, NULL);
11535 TEST_ASSERT(ret == 0,
11536 "Failed to create instance %u of"
11538 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11542 /* attach 2 AESNI_MB cdevs */
11543 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11545 struct rte_cryptodev_info info;
11546 unsigned int session_size;
11548 rte_cryptodev_info_get(i, &info);
11549 if (info.driver_id != rte_cryptodev_driver_id_get(
11550 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11553 session_size = rte_cryptodev_sym_get_private_session_size(i);
11555 * Create the session mempool again, since now there are new devices
11556 * to use the mempool.
11558 if (ts_params->session_mpool) {
11559 rte_mempool_free(ts_params->session_mpool);
11560 ts_params->session_mpool = NULL;
11562 if (ts_params->session_priv_mpool) {
11563 rte_mempool_free(ts_params->session_priv_mpool);
11564 ts_params->session_priv_mpool = NULL;
11567 if (info.sym.max_nb_sessions != 0 &&
11568 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11569 RTE_LOG(ERR, USER1,
11570 "Device does not support "
11571 "at least %u sessions\n",
11573 return TEST_FAILED;
11576 * Create mempool with maximum number of sessions,
11577 * to include the session headers
11579 if (ts_params->session_mpool == NULL) {
11580 ts_params->session_mpool =
11581 rte_cryptodev_sym_session_pool_create(
11583 MAX_NB_SESSIONS, 0, 0, 0,
11585 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11586 "session mempool allocation failed");
11590 * Create mempool with maximum number of sessions,
11591 * to include device specific session private data
11593 if (ts_params->session_priv_mpool == NULL) {
11594 ts_params->session_priv_mpool = rte_mempool_create(
11595 "test_sess_mp_priv",
11598 0, 0, NULL, NULL, NULL,
11599 NULL, SOCKET_ID_ANY,
11602 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11603 "session mempool allocation failed");
11606 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11607 ts_params->qp_conf.mp_session_private =
11608 ts_params->session_priv_mpool;
11610 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11613 TEST_ASSERT(ret == 0,
11614 "Failed to attach device %u of pmd : %s", i,
11615 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11617 aesni_ids[nb_devs_attached] = (uint8_t)i;
11619 nb_devs_attached++;
11626 test_scheduler_detach_slave_op(void)
11628 struct crypto_testsuite_params *ts_params = &testsuite_params;
11629 uint8_t sched_id = ts_params->valid_devs[0];
11633 for (i = 0; i < 2; i++) {
11634 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11636 TEST_ASSERT(ret == 0,
11637 "Failed to detach device %u", aesni_ids[i]);
11644 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11646 struct crypto_testsuite_params *ts_params = &testsuite_params;
11647 uint8_t sched_id = ts_params->valid_devs[0];
11649 return rte_cryptodev_scheduler_mode_set(sched_id,
11654 test_scheduler_mode_roundrobin_op(void)
11656 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11657 0, "Failed to set roundrobin mode");
11663 test_scheduler_mode_multicore_op(void)
11665 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11666 0, "Failed to set multicore mode");
11672 test_scheduler_mode_failover_op(void)
11674 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11675 0, "Failed to set failover mode");
11681 test_scheduler_mode_pkt_size_distr_op(void)
11683 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11684 0, "Failed to set pktsize mode");
11689 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11690 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11691 .setup = testsuite_setup,
11692 .teardown = testsuite_teardown,
11693 .unit_test_cases = {
11695 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11696 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11697 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11698 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11699 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11700 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11703 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11704 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11705 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11706 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11707 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11708 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11711 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11712 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11713 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11714 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11715 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11716 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11719 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11720 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11721 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11722 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11723 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11724 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11726 TEST_CASES_END() /**< NULL terminate unit test array */
11730 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11732 static struct unit_test_suite cryptodev_testsuite = {
11733 .suite_name = "Crypto Unit Test Suite",
11734 .setup = testsuite_setup,
11735 .teardown = testsuite_teardown,
11736 .unit_test_cases = {
11737 TEST_CASE_ST(ut_setup, ut_teardown,
11738 test_device_configure_invalid_dev_id),
11739 TEST_CASE_ST(ut_setup, ut_teardown,
11740 test_queue_pair_descriptor_setup),
11741 TEST_CASE_ST(ut_setup, ut_teardown,
11742 test_device_configure_invalid_queue_pair_ids),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_multi_session),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_multi_session_random_usage),
11749 TEST_CASE_ST(ut_setup, ut_teardown,
11750 test_null_invalid_operation),
11751 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11753 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11754 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11755 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11757 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11758 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11759 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11760 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11761 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11763 /** AES CCM Authenticated Encryption 128 bits key */
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_CCM_authenticated_encryption_test_case_128_1),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_CCM_authenticated_encryption_test_case_128_2),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_AES_CCM_authenticated_encryption_test_case_128_3),
11771 /** AES CCM Authenticated Decryption 128 bits key*/
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_CCM_authenticated_decryption_test_case_128_1),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_CCM_authenticated_decryption_test_case_128_2),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_AES_CCM_authenticated_decryption_test_case_128_3),
11779 /** AES CCM Authenticated Encryption 192 bits key */
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_CCM_authenticated_encryption_test_case_192_1),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_CCM_authenticated_encryption_test_case_192_2),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_CCM_authenticated_encryption_test_case_192_3),
11787 /** AES CCM Authenticated Decryption 192 bits key*/
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_CCM_authenticated_decryption_test_case_192_1),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_CCM_authenticated_decryption_test_case_192_2),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_CCM_authenticated_decryption_test_case_192_3),
11795 /** AES CCM Authenticated Encryption 256 bits key */
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_CCM_authenticated_encryption_test_case_256_1),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_CCM_authenticated_encryption_test_case_256_2),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_AES_CCM_authenticated_encryption_test_case_256_3),
11803 /** AES CCM Authenticated Decryption 256 bits key*/
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_CCM_authenticated_decryption_test_case_256_1),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_CCM_authenticated_decryption_test_case_256_2),
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_AES_CCM_authenticated_decryption_test_case_256_3),
11811 /** AES GCM Authenticated Encryption */
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_GCM_authenticated_encryption_test_case_1),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_GCM_authenticated_encryption_test_case_2),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_AES_GCM_authenticated_encryption_test_case_3),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_AES_GCM_authenticated_encryption_test_case_4),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_authenticated_encryption_test_case_5),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_GCM_authenticated_encryption_test_case_6),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_GCM_authenticated_encryption_test_case_7),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_authenticated_encryption_test_case_8),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11839 /** AES GCM Authenticated Decryption */
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_AES_GCM_authenticated_decryption_test_case_1),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_authenticated_decryption_test_case_2),
11844 TEST_CASE_ST(ut_setup, ut_teardown,
11845 test_AES_GCM_authenticated_decryption_test_case_3),
11846 TEST_CASE_ST(ut_setup, ut_teardown,
11847 test_AES_GCM_authenticated_decryption_test_case_4),
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GCM_authenticated_decryption_test_case_5),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GCM_authenticated_decryption_test_case_6),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_GCM_authenticated_decryption_test_case_7),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_GCM_authenticated_decryption_test_case_8),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11859 /** AES GCM Authenticated Encryption 192 bits key */
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_GCM_auth_encryption_test_case_192_1),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_AES_GCM_auth_encryption_test_case_192_2),
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_AES_GCM_auth_encryption_test_case_192_3),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_AES_GCM_auth_encryption_test_case_192_4),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_AES_GCM_auth_encryption_test_case_192_5),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_GCM_auth_encryption_test_case_192_6),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_AES_GCM_auth_encryption_test_case_192_7),
11875 /** AES GCM Authenticated Decryption 192 bits key */
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_GCM_auth_decryption_test_case_192_1),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_GCM_auth_decryption_test_case_192_2),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_AES_GCM_auth_decryption_test_case_192_3),
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_AES_GCM_auth_decryption_test_case_192_4),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_AES_GCM_auth_decryption_test_case_192_5),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_AES_GCM_auth_decryption_test_case_192_6),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_AES_GCM_auth_decryption_test_case_192_7),
11891 /** AES GCM Authenticated Encryption 256 bits key */
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_AES_GCM_auth_encryption_test_case_256_1),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_GCM_auth_encryption_test_case_256_2),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_GCM_auth_encryption_test_case_256_3),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_GCM_auth_encryption_test_case_256_4),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_GCM_auth_encryption_test_case_256_5),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_GCM_auth_encryption_test_case_256_6),
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_AES_GCM_auth_encryption_test_case_256_7),
11907 /** AES GCM Authenticated Decryption 256 bits key */
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_AES_GCM_auth_decryption_test_case_256_1),
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_AES_GCM_auth_decryption_test_case_256_2),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_GCM_auth_decryption_test_case_256_3),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_AES_GCM_auth_decryption_test_case_256_4),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 test_AES_GCM_auth_decryption_test_case_256_5),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_AES_GCM_auth_decryption_test_case_256_6),
11920 TEST_CASE_ST(ut_setup, ut_teardown,
11921 test_AES_GCM_auth_decryption_test_case_256_7),
11923 /** AES GCM Authenticated Encryption big aad size */
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_AES_GCM_auth_encryption_test_case_aad_1),
11926 TEST_CASE_ST(ut_setup, ut_teardown,
11927 test_AES_GCM_auth_encryption_test_case_aad_2),
11929 /** AES GCM Authenticated Decryption big aad size */
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_AES_GCM_auth_decryption_test_case_aad_1),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_AES_GCM_auth_decryption_test_case_aad_2),
11935 /** Out of place tests */
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11941 /** Session-less tests */
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11944 TEST_CASE_ST(ut_setup, ut_teardown,
11945 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11947 /** AES GMAC Authentication */
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GMAC_authentication_test_case_1),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_GMAC_authentication_verify_test_case_1),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_GMAC_authentication_test_case_2),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GMAC_authentication_verify_test_case_2),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_GMAC_authentication_test_case_3),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_GMAC_authentication_verify_test_case_3),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_GMAC_authentication_test_case_4),
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 test_AES_GMAC_authentication_verify_test_case_4),
11965 /** SNOW 3G encrypt only (UEA2) */
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_snow3g_encryption_test_case_1),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_snow3g_encryption_test_case_2),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_snow3g_encryption_test_case_3),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_snow3g_encryption_test_case_4),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_snow3g_encryption_test_case_5),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_snow3g_encryption_test_case_1_oop),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_snow3g_encryption_test_case_1_oop_sgl),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_snow3g_encryption_test_case_1_offset_oop),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_snow3g_decryption_test_case_1_oop),
11986 /** SNOW 3G generate auth, then encrypt (UEA2) */
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_snow3g_auth_cipher_test_case_1),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_snow3g_auth_cipher_test_case_2),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_snow3g_auth_cipher_test_case_2_oop),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_snow3g_auth_cipher_part_digest_enc),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_snow3g_auth_cipher_part_digest_enc_oop),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_snow3g_auth_cipher_test_case_3_sgl),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_auth_cipher_part_digest_enc_sgl),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12006 /** SNOW 3G decrypt (UEA2), then verify auth */
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_auth_cipher_verify_test_case_1),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_snow3g_auth_cipher_verify_test_case_2),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_snow3g_auth_cipher_verify_test_case_2_oop),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_snow3g_auth_cipher_verify_part_digest_enc),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12026 /** SNOW 3G decrypt only (UEA2) */
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_snow3g_decryption_test_case_1),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_snow3g_decryption_test_case_2),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_snow3g_decryption_test_case_3),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_snow3g_decryption_test_case_4),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_snow3g_decryption_test_case_5),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_snow3g_decryption_with_digest_test_case_1),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_snow3g_hash_generate_test_case_1),
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_snow3g_hash_generate_test_case_2),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_snow3g_hash_generate_test_case_3),
12045 /* Tests with buffers which length is not byte-aligned */
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_hash_generate_test_case_4),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_hash_generate_test_case_5),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_hash_generate_test_case_6),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_hash_verify_test_case_1),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_hash_verify_test_case_2),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_hash_verify_test_case_3),
12058 /* Tests with buffers which length is not byte-aligned */
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_snow3g_hash_verify_test_case_4),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_snow3g_hash_verify_test_case_5),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_snow3g_hash_verify_test_case_6),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_snow3g_cipher_auth_test_case_1),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_snow3g_auth_cipher_with_digest_test_case_1),
12070 /** ZUC encrypt only (EEA3) */
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_zuc_encryption_test_case_1),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_zuc_encryption_test_case_2),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_zuc_encryption_test_case_3),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_zuc_encryption_test_case_4),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_zuc_encryption_test_case_5),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_zuc_encryption_test_case_6_sgl),
12084 /** ZUC authenticate (EIA3) */
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_zuc_hash_generate_test_case_1),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_zuc_hash_generate_test_case_2),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_zuc_hash_generate_test_case_3),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_zuc_hash_generate_test_case_4),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_zuc_hash_generate_test_case_5),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_zuc_hash_generate_test_case_6),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_zuc_hash_generate_test_case_7),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_zuc_hash_generate_test_case_8),
12102 /** ZUC alg-chain (EEA3/EIA3) */
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_zuc_cipher_auth_test_case_1),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_zuc_cipher_auth_test_case_2),
12108 /** ZUC generate auth, then encrypt (EEA3) */
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_zuc_auth_cipher_test_case_1),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_zuc_auth_cipher_test_case_1_oop),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_zuc_auth_cipher_test_case_1_sgl),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_zuc_auth_cipher_test_case_1_oop_sgl),
12118 /** ZUC decrypt (EEA3), then verify auth */
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_zuc_auth_cipher_verify_test_case_1),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_zuc_auth_cipher_verify_test_case_1_oop),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_zuc_auth_cipher_verify_test_case_1_sgl),
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12128 /** HMAC_MD5 Authentication */
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_MD5_HMAC_generate_case_1),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_MD5_HMAC_verify_case_1),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_MD5_HMAC_generate_case_2),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_MD5_HMAC_verify_case_2),
12138 /** KASUMI hash only (UIA1) */
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_kasumi_hash_generate_test_case_1),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_kasumi_hash_generate_test_case_2),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_kasumi_hash_generate_test_case_3),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_kasumi_hash_generate_test_case_4),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_kasumi_hash_generate_test_case_5),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_kasumi_hash_generate_test_case_6),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_kasumi_hash_verify_test_case_1),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_kasumi_hash_verify_test_case_2),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_kasumi_hash_verify_test_case_3),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_kasumi_hash_verify_test_case_4),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_kasumi_hash_verify_test_case_5),
12163 /** KASUMI encrypt only (UEA1) */
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_kasumi_encryption_test_case_1),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_kasumi_encryption_test_case_1_sgl),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_kasumi_encryption_test_case_1_oop),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_kasumi_encryption_test_case_1_oop_sgl),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_encryption_test_case_2),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_encryption_test_case_3),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_encryption_test_case_4),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_kasumi_encryption_test_case_5),
12181 /** KASUMI decrypt only (UEA1) */
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_decryption_test_case_1),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_kasumi_decryption_test_case_2),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_kasumi_decryption_test_case_3),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_kasumi_decryption_test_case_4),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_kasumi_decryption_test_case_5),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_kasumi_decryption_test_case_1_oop),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_kasumi_cipher_auth_test_case_1),
12198 /** KASUMI generate auth, then encrypt (F8) */
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_auth_cipher_test_case_1),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_auth_cipher_test_case_2),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_auth_cipher_test_case_2_oop),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_auth_cipher_test_case_2_sgl),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12210 /** KASUMI decrypt (F8), then verify auth */
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_auth_cipher_verify_test_case_1),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_auth_cipher_verify_test_case_2),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_auth_cipher_verify_test_case_2_oop),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12222 /** ESN Testcase */
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12228 /** Negative tests */
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 authentication_verify_AES128_GMAC_fail_data_corrupt),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12266 /** Mixed CIPHER + HASH algorithms */
12267 /** AUTH AES CMAC + CIPHER AES CTR */
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12285 /** AUTH ZUC + CIPHER SNOW3G */
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_auth_zuc_cipher_snow_test_case_1),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_verify_auth_zuc_cipher_snow_test_case_1),
12290 /** AUTH AES CMAC + CIPHER SNOW3G */
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_auth_aes_cmac_cipher_snow_test_case_1),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12295 /** AUTH ZUC + CIPHER AES CTR */
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_auth_zuc_cipher_aes_ctr_test_case_1),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12300 /** AUTH SNOW3G + CIPHER AES CTR */
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_auth_snow_cipher_aes_ctr_test_case_1),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12305 /** AUTH SNOW3G + CIPHER ZUC */
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 test_auth_snow_cipher_zuc_test_case_1),
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 test_verify_auth_snow_cipher_zuc_test_case_1),
12310 /** AUTH AES CMAC + CIPHER ZUC */
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_auth_aes_cmac_cipher_zuc_test_case_1),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12316 /** AUTH NULL + CIPHER SNOW3G */
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_auth_null_cipher_snow_test_case_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_verify_auth_null_cipher_snow_test_case_1),
12321 /** AUTH NULL + CIPHER ZUC */
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 test_auth_null_cipher_zuc_test_case_1),
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 test_verify_auth_null_cipher_zuc_test_case_1),
12326 /** AUTH SNOW3G + CIPHER NULL */
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_auth_snow_cipher_null_test_case_1),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_verify_auth_snow_cipher_null_test_case_1),
12331 /** AUTH ZUC + CIPHER NULL */
12332 TEST_CASE_ST(ut_setup, ut_teardown,
12333 test_auth_zuc_cipher_null_test_case_1),
12334 TEST_CASE_ST(ut_setup, ut_teardown,
12335 test_verify_auth_zuc_cipher_null_test_case_1),
12336 /** AUTH NULL + CIPHER AES CTR */
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_auth_null_cipher_aes_ctr_test_case_1),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12341 /** AUTH AES CMAC + CIPHER NULL */
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_auth_aes_cmac_cipher_null_test_case_1),
12344 TEST_CASE_ST(ut_setup, ut_teardown,
12345 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12347 #ifdef RTE_LIBRTE_SECURITY
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_PDCP_PROTO_all),
12351 TEST_CASES_END() /**< NULL terminate unit test array */
12355 static struct unit_test_suite cryptodev_virtio_testsuite = {
12356 .suite_name = "Crypto VIRTIO Unit Test Suite",
12357 .setup = testsuite_setup,
12358 .teardown = testsuite_teardown,
12359 .unit_test_cases = {
12360 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12362 TEST_CASES_END() /**< NULL terminate unit test array */
12366 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12367 .suite_name = "Crypto CAAM JR Unit Test Suite",
12368 .setup = testsuite_setup,
12369 .teardown = testsuite_teardown,
12370 .unit_test_cases = {
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_device_configure_invalid_dev_id),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_multi_session),
12376 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12377 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12378 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12379 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12380 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12382 TEST_CASES_END() /**< NULL terminate unit test array */
12386 static struct unit_test_suite cryptodev_armv8_testsuite = {
12387 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12388 .setup = testsuite_setup,
12389 .teardown = testsuite_teardown,
12390 .unit_test_cases = {
12391 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12393 /** Negative tests */
12394 TEST_CASE_ST(ut_setup, ut_teardown,
12395 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12399 TEST_CASES_END() /**< NULL terminate unit test array */
12403 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12404 .suite_name = "Crypto Device Marvell Component Test Suite",
12405 .setup = testsuite_setup,
12406 .teardown = testsuite_teardown,
12407 .unit_test_cases = {
12408 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_multi_session_random_usage),
12411 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12412 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12413 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12414 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12415 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12417 /** Negative tests */
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12427 TEST_CASES_END() /**< NULL terminate unit test array */
12431 static struct unit_test_suite cryptodev_ccp_testsuite = {
12432 .suite_name = "Crypto Device CCP Unit Test Suite",
12433 .setup = testsuite_setup,
12434 .teardown = testsuite_teardown,
12435 .unit_test_cases = {
12436 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_multi_session_random_usage),
12439 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12440 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12441 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12442 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12443 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12445 /** Negative tests */
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12455 TEST_CASES_END() /**< NULL terminate unit test array */
12459 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12460 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12461 .setup = testsuite_setup,
12462 .teardown = testsuite_teardown,
12463 .unit_test_cases = {
12464 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12465 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12466 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12467 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12468 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12470 /** AES GCM Authenticated Encryption */
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_GCM_authenticated_encryption_test_case_1),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_AES_GCM_authenticated_encryption_test_case_2),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_AES_GCM_authenticated_encryption_test_case_3),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_AES_GCM_authenticated_encryption_test_case_4),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_AES_GCM_authenticated_encryption_test_case_5),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_AES_GCM_authenticated_encryption_test_case_6),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_AES_GCM_authenticated_encryption_test_case_7),
12486 /** AES GCM Authenticated Decryption */
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_AES_GCM_authenticated_decryption_test_case_1),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_AES_GCM_authenticated_decryption_test_case_2),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_AES_GCM_authenticated_decryption_test_case_3),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_AES_GCM_authenticated_decryption_test_case_4),
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 test_AES_GCM_authenticated_decryption_test_case_5),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_AES_GCM_authenticated_decryption_test_case_6),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_AES_GCM_authenticated_decryption_test_case_7),
12501 /** AES GMAC Authentication */
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GMAC_authentication_test_case_1),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GMAC_authentication_verify_test_case_1),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GMAC_authentication_test_case_2),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GMAC_authentication_verify_test_case_2),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GMAC_authentication_test_case_3),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GMAC_authentication_verify_test_case_3),
12515 /** SNOW 3G encrypt only (UEA2) */
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_snow3g_encryption_test_case_1),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_snow3g_encryption_test_case_2),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_snow3g_encryption_test_case_3),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_snow3g_encryption_test_case_4),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_snow3g_encryption_test_case_5),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_snow3g_encryption_test_case_1_oop),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_snow3g_decryption_test_case_1_oop),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_snow3g_encryption_test_case_1_oop_sgl),
12534 /** SNOW 3G decrypt only (UEA2) */
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_snow3g_decryption_test_case_1),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_snow3g_decryption_test_case_2),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_snow3g_decryption_test_case_3),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_snow3g_decryption_test_case_4),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_snow3g_decryption_test_case_5),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_snow3g_hash_generate_test_case_1),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_snow3g_hash_generate_test_case_2),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_snow3g_hash_generate_test_case_3),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_snow3g_hash_verify_test_case_1),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_snow3g_hash_verify_test_case_2),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_snow3g_hash_verify_test_case_3),
12559 /** ZUC encrypt only (EEA3) */
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_zuc_encryption_test_case_1),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_zuc_encryption_test_case_2),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_zuc_encryption_test_case_3),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_zuc_encryption_test_case_4),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_zuc_encryption_test_case_5),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_zuc_hash_generate_test_case_1),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_zuc_hash_generate_test_case_2),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_zuc_hash_generate_test_case_3),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_zuc_hash_generate_test_case_4),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_zuc_hash_generate_test_case_5),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_zuc_encryption_test_case_6_sgl),
12583 /** KASUMI encrypt only (UEA1) */
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_kasumi_encryption_test_case_1),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_kasumi_encryption_test_case_2),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_kasumi_encryption_test_case_3),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_kasumi_encryption_test_case_4),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_kasumi_encryption_test_case_5),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_kasumi_encryption_test_case_1_sgl),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_kasumi_encryption_test_case_1_oop_sgl),
12598 /** KASUMI decrypt only (UEA1) */
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_kasumi_decryption_test_case_1),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_kasumi_decryption_test_case_2),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_kasumi_decryption_test_case_3),
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_kasumi_decryption_test_case_4),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_kasumi_decryption_test_case_5),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_kasumi_encryption_test_case_1_oop),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_kasumi_decryption_test_case_1_oop),
12615 /** KASUMI hash only (UIA1) */
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_kasumi_hash_generate_test_case_1),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_kasumi_hash_generate_test_case_2),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_kasumi_hash_generate_test_case_3),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_kasumi_hash_generate_test_case_4),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_kasumi_hash_generate_test_case_5),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_kasumi_hash_generate_test_case_6),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_kasumi_hash_verify_test_case_1),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_kasumi_hash_verify_test_case_2),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_kasumi_hash_verify_test_case_3),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_kasumi_hash_verify_test_case_4),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_kasumi_hash_verify_test_case_5),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_null_cipher_only_operation),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_null_auth_only_operation),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_null_cipher_auth_operation),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_null_auth_cipher_operation),
12649 /** Negative tests */
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 authentication_verify_AES128_GMAC_fail_data_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12662 TEST_CASES_END() /**< NULL terminate unit test array */
12666 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12667 .suite_name = "Crypto NITROX Unit Test Suite",
12668 .setup = testsuite_setup,
12669 .teardown = testsuite_teardown,
12670 .unit_test_cases = {
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_device_configure_invalid_dev_id),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_device_configure_invalid_queue_pair_ids),
12675 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12676 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12678 TEST_CASES_END() /**< NULL terminate unit test array */
12682 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
12683 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
12684 .setup = testsuite_setup,
12685 .teardown = testsuite_teardown,
12686 .unit_test_cases = {
12687 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12688 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12689 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12690 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12691 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12693 /** AES GCM Authenticated Encryption */
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_AES_GCM_authenticated_encryption_test_case_1),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_authenticated_encryption_test_case_2),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_authenticated_encryption_test_case_3),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_authenticated_encryption_test_case_4),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_AES_GCM_authenticated_encryption_test_case_5),
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_authenticated_encryption_test_case_6),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_authenticated_encryption_test_case_7),
12709 /** AES GCM Authenticated Decryption */
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_AES_GCM_authenticated_decryption_test_case_1),
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_AES_GCM_authenticated_decryption_test_case_2),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_authenticated_decryption_test_case_3),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_authenticated_decryption_test_case_4),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_AES_GCM_authenticated_decryption_test_case_5),
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_AES_GCM_authenticated_decryption_test_case_6),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_authenticated_decryption_test_case_7),
12724 /** AES GMAC Authentication */
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GMAC_authentication_test_case_1),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GMAC_authentication_verify_test_case_1),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GMAC_authentication_test_case_2),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GMAC_authentication_verify_test_case_2),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GMAC_authentication_test_case_3),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GMAC_authentication_verify_test_case_3),
12738 /** SNOW 3G encrypt only (UEA2) */
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_snow3g_encryption_test_case_1),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_snow3g_encryption_test_case_2),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_snow3g_encryption_test_case_3),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_snow3g_encryption_test_case_4),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_snow3g_encryption_test_case_5),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_snow3g_encryption_test_case_1_oop),
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_snow3g_decryption_test_case_1_oop),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_snow3g_encryption_test_case_1_oop_sgl),
12757 /** SNOW 3G decrypt only (UEA2) */
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_snow3g_decryption_test_case_1),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_snow3g_decryption_test_case_2),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_snow3g_decryption_test_case_3),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_snow3g_decryption_test_case_4),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_snow3g_decryption_test_case_5),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_snow3g_hash_generate_test_case_1),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_snow3g_hash_generate_test_case_2),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_snow3g_hash_generate_test_case_3),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_snow3g_hash_verify_test_case_1),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_snow3g_hash_verify_test_case_2),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_snow3g_hash_verify_test_case_3),
12782 /** ZUC encrypt only (EEA3) */
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_zuc_encryption_test_case_1),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_zuc_encryption_test_case_2),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_zuc_encryption_test_case_3),
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_zuc_encryption_test_case_4),
12791 TEST_CASE_ST(ut_setup, ut_teardown,
12792 test_zuc_encryption_test_case_5),
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_zuc_hash_generate_test_case_1),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_zuc_hash_generate_test_case_2),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_zuc_hash_generate_test_case_3),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_zuc_hash_generate_test_case_4),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_zuc_hash_generate_test_case_5),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_zuc_encryption_test_case_6_sgl),
12806 /** KASUMI encrypt only (UEA1) */
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_kasumi_encryption_test_case_1),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_kasumi_encryption_test_case_2),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_kasumi_encryption_test_case_3),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_kasumi_encryption_test_case_4),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_kasumi_encryption_test_case_5),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_kasumi_encryption_test_case_1_sgl),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_kasumi_encryption_test_case_1_oop_sgl),
12821 /** KASUMI decrypt only (UEA1) */
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_kasumi_decryption_test_case_1),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_kasumi_decryption_test_case_2),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_kasumi_decryption_test_case_3),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_kasumi_decryption_test_case_4),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_kasumi_decryption_test_case_5),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_kasumi_encryption_test_case_1_oop),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_kasumi_decryption_test_case_1_oop),
12838 /** KASUMI hash only (UIA1) */
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_kasumi_hash_generate_test_case_1),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_kasumi_hash_generate_test_case_2),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_kasumi_hash_generate_test_case_3),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_kasumi_hash_generate_test_case_4),
12847 TEST_CASE_ST(ut_setup, ut_teardown,
12848 test_kasumi_hash_generate_test_case_5),
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_kasumi_hash_generate_test_case_6),
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_kasumi_hash_verify_test_case_1),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_kasumi_hash_verify_test_case_2),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_kasumi_hash_verify_test_case_3),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_kasumi_hash_verify_test_case_4),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_kasumi_hash_verify_test_case_5),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_null_cipher_only_operation),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_null_auth_only_operation),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_null_cipher_auth_operation),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_null_auth_cipher_operation),
12872 /** Negative tests */
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 authentication_verify_AES128_GMAC_fail_data_corrupt),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12885 TEST_CASES_END() /**< NULL terminate unit test array */
12890 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12892 gbl_driver_id = rte_cryptodev_driver_id_get(
12893 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12895 if (gbl_driver_id == -1) {
12896 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12897 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12898 "are enabled in config file to run this testsuite.\n");
12899 return TEST_SKIPPED;
12902 return unit_test_suite_runner(&cryptodev_testsuite);
12906 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12908 gbl_driver_id = rte_cryptodev_driver_id_get(
12909 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12911 if (gbl_driver_id == -1) {
12912 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12913 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12914 "in config file to run this testsuite.\n");
12915 return TEST_FAILED;
12918 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12922 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12924 gbl_driver_id = rte_cryptodev_driver_id_get(
12925 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12927 if (gbl_driver_id == -1) {
12928 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12929 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12930 "in config file to run this testsuite.\n");
12931 return TEST_SKIPPED;
12934 return unit_test_suite_runner(&cryptodev_testsuite);
12938 test_cryptodev_cpu_aesni_mb(void)
12941 enum rte_security_session_action_type at;
12943 gbl_driver_id = rte_cryptodev_driver_id_get(
12944 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12946 if (gbl_driver_id == -1) {
12947 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12948 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12949 "in config file to run this testsuite.\n");
12950 return TEST_SKIPPED;
12953 at = gbl_action_type;
12954 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12955 rc = unit_test_suite_runner(&cryptodev_testsuite);
12956 gbl_action_type = at;
12961 test_cryptodev_openssl(void)
12963 gbl_driver_id = rte_cryptodev_driver_id_get(
12964 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12966 if (gbl_driver_id == -1) {
12967 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12968 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12969 "in config file to run this testsuite.\n");
12970 return TEST_SKIPPED;
12973 return unit_test_suite_runner(&cryptodev_testsuite);
12977 test_cryptodev_aesni_gcm(void)
12979 gbl_driver_id = rte_cryptodev_driver_id_get(
12980 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12982 if (gbl_driver_id == -1) {
12983 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12984 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12985 "in config file to run this testsuite.\n");
12986 return TEST_SKIPPED;
12989 return unit_test_suite_runner(&cryptodev_testsuite);
12993 test_cryptodev_cpu_aesni_gcm(void)
12996 enum rte_security_session_action_type at;
12998 gbl_driver_id = rte_cryptodev_driver_id_get(
12999 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13001 if (gbl_driver_id == -1) {
13002 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13003 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13004 "in config file to run this testsuite.\n");
13005 return TEST_SKIPPED;
13008 at = gbl_action_type;
13009 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13010 rc = unit_test_suite_runner(&cryptodev_testsuite);
13011 gbl_action_type = at;
13016 test_cryptodev_null(void)
13018 gbl_driver_id = rte_cryptodev_driver_id_get(
13019 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13021 if (gbl_driver_id == -1) {
13022 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13023 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13024 "in config file to run this testsuite.\n");
13025 return TEST_SKIPPED;
13028 return unit_test_suite_runner(&cryptodev_testsuite);
13032 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13034 gbl_driver_id = rte_cryptodev_driver_id_get(
13035 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13037 if (gbl_driver_id == -1) {
13038 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13039 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13040 "in config file to run this testsuite.\n");
13041 return TEST_SKIPPED;
13044 return unit_test_suite_runner(&cryptodev_testsuite);
13048 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13050 gbl_driver_id = rte_cryptodev_driver_id_get(
13051 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13053 if (gbl_driver_id == -1) {
13054 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13055 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13056 "in config file to run this testsuite.\n");
13057 return TEST_SKIPPED;
13060 return unit_test_suite_runner(&cryptodev_testsuite);
13064 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13066 gbl_driver_id = rte_cryptodev_driver_id_get(
13067 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13069 if (gbl_driver_id == -1) {
13070 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13071 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13072 "in config file to run this testsuite.\n");
13073 return TEST_SKIPPED;
13076 return unit_test_suite_runner(&cryptodev_testsuite);
13080 test_cryptodev_armv8(void)
13082 gbl_driver_id = rte_cryptodev_driver_id_get(
13083 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13085 if (gbl_driver_id == -1) {
13086 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13087 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13088 "in config file to run this testsuite.\n");
13089 return TEST_SKIPPED;
13092 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13096 test_cryptodev_mrvl(void)
13098 gbl_driver_id = rte_cryptodev_driver_id_get(
13099 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13101 if (gbl_driver_id == -1) {
13102 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13103 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13104 "in config file to run this testsuite.\n");
13105 return TEST_SKIPPED;
13108 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13111 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13114 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13116 gbl_driver_id = rte_cryptodev_driver_id_get(
13117 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13119 if (gbl_driver_id == -1) {
13120 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13121 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13122 "in config file to run this testsuite.\n");
13123 return TEST_SKIPPED;
13126 if (rte_cryptodev_driver_id_get(
13127 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13128 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13129 " enabled in config file to run this testsuite.\n");
13130 return TEST_SKIPPED;
13132 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13135 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13140 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13142 gbl_driver_id = rte_cryptodev_driver_id_get(
13143 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13145 if (gbl_driver_id == -1) {
13146 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13147 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13148 "in config file to run this testsuite.\n");
13149 return TEST_SKIPPED;
13152 return unit_test_suite_runner(&cryptodev_testsuite);
13156 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13158 gbl_driver_id = rte_cryptodev_driver_id_get(
13159 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13161 if (gbl_driver_id == -1) {
13162 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13163 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13164 "in config file to run this testsuite.\n");
13165 return TEST_SKIPPED;
13168 return unit_test_suite_runner(&cryptodev_testsuite);
13172 test_cryptodev_ccp(void)
13174 gbl_driver_id = rte_cryptodev_driver_id_get(
13175 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13177 if (gbl_driver_id == -1) {
13178 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13179 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13180 "in config file to run this testsuite.\n");
13181 return TEST_FAILED;
13184 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13188 test_cryptodev_octeontx(void)
13190 gbl_driver_id = rte_cryptodev_driver_id_get(
13191 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13192 if (gbl_driver_id == -1) {
13193 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13194 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13195 "enabled in config file to run this "
13197 return TEST_FAILED;
13199 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13203 test_cryptodev_octeontx2(void)
13205 gbl_driver_id = rte_cryptodev_driver_id_get(
13206 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13207 if (gbl_driver_id == -1) {
13208 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13209 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13210 "enabled in config file to run this "
13212 return TEST_FAILED;
13214 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13218 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13220 gbl_driver_id = rte_cryptodev_driver_id_get(
13221 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13223 if (gbl_driver_id == -1) {
13224 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13225 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13226 "in config file to run this testsuite.\n");
13227 return TEST_FAILED;
13230 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13234 test_cryptodev_nitrox(void)
13236 gbl_driver_id = rte_cryptodev_driver_id_get(
13237 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13239 if (gbl_driver_id == -1) {
13240 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13241 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13242 "in config file to run this testsuite.\n");
13243 return TEST_FAILED;
13246 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13249 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13250 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13251 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13252 test_cryptodev_cpu_aesni_mb);
13253 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13254 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13255 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13256 test_cryptodev_cpu_aesni_gcm);
13257 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13258 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13259 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13260 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13261 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13262 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13263 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13264 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13265 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13266 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13267 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13268 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13269 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13270 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);