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 /* This test is for QAT and NITROX PMDs only */
771 if (gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
773 gbl_driver_id != rte_cryptodev_driver_id_get(
774 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
777 /* Stop the device in case it's started so it can be configured */
778 rte_cryptodev_stop(ts_params->valid_devs[0]);
780 /* valid - one queue pairs */
781 ts_params->conf.nb_queue_pairs = 1;
783 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
785 "Failed to configure cryptodev: dev_id %u, qp_id %u",
786 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
789 /* valid - max value queue pairs */
790 ts_params->conf.nb_queue_pairs = orig_nb_qps;
792 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
794 "Failed to configure cryptodev: dev_id %u, qp_id %u",
795 ts_params->valid_devs[0],
796 ts_params->conf.nb_queue_pairs);
799 /* invalid - zero queue pairs */
800 ts_params->conf.nb_queue_pairs = 0;
802 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
804 "Failed test for rte_cryptodev_configure, dev_id %u,"
806 ts_params->valid_devs[0],
807 ts_params->conf.nb_queue_pairs);
810 /* invalid - max value supported by field queue pairs */
811 ts_params->conf.nb_queue_pairs = UINT16_MAX;
813 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
815 "Failed test for rte_cryptodev_configure, dev_id %u,"
817 ts_params->valid_devs[0],
818 ts_params->conf.nb_queue_pairs);
821 /* invalid - max value + 1 queue pairs */
822 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
824 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
826 "Failed test for rte_cryptodev_configure, dev_id %u,"
828 ts_params->valid_devs[0],
829 ts_params->conf.nb_queue_pairs);
831 /* revert to original testsuite value */
832 ts_params->conf.nb_queue_pairs = orig_nb_qps;
838 test_queue_pair_descriptor_setup(void)
840 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 struct rte_cryptodev_info dev_info;
842 struct rte_cryptodev_qp_conf qp_conf = {
843 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
848 /* This test is for QAT PMD only */
849 if (gbl_driver_id != rte_cryptodev_driver_id_get(
850 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
853 /* Stop the device in case it's started so it can be configured */
854 rte_cryptodev_stop(ts_params->valid_devs[0]);
857 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
859 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
861 "Failed to configure cryptodev %u",
862 ts_params->valid_devs[0]);
865 * Test various ring sizes on this device. memzones can't be
866 * freed so are re-used if ring is released and re-created.
868 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
869 qp_conf.mp_session = ts_params->session_mpool;
870 qp_conf.mp_session_private = ts_params->session_priv_mpool;
872 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
873 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
874 ts_params->valid_devs[0], qp_id, &qp_conf,
875 rte_cryptodev_socket_id(
876 ts_params->valid_devs[0])),
878 "rte_cryptodev_queue_pair_setup: num_inflights "
879 "%u on qp %u on cryptodev %u",
880 qp_conf.nb_descriptors, qp_id,
881 ts_params->valid_devs[0]);
884 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
886 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
887 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
888 ts_params->valid_devs[0], qp_id, &qp_conf,
889 rte_cryptodev_socket_id(
890 ts_params->valid_devs[0])),
892 " rte_cryptodev_queue_pair_setup: num_inflights"
893 " %u on qp %u on cryptodev %u",
894 qp_conf.nb_descriptors, qp_id,
895 ts_params->valid_devs[0]);
898 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
900 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
901 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
902 ts_params->valid_devs[0], qp_id, &qp_conf,
903 rte_cryptodev_socket_id(
904 ts_params->valid_devs[0])),
906 "rte_cryptodev_queue_pair_setup: num_inflights"
907 " %u on qp %u on cryptodev %u",
908 qp_conf.nb_descriptors, qp_id,
909 ts_params->valid_devs[0]);
912 /* invalid number of descriptors - max supported + 2 */
913 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
915 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
916 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
917 ts_params->valid_devs[0], qp_id, &qp_conf,
918 rte_cryptodev_socket_id(
919 ts_params->valid_devs[0])),
920 "Unexpectedly passed test for "
921 "rte_cryptodev_queue_pair_setup:"
922 "num_inflights %u on qp %u on cryptodev %u",
923 qp_conf.nb_descriptors, qp_id,
924 ts_params->valid_devs[0]);
927 /* invalid number of descriptors - max value of parameter */
928 qp_conf.nb_descriptors = UINT32_MAX-1;
930 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
931 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
932 ts_params->valid_devs[0], qp_id, &qp_conf,
933 rte_cryptodev_socket_id(
934 ts_params->valid_devs[0])),
935 "Unexpectedly passed test for "
936 "rte_cryptodev_queue_pair_setup:"
937 "num_inflights %u on qp %u on cryptodev %u",
938 qp_conf.nb_descriptors, qp_id,
939 ts_params->valid_devs[0]);
942 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
944 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
945 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
946 ts_params->valid_devs[0], qp_id, &qp_conf,
947 rte_cryptodev_socket_id(
948 ts_params->valid_devs[0])),
950 " rte_cryptodev_queue_pair_setup:"
951 "num_inflights %u on qp %u on cryptodev %u",
952 qp_conf.nb_descriptors, qp_id,
953 ts_params->valid_devs[0]);
956 /* invalid number of descriptors - max supported + 1 */
957 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
959 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
960 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
961 ts_params->valid_devs[0], qp_id, &qp_conf,
962 rte_cryptodev_socket_id(
963 ts_params->valid_devs[0])),
964 "Unexpectedly passed test for "
965 "rte_cryptodev_queue_pair_setup:"
966 "num_inflights %u on qp %u on cryptodev %u",
967 qp_conf.nb_descriptors, qp_id,
968 ts_params->valid_devs[0]);
971 /* test invalid queue pair id */
972 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
974 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
976 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
977 ts_params->valid_devs[0],
979 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
980 "Failed test for rte_cryptodev_queue_pair_setup:"
981 "invalid qp %u on cryptodev %u",
982 qp_id, ts_params->valid_devs[0]);
984 qp_id = 0xffff; /*invalid*/
986 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
987 ts_params->valid_devs[0],
989 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
990 "Failed test for rte_cryptodev_queue_pair_setup:"
991 "invalid qp %u on cryptodev %u",
992 qp_id, ts_params->valid_devs[0]);
997 /* ***** Plaintext data for tests ***** */
999 const char catch_22_quote_1[] =
1000 "There was only one catch and that was Catch-22, which "
1001 "specified that a concern for one's safety in the face of "
1002 "dangers that were real and immediate was the process of a "
1003 "rational mind. Orr was crazy and could be grounded. All he "
1004 "had to do was ask; and as soon as he did, he would no longer "
1005 "be crazy and would have to fly more missions. Orr would be "
1006 "crazy to fly more missions and sane if he didn't, but if he "
1007 "was sane he had to fly them. If he flew them he was crazy "
1008 "and didn't have to; but if he didn't want to he was sane and "
1009 "had to. Yossarian was moved very deeply by the absolute "
1010 "simplicity of this clause of Catch-22 and let out a "
1011 "respectful whistle. \"That's some catch, that Catch-22\", he "
1012 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1014 const char catch_22_quote[] =
1015 "What a lousy earth! He wondered how many people were "
1016 "destitute that same night even in his own prosperous country, "
1017 "how many homes were shanties, how many husbands were drunk "
1018 "and wives socked, and how many children were bullied, abused, "
1019 "or abandoned. How many families hungered for food they could "
1020 "not afford to buy? How many hearts were broken? How many "
1021 "suicides would take place that same night, how many people "
1022 "would go insane? How many cockroaches and landlords would "
1023 "triumph? How many winners were losers, successes failures, "
1024 "and rich men poor men? How many wise guys were stupid? How "
1025 "many happy endings were unhappy endings? How many honest men "
1026 "were liars, brave men cowards, loyal men traitors, how many "
1027 "sainted men were corrupt, how many people in positions of "
1028 "trust had sold their souls to bodyguards, how many had never "
1029 "had souls? How many straight-and-narrow paths were crooked "
1030 "paths? How many best families were worst families and how "
1031 "many good people were bad people? When you added them all up "
1032 "and then subtracted, you might be left with only the children, "
1033 "and perhaps with Albert Einstein and an old violinist or "
1034 "sculptor somewhere.";
1036 #define QUOTE_480_BYTES (480)
1037 #define QUOTE_512_BYTES (512)
1038 #define QUOTE_768_BYTES (768)
1039 #define QUOTE_1024_BYTES (1024)
1043 /* ***** SHA1 Hash Tests ***** */
1045 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1047 static uint8_t hmac_sha1_key[] = {
1048 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1049 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1050 0xDE, 0xF4, 0xDE, 0xAD };
1052 /* ***** SHA224 Hash Tests ***** */
1054 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1057 /* ***** AES-CBC Cipher Tests ***** */
1059 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1060 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1062 static uint8_t aes_cbc_key[] = {
1063 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1064 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1066 static uint8_t aes_cbc_iv[] = {
1067 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1068 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1071 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1073 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1074 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1075 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1076 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1077 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1078 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1079 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1080 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1081 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1082 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1083 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1084 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1085 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1086 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1087 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1088 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1089 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1090 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1091 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1092 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1093 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1094 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1095 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1096 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1097 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1098 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1099 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1100 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1101 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1102 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1103 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1104 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1105 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1106 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1107 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1108 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1109 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1110 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1111 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1112 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1113 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1114 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1115 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1116 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1117 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1118 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1119 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1120 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1121 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1122 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1123 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1124 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1125 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1126 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1127 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1128 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1129 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1130 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1131 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1132 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1133 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1134 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1135 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1136 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1137 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1140 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1141 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1142 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1143 0x18, 0x8c, 0x1d, 0x32
1147 /* Multisession Vector context Test */
1148 /*Begin Session 0 */
1149 static uint8_t ms_aes_cbc_key0[] = {
1150 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1151 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1154 static uint8_t ms_aes_cbc_iv0[] = {
1155 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1156 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1159 static const uint8_t ms_aes_cbc_cipher0[] = {
1160 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1161 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1162 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1163 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1164 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1165 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1166 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1167 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1168 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1169 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1170 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1171 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1172 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1173 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1174 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1175 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1176 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1177 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1178 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1179 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1180 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1181 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1182 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1183 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1184 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1185 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1186 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1187 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1188 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1189 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1190 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1191 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1192 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1193 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1194 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1195 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1196 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1197 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1198 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1199 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1200 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1201 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1202 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1203 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1204 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1205 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1206 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1207 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1208 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1209 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1210 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1211 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1212 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1213 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1214 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1215 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1216 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1217 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1218 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1219 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1220 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1221 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1222 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1223 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1227 static uint8_t ms_hmac_key0[] = {
1228 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest0[] = {
1239 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1240 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1241 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1242 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1243 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1244 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1245 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1246 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1250 /* Begin session 1 */
1252 static uint8_t ms_aes_cbc_key1[] = {
1253 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1254 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1257 static uint8_t ms_aes_cbc_iv1[] = {
1258 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1259 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1262 static const uint8_t ms_aes_cbc_cipher1[] = {
1263 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1264 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1265 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1266 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1267 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1268 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1269 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1270 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1271 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1272 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1273 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1274 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1275 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1276 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1277 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1278 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1279 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1280 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1281 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1282 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1283 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1284 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1285 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1286 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1287 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1288 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1289 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1290 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1291 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1292 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1293 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1294 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1295 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1296 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1297 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1298 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1299 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1300 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1301 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1302 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1303 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1304 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1305 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1306 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1307 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1308 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1309 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1310 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1311 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1312 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1313 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1314 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1315 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1316 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1317 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1318 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1319 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1320 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1321 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1322 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1323 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1324 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1325 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1326 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1330 static uint8_t ms_hmac_key1[] = {
1331 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1332 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1333 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1334 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1335 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1336 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1337 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1338 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1341 static const uint8_t ms_hmac_digest1[] = {
1342 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1343 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1344 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1345 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1346 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1347 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1348 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1349 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1352 /* Begin Session 2 */
1353 static uint8_t ms_aes_cbc_key2[] = {
1354 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1355 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1358 static uint8_t ms_aes_cbc_iv2[] = {
1359 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1360 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1363 static const uint8_t ms_aes_cbc_cipher2[] = {
1364 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1365 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1366 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1367 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1368 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1369 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1370 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1371 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1372 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1373 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1374 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1375 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1376 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1377 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1378 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1379 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1380 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1381 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1382 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1383 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1384 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1385 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1386 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1387 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1388 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1389 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1390 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1391 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1392 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1393 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1394 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1395 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1396 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1397 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1398 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1399 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1400 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1401 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1402 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1403 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1404 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1405 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1406 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1407 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1408 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1409 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1410 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1411 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1412 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1413 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1414 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1415 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1416 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1417 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1418 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1419 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1420 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1421 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1422 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1423 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1424 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1425 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1426 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1427 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1430 static uint8_t ms_hmac_key2[] = {
1431 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1432 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1433 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1434 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1435 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1436 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1437 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1438 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1441 static const uint8_t ms_hmac_digest2[] = {
1442 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1443 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1444 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1445 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1446 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1447 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1448 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1449 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1456 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1458 struct crypto_testsuite_params *ts_params = &testsuite_params;
1459 struct crypto_unittest_params *ut_params = &unittest_params;
1461 /* Verify the capabilities */
1462 struct rte_cryptodev_sym_capability_idx cap_idx;
1463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1464 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1469 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1474 /* Generate test mbuf data and space for digest */
1475 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1476 catch_22_quote, QUOTE_512_BYTES, 0);
1478 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1479 DIGEST_BYTE_LENGTH_SHA1);
1480 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1482 /* Setup Cipher Parameters */
1483 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1484 ut_params->cipher_xform.next = &ut_params->auth_xform;
1486 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1487 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1488 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1489 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1490 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1491 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1493 /* Setup HMAC Parameters */
1494 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1496 ut_params->auth_xform.next = NULL;
1498 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1499 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1500 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1501 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1502 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1504 ut_params->sess = rte_cryptodev_sym_session_create(
1505 ts_params->session_mpool);
1507 /* Create crypto session*/
1508 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1509 ut_params->sess, &ut_params->cipher_xform,
1510 ts_params->session_priv_mpool);
1511 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1513 /* Generate crypto op data structure */
1514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1516 TEST_ASSERT_NOT_NULL(ut_params->op,
1517 "Failed to allocate symmetric crypto operation struct");
1519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1523 /* set crypto operation source mbuf */
1524 sym_op->m_src = ut_params->ibuf;
1526 /* Set crypto operation authentication parameters */
1527 sym_op->auth.digest.data = ut_params->digest;
1528 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1529 ut_params->ibuf, QUOTE_512_BYTES);
1531 sym_op->auth.data.offset = 0;
1532 sym_op->auth.data.length = QUOTE_512_BYTES;
1534 /* Copy IV at the end of the crypto operation */
1535 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1536 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1538 /* Set crypto operation cipher parameters */
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1544 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1547 TEST_ASSERT_NOT_NULL(
1548 process_crypto_request(ts_params->valid_devs[0],
1550 "failed to process sym crypto op");
1552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1553 "crypto op processing failed");
1556 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1559 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1560 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1562 "ciphertext data not as expected");
1564 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1566 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1567 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1568 gbl_driver_id == rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1570 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1571 DIGEST_BYTE_LENGTH_SHA1,
1572 "Generated digest data not as expected");
1574 return TEST_SUCCESS;
1577 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1579 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1581 static uint8_t hmac_sha512_key[] = {
1582 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1583 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1584 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1585 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1586 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1587 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1588 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1589 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1591 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1592 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1593 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1594 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1595 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1596 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1597 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1598 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1599 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1604 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1605 struct crypto_unittest_params *ut_params,
1606 uint8_t *cipher_key,
1610 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1611 struct crypto_unittest_params *ut_params,
1612 struct crypto_testsuite_params *ts_params,
1613 const uint8_t *cipher,
1614 const uint8_t *digest,
1619 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1620 struct crypto_unittest_params *ut_params,
1621 uint8_t *cipher_key,
1625 /* Setup Cipher Parameters */
1626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1627 ut_params->cipher_xform.next = NULL;
1629 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1630 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1631 ut_params->cipher_xform.cipher.key.data = cipher_key;
1632 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1633 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1634 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1636 /* Setup HMAC Parameters */
1637 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1638 ut_params->auth_xform.next = &ut_params->cipher_xform;
1640 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1641 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1642 ut_params->auth_xform.auth.key.data = hmac_key;
1643 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1644 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1646 return TEST_SUCCESS;
1651 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1652 struct crypto_unittest_params *ut_params,
1653 struct crypto_testsuite_params *ts_params,
1654 const uint8_t *cipher,
1655 const uint8_t *digest,
1658 /* Generate test mbuf data and digest */
1659 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1662 QUOTE_512_BYTES, 0);
1664 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1665 DIGEST_BYTE_LENGTH_SHA512);
1666 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1668 rte_memcpy(ut_params->digest,
1670 DIGEST_BYTE_LENGTH_SHA512);
1672 /* Generate Crypto op data structure */
1673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1675 TEST_ASSERT_NOT_NULL(ut_params->op,
1676 "Failed to allocate symmetric crypto operation struct");
1678 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1680 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1682 /* set crypto operation source mbuf */
1683 sym_op->m_src = ut_params->ibuf;
1685 sym_op->auth.digest.data = ut_params->digest;
1686 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1687 ut_params->ibuf, QUOTE_512_BYTES);
1689 sym_op->auth.data.offset = 0;
1690 sym_op->auth.data.length = QUOTE_512_BYTES;
1692 /* Copy IV at the end of the crypto operation */
1693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1694 iv, CIPHER_IV_LENGTH_AES_CBC);
1696 sym_op->cipher.data.offset = 0;
1697 sym_op->cipher.data.length = QUOTE_512_BYTES;
1699 /* Process crypto operation */
1700 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1701 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1704 TEST_ASSERT_NOT_NULL(
1705 process_crypto_request(ts_params->valid_devs[0],
1707 "failed to process sym crypto op");
1709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1710 "crypto op processing failed");
1712 ut_params->obuf = ut_params->op->sym->m_src;
1715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1716 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1719 "Plaintext data not as expected");
1722 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1723 "Digest verification failed");
1725 return TEST_SUCCESS;
1729 test_blockcipher(enum blockcipher_test_type test_type)
1731 struct crypto_testsuite_params *ts_params = &testsuite_params;
1734 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1735 ts_params->op_mpool,
1736 ts_params->session_mpool, ts_params->session_priv_mpool,
1737 ts_params->valid_devs[0],
1740 if (status == -ENOTSUP)
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 return TEST_SUCCESS;
1749 test_AES_cipheronly_all(void)
1751 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1755 test_AES_docsis_all(void)
1757 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1761 test_DES_docsis_all(void)
1763 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1767 test_DES_cipheronly_all(void)
1769 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1773 test_authonly_all(void)
1775 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1779 test_AES_chain_all(void)
1781 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1785 test_3DES_chain_all(void)
1787 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1791 test_3DES_cipheronly_all(void)
1793 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1796 /* ***** SNOW 3G Tests ***** */
1798 create_wireless_algo_hash_session(uint8_t dev_id,
1799 const uint8_t *key, const uint8_t key_len,
1800 const uint8_t iv_len, const uint8_t auth_len,
1801 enum rte_crypto_auth_operation op,
1802 enum rte_crypto_auth_algorithm algo)
1804 uint8_t hash_key[key_len];
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 struct crypto_unittest_params *ut_params = &unittest_params;
1810 memcpy(hash_key, key, key_len);
1812 debug_hexdump(stdout, "key:", key, key_len);
1814 /* Setup Authentication Parameters */
1815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1816 ut_params->auth_xform.next = NULL;
1818 ut_params->auth_xform.auth.op = op;
1819 ut_params->auth_xform.auth.algo = algo;
1820 ut_params->auth_xform.auth.key.length = key_len;
1821 ut_params->auth_xform.auth.key.data = hash_key;
1822 ut_params->auth_xform.auth.digest_length = auth_len;
1823 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1824 ut_params->auth_xform.auth.iv.length = iv_len;
1825 ut_params->sess = rte_cryptodev_sym_session_create(
1826 ts_params->session_mpool);
1828 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1829 &ut_params->auth_xform,
1830 ts_params->session_priv_mpool);
1831 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1837 create_wireless_algo_cipher_session(uint8_t dev_id,
1838 enum rte_crypto_cipher_operation op,
1839 enum rte_crypto_cipher_algorithm algo,
1840 const uint8_t *key, const uint8_t key_len,
1843 uint8_t cipher_key[key_len];
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 memcpy(cipher_key, key, key_len);
1850 /* Setup Cipher Parameters */
1851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1852 ut_params->cipher_xform.next = NULL;
1854 ut_params->cipher_xform.cipher.algo = algo;
1855 ut_params->cipher_xform.cipher.op = op;
1856 ut_params->cipher_xform.cipher.key.data = cipher_key;
1857 ut_params->cipher_xform.cipher.key.length = key_len;
1858 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1859 ut_params->cipher_xform.cipher.iv.length = iv_len;
1861 debug_hexdump(stdout, "key:", key, key_len);
1863 /* Create Crypto session */
1864 ut_params->sess = rte_cryptodev_sym_session_create(
1865 ts_params->session_mpool);
1867 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1868 &ut_params->cipher_xform,
1869 ts_params->session_priv_mpool);
1870 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1871 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1876 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1877 unsigned int cipher_len,
1878 unsigned int cipher_offset)
1880 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 struct crypto_unittest_params *ut_params = &unittest_params;
1883 /* Generate Crypto op data structure */
1884 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1885 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1886 TEST_ASSERT_NOT_NULL(ut_params->op,
1887 "Failed to allocate pktmbuf offload");
1889 /* Set crypto operation data parameters */
1890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1892 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1894 /* set crypto operation source mbuf */
1895 sym_op->m_src = ut_params->ibuf;
1898 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1900 sym_op->cipher.data.length = cipher_len;
1901 sym_op->cipher.data.offset = cipher_offset;
1906 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1907 unsigned int cipher_len,
1908 unsigned int cipher_offset)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1911 struct crypto_unittest_params *ut_params = &unittest_params;
1913 /* Generate Crypto op data structure */
1914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1916 TEST_ASSERT_NOT_NULL(ut_params->op,
1917 "Failed to allocate pktmbuf offload");
1919 /* Set crypto operation data parameters */
1920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1922 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1924 /* set crypto operation source mbuf */
1925 sym_op->m_src = ut_params->ibuf;
1926 sym_op->m_dst = ut_params->obuf;
1929 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1931 sym_op->cipher.data.length = cipher_len;
1932 sym_op->cipher.data.offset = cipher_offset;
1937 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1938 enum rte_crypto_cipher_operation cipher_op,
1939 enum rte_crypto_auth_operation auth_op,
1940 enum rte_crypto_auth_algorithm auth_algo,
1941 enum rte_crypto_cipher_algorithm cipher_algo,
1942 const uint8_t *key, uint8_t key_len,
1943 uint8_t auth_iv_len, uint8_t auth_len,
1944 uint8_t cipher_iv_len)
1947 uint8_t cipher_auth_key[key_len];
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 struct crypto_unittest_params *ut_params = &unittest_params;
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;
1980 debug_hexdump(stdout, "key:", key, key_len);
1982 /* Create Crypto session*/
1983 ut_params->sess = rte_cryptodev_sym_session_create(
1984 ts_params->session_mpool);
1985 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
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");
1998 create_wireless_cipher_auth_session(uint8_t dev_id,
1999 enum rte_crypto_cipher_operation cipher_op,
2000 enum rte_crypto_auth_operation auth_op,
2001 enum rte_crypto_auth_algorithm auth_algo,
2002 enum rte_crypto_cipher_algorithm cipher_algo,
2003 const struct wireless_test_data *tdata)
2005 const uint8_t key_len = tdata->key.len;
2006 uint8_t cipher_auth_key[key_len];
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 struct crypto_unittest_params *ut_params = &unittest_params;
2011 const uint8_t *key = tdata->key.data;
2012 const uint8_t auth_len = tdata->digest.len;
2013 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2014 uint8_t auth_iv_len = tdata->auth_iv.len;
2016 memcpy(cipher_auth_key, key, key_len);
2018 /* Setup Authentication Parameters */
2019 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2020 ut_params->auth_xform.next = NULL;
2022 ut_params->auth_xform.auth.op = auth_op;
2023 ut_params->auth_xform.auth.algo = auth_algo;
2024 ut_params->auth_xform.auth.key.length = key_len;
2025 /* Hash key = cipher key */
2026 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 /* Auth IV will be after cipher IV */
2029 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2030 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2032 /* Setup Cipher Parameters */
2033 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2034 ut_params->cipher_xform.next = &ut_params->auth_xform;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2041 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2044 debug_hexdump(stdout, "key:", key, key_len);
2046 /* Create Crypto session*/
2047 ut_params->sess = rte_cryptodev_sym_session_create(
2048 ts_params->session_mpool);
2050 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2051 &ut_params->cipher_xform,
2052 ts_params->session_priv_mpool);
2054 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2060 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2061 const struct wireless_test_data *tdata)
2063 return create_wireless_cipher_auth_session(dev_id,
2064 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2065 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2066 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2070 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2071 enum rte_crypto_cipher_operation cipher_op,
2072 enum rte_crypto_auth_operation auth_op,
2073 enum rte_crypto_auth_algorithm auth_algo,
2074 enum rte_crypto_cipher_algorithm cipher_algo,
2075 const uint8_t *key, const uint8_t key_len,
2076 uint8_t auth_iv_len, uint8_t auth_len,
2077 uint8_t cipher_iv_len)
2079 uint8_t auth_cipher_key[key_len];
2081 struct crypto_testsuite_params *ts_params = &testsuite_params;
2082 struct crypto_unittest_params *ut_params = &unittest_params;
2084 memcpy(auth_cipher_key, key, key_len);
2086 /* Setup Authentication Parameters */
2087 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2088 ut_params->auth_xform.auth.op = auth_op;
2089 ut_params->auth_xform.next = &ut_params->cipher_xform;
2090 ut_params->auth_xform.auth.algo = auth_algo;
2091 ut_params->auth_xform.auth.key.length = key_len;
2092 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2093 ut_params->auth_xform.auth.digest_length = auth_len;
2094 /* Auth IV will be after cipher IV */
2095 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2096 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2098 /* Setup Cipher Parameters */
2099 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2100 ut_params->cipher_xform.next = NULL;
2101 ut_params->cipher_xform.cipher.algo = cipher_algo;
2102 ut_params->cipher_xform.cipher.op = cipher_op;
2103 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2104 ut_params->cipher_xform.cipher.key.length = key_len;
2105 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2106 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2108 debug_hexdump(stdout, "key:", key, key_len);
2110 /* Create Crypto session*/
2111 ut_params->sess = rte_cryptodev_sym_session_create(
2112 ts_params->session_mpool);
2113 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2115 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2116 ut_params->auth_xform.next = NULL;
2117 ut_params->cipher_xform.next = &ut_params->auth_xform;
2118 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2119 &ut_params->cipher_xform,
2120 ts_params->session_priv_mpool);
2123 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2124 &ut_params->auth_xform,
2125 ts_params->session_priv_mpool);
2127 if (status == -ENOTSUP)
2130 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2136 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2137 unsigned int auth_tag_len,
2138 const uint8_t *iv, unsigned int iv_len,
2139 unsigned int data_pad_len,
2140 enum rte_crypto_auth_operation op,
2141 unsigned int auth_len, unsigned int auth_offset)
2143 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 struct crypto_unittest_params *ut_params = &unittest_params;
2147 /* Generate Crypto op data structure */
2148 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2149 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2150 TEST_ASSERT_NOT_NULL(ut_params->op,
2151 "Failed to allocate pktmbuf offload");
2153 /* Set crypto operation data parameters */
2154 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2156 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2158 /* set crypto operation source mbuf */
2159 sym_op->m_src = ut_params->ibuf;
2162 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2165 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2166 ut_params->ibuf, auth_tag_len);
2168 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2169 "no room to append auth tag");
2170 ut_params->digest = sym_op->auth.digest.data;
2171 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2172 ut_params->ibuf, data_pad_len);
2173 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2174 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2176 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2178 debug_hexdump(stdout, "digest:",
2179 sym_op->auth.digest.data,
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = auth_offset;
2189 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2190 enum rte_crypto_auth_operation op)
2192 struct crypto_testsuite_params *ts_params = &testsuite_params;
2193 struct crypto_unittest_params *ut_params = &unittest_params;
2195 const uint8_t *auth_tag = tdata->digest.data;
2196 const unsigned int auth_tag_len = tdata->digest.len;
2197 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2198 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2200 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2201 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2202 const uint8_t *auth_iv = tdata->auth_iv.data;
2203 const uint8_t auth_iv_len = tdata->auth_iv.len;
2204 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2205 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2207 /* Generate Crypto op data structure */
2208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2210 TEST_ASSERT_NOT_NULL(ut_params->op,
2211 "Failed to allocate pktmbuf offload");
2212 /* Set crypto operation data parameters */
2213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2215 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2217 /* set crypto operation source mbuf */
2218 sym_op->m_src = ut_params->ibuf;
2221 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2222 ut_params->ibuf, auth_tag_len);
2224 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2225 "no room to append auth tag");
2226 ut_params->digest = sym_op->auth.digest.data;
2227 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2228 ut_params->ibuf, data_pad_len);
2229 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2230 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2232 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2234 debug_hexdump(stdout, "digest:",
2235 sym_op->auth.digest.data,
2238 /* Copy cipher and auth IVs at the end of the crypto operation */
2239 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2241 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2242 iv_ptr += cipher_iv_len;
2243 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2245 sym_op->cipher.data.length = cipher_len;
2246 sym_op->cipher.data.offset = 0;
2247 sym_op->auth.data.length = auth_len;
2248 sym_op->auth.data.offset = 0;
2254 create_zuc_cipher_hash_generate_operation(
2255 const struct wireless_test_data *tdata)
2257 return create_wireless_cipher_hash_operation(tdata,
2258 RTE_CRYPTO_AUTH_OP_GENERATE);
2262 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2263 const unsigned auth_tag_len,
2264 const uint8_t *auth_iv, uint8_t auth_iv_len,
2265 unsigned data_pad_len,
2266 enum rte_crypto_auth_operation op,
2267 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2268 const unsigned cipher_len, const unsigned cipher_offset,
2269 const unsigned auth_len, const unsigned auth_offset)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2272 struct crypto_unittest_params *ut_params = &unittest_params;
2274 enum rte_crypto_cipher_algorithm cipher_algo =
2275 ut_params->cipher_xform.cipher.algo;
2276 enum rte_crypto_auth_algorithm auth_algo =
2277 ut_params->auth_xform.auth.algo;
2279 /* Generate Crypto op data structure */
2280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2282 TEST_ASSERT_NOT_NULL(ut_params->op,
2283 "Failed to allocate pktmbuf offload");
2284 /* Set crypto operation data parameters */
2285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2287 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2289 /* set crypto operation source mbuf */
2290 sym_op->m_src = ut_params->ibuf;
2293 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2294 ut_params->ibuf, auth_tag_len);
2296 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2297 "no room to append auth tag");
2298 ut_params->digest = sym_op->auth.digest.data;
2300 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2301 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2302 ut_params->ibuf, data_pad_len);
2304 struct rte_mbuf *m = ut_params->ibuf;
2305 unsigned int offset = data_pad_len;
2307 while (offset > m->data_len && m->next != NULL) {
2308 offset -= m->data_len;
2311 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2315 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2316 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2318 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2320 debug_hexdump(stdout, "digest:",
2321 sym_op->auth.digest.data,
2324 /* Copy cipher and auth IVs at the end of the crypto operation */
2325 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2327 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2328 iv_ptr += cipher_iv_len;
2329 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2331 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2332 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2333 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2334 sym_op->cipher.data.length = cipher_len;
2335 sym_op->cipher.data.offset = cipher_offset;
2337 sym_op->cipher.data.length = cipher_len >> 3;
2338 sym_op->cipher.data.offset = cipher_offset >> 3;
2341 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2342 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2343 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2344 sym_op->auth.data.length = auth_len;
2345 sym_op->auth.data.offset = auth_offset;
2347 sym_op->auth.data.length = auth_len >> 3;
2348 sym_op->auth.data.offset = auth_offset >> 3;
2355 create_wireless_algo_auth_cipher_operation(
2356 const uint8_t *auth_tag, unsigned int auth_tag_len,
2357 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2358 const uint8_t *auth_iv, uint8_t auth_iv_len,
2359 unsigned int data_pad_len,
2360 unsigned int cipher_len, unsigned int cipher_offset,
2361 unsigned int auth_len, unsigned int auth_offset,
2362 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2364 struct crypto_testsuite_params *ts_params = &testsuite_params;
2365 struct crypto_unittest_params *ut_params = &unittest_params;
2367 enum rte_crypto_cipher_algorithm cipher_algo =
2368 ut_params->cipher_xform.cipher.algo;
2369 enum rte_crypto_auth_algorithm auth_algo =
2370 ut_params->auth_xform.auth.algo;
2372 /* Generate Crypto op data structure */
2373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2375 TEST_ASSERT_NOT_NULL(ut_params->op,
2376 "Failed to allocate pktmbuf offload");
2378 /* Set crypto operation data parameters */
2379 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2381 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2383 /* set crypto operation mbufs */
2384 sym_op->m_src = ut_params->ibuf;
2385 if (op_mode == OUT_OF_PLACE)
2386 sym_op->m_dst = ut_params->obuf;
2390 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2391 (op_mode == IN_PLACE ?
2392 ut_params->ibuf : ut_params->obuf),
2393 uint8_t *, data_pad_len);
2394 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2395 (op_mode == IN_PLACE ?
2396 ut_params->ibuf : ut_params->obuf),
2398 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2400 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2401 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2402 sym_op->m_src : sym_op->m_dst);
2403 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2404 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2405 sgl_buf = sgl_buf->next;
2407 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2408 uint8_t *, remaining_off);
2409 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2411 memset(sym_op->auth.digest.data, 0, remaining_off);
2412 while (sgl_buf->next != NULL) {
2413 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2414 0, rte_pktmbuf_data_len(sgl_buf));
2415 sgl_buf = sgl_buf->next;
2419 /* Copy digest for the verification */
2421 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2423 /* Copy cipher and auth IVs at the end of the crypto operation */
2424 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2425 ut_params->op, uint8_t *, IV_OFFSET);
2427 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2428 iv_ptr += cipher_iv_len;
2429 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2431 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2432 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2433 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2434 sym_op->cipher.data.length = cipher_len;
2435 sym_op->cipher.data.offset = cipher_offset;
2437 sym_op->cipher.data.length = cipher_len >> 3;
2438 sym_op->cipher.data.offset = cipher_offset >> 3;
2441 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2442 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2443 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2444 sym_op->auth.data.length = auth_len;
2445 sym_op->auth.data.offset = auth_offset;
2447 sym_op->auth.data.length = auth_len >> 3;
2448 sym_op->auth.data.offset = auth_offset >> 3;
2455 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2461 unsigned plaintext_pad_len;
2462 unsigned plaintext_len;
2464 struct rte_cryptodev_info dev_info;
2466 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2467 uint64_t feat_flags = dev_info.feature_flags;
2469 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2470 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2471 printf("Device doesn't support NON-Byte Aligned Data.\n");
2475 /* Verify the capabilities */
2476 struct rte_cryptodev_sym_capability_idx cap_idx;
2477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2478 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2483 /* Create SNOW 3G session */
2484 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2485 tdata->key.data, tdata->key.len,
2486 tdata->auth_iv.len, tdata->digest.len,
2487 RTE_CRYPTO_AUTH_OP_GENERATE,
2488 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2492 /* alloc mbuf and set payload */
2493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2495 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2496 rte_pktmbuf_tailroom(ut_params->ibuf));
2498 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2499 /* Append data which is padded to a multiple of */
2500 /* the algorithms block size */
2501 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2502 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2504 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2506 /* Create SNOW 3G operation */
2507 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2508 tdata->auth_iv.data, tdata->auth_iv.len,
2509 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2510 tdata->validAuthLenInBits.len,
2515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2517 ut_params->obuf = ut_params->op->sym->m_src;
2518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2519 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2520 + plaintext_pad_len;
2523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2526 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2527 "SNOW 3G Generated auth tag not as expected");
2533 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2535 struct crypto_testsuite_params *ts_params = &testsuite_params;
2536 struct crypto_unittest_params *ut_params = &unittest_params;
2539 unsigned plaintext_pad_len;
2540 unsigned plaintext_len;
2542 struct rte_cryptodev_info dev_info;
2544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2545 uint64_t feat_flags = dev_info.feature_flags;
2547 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2548 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2549 printf("Device doesn't support NON-Byte Aligned Data.\n");
2553 /* Verify the capabilities */
2554 struct rte_cryptodev_sym_capability_idx cap_idx;
2555 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2556 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2557 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2561 /* Create SNOW 3G session */
2562 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2563 tdata->key.data, tdata->key.len,
2564 tdata->auth_iv.len, tdata->digest.len,
2565 RTE_CRYPTO_AUTH_OP_VERIFY,
2566 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2569 /* alloc mbuf and set payload */
2570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2572 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2573 rte_pktmbuf_tailroom(ut_params->ibuf));
2575 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2576 /* Append data which is padded to a multiple of */
2577 /* the algorithms block size */
2578 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2579 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2581 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2583 /* Create SNOW 3G operation */
2584 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2586 tdata->auth_iv.data, tdata->auth_iv.len,
2588 RTE_CRYPTO_AUTH_OP_VERIFY,
2589 tdata->validAuthLenInBits.len,
2594 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2596 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2597 ut_params->obuf = ut_params->op->sym->m_src;
2598 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2599 + plaintext_pad_len;
2602 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2611 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2613 struct crypto_testsuite_params *ts_params = &testsuite_params;
2614 struct crypto_unittest_params *ut_params = &unittest_params;
2617 unsigned plaintext_pad_len;
2618 unsigned plaintext_len;
2621 /* Verify the capabilities */
2622 struct rte_cryptodev_sym_capability_idx cap_idx;
2623 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2624 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2625 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2629 /* Create KASUMI session */
2630 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2631 tdata->key.data, tdata->key.len,
2632 0, tdata->digest.len,
2633 RTE_CRYPTO_AUTH_OP_GENERATE,
2634 RTE_CRYPTO_AUTH_KASUMI_F9);
2638 /* alloc mbuf and set payload */
2639 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2641 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2642 rte_pktmbuf_tailroom(ut_params->ibuf));
2644 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2645 /* Append data which is padded to a multiple of */
2646 /* the algorithms block size */
2647 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2648 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2650 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2652 /* Create KASUMI operation */
2653 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2655 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2656 tdata->plaintext.len,
2661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2662 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2668 ut_params->obuf = ut_params->op->sym->m_src;
2669 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2670 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2671 + plaintext_pad_len;
2674 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2677 DIGEST_BYTE_LENGTH_KASUMI_F9,
2678 "KASUMI Generated auth tag not as expected");
2684 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2686 struct crypto_testsuite_params *ts_params = &testsuite_params;
2687 struct crypto_unittest_params *ut_params = &unittest_params;
2690 unsigned plaintext_pad_len;
2691 unsigned plaintext_len;
2694 /* Verify the capabilities */
2695 struct rte_cryptodev_sym_capability_idx cap_idx;
2696 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2698 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2702 /* Create KASUMI session */
2703 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2704 tdata->key.data, tdata->key.len,
2705 0, tdata->digest.len,
2706 RTE_CRYPTO_AUTH_OP_VERIFY,
2707 RTE_CRYPTO_AUTH_KASUMI_F9);
2710 /* alloc mbuf and set payload */
2711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2714 rte_pktmbuf_tailroom(ut_params->ibuf));
2716 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2717 /* Append data which is padded to a multiple */
2718 /* of the algorithms block size */
2719 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2720 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2724 /* Create KASUMI operation */
2725 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2729 RTE_CRYPTO_AUTH_OP_VERIFY,
2730 tdata->plaintext.len,
2735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2738 ut_params->obuf = ut_params->op->sym->m_src;
2739 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2740 + plaintext_pad_len;
2743 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2752 test_snow3g_hash_generate_test_case_1(void)
2754 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2758 test_snow3g_hash_generate_test_case_2(void)
2760 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2764 test_snow3g_hash_generate_test_case_3(void)
2766 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2770 test_snow3g_hash_generate_test_case_4(void)
2772 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2776 test_snow3g_hash_generate_test_case_5(void)
2778 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2782 test_snow3g_hash_generate_test_case_6(void)
2784 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2788 test_snow3g_hash_verify_test_case_1(void)
2790 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2795 test_snow3g_hash_verify_test_case_2(void)
2797 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2801 test_snow3g_hash_verify_test_case_3(void)
2803 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2807 test_snow3g_hash_verify_test_case_4(void)
2809 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2813 test_snow3g_hash_verify_test_case_5(void)
2815 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2819 test_snow3g_hash_verify_test_case_6(void)
2821 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2825 test_kasumi_hash_generate_test_case_1(void)
2827 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2831 test_kasumi_hash_generate_test_case_2(void)
2833 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2837 test_kasumi_hash_generate_test_case_3(void)
2839 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2843 test_kasumi_hash_generate_test_case_4(void)
2845 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2849 test_kasumi_hash_generate_test_case_5(void)
2851 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2855 test_kasumi_hash_generate_test_case_6(void)
2857 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2861 test_kasumi_hash_verify_test_case_1(void)
2863 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2867 test_kasumi_hash_verify_test_case_2(void)
2869 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2873 test_kasumi_hash_verify_test_case_3(void)
2875 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2879 test_kasumi_hash_verify_test_case_4(void)
2881 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2885 test_kasumi_hash_verify_test_case_5(void)
2887 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2891 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2893 struct crypto_testsuite_params *ts_params = &testsuite_params;
2894 struct crypto_unittest_params *ut_params = &unittest_params;
2897 uint8_t *plaintext, *ciphertext;
2898 unsigned plaintext_pad_len;
2899 unsigned plaintext_len;
2901 /* Verify the capabilities */
2902 struct rte_cryptodev_sym_capability_idx cap_idx;
2903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2909 /* Create KASUMI session */
2910 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2911 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2912 RTE_CRYPTO_CIPHER_KASUMI_F8,
2913 tdata->key.data, tdata->key.len,
2914 tdata->cipher_iv.len);
2918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2920 /* Clear mbuf payload */
2921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2922 rte_pktmbuf_tailroom(ut_params->ibuf));
2924 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2925 /* Append data which is padded to a multiple */
2926 /* of the algorithms block size */
2927 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2928 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2930 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2932 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2934 /* Create KASUMI operation */
2935 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2936 tdata->cipher_iv.len,
2937 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2938 tdata->validCipherOffsetInBits.len);
2942 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2944 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2946 ut_params->obuf = ut_params->op->sym->m_dst;
2947 if (ut_params->obuf)
2948 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2950 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2952 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2954 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2955 (tdata->validCipherOffsetInBits.len >> 3);
2957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2959 reference_ciphertext,
2960 tdata->validCipherLenInBits.len,
2961 "KASUMI Ciphertext data not as expected");
2966 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2968 struct crypto_testsuite_params *ts_params = &testsuite_params;
2969 struct crypto_unittest_params *ut_params = &unittest_params;
2973 unsigned int plaintext_pad_len;
2974 unsigned int plaintext_len;
2976 uint8_t buffer[10000];
2977 const uint8_t *ciphertext;
2979 struct rte_cryptodev_info dev_info;
2981 /* Verify the capabilities */
2982 struct rte_cryptodev_sym_capability_idx cap_idx;
2983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2984 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2985 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2989 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2991 uint64_t feat_flags = dev_info.feature_flags;
2993 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2994 printf("Device doesn't support in-place scatter-gather. "
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3002 RTE_CRYPTO_CIPHER_KASUMI_F8,
3003 tdata->key.data, tdata->key.len,
3004 tdata->cipher_iv.len);
3008 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3011 /* Append data which is padded to a multiple */
3012 /* of the algorithms block size */
3013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3015 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3016 plaintext_pad_len, 10, 0);
3018 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3020 /* Create KASUMI operation */
3021 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3022 tdata->cipher_iv.len,
3023 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3024 tdata->validCipherOffsetInBits.len);
3028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3032 ut_params->obuf = ut_params->op->sym->m_dst;
3034 if (ut_params->obuf)
3035 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3036 plaintext_len, buffer);
3038 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3039 tdata->validCipherOffsetInBits.len >> 3,
3040 plaintext_len, buffer);
3043 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3045 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3046 (tdata->validCipherOffsetInBits.len >> 3);
3048 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3050 reference_ciphertext,
3051 tdata->validCipherLenInBits.len,
3052 "KASUMI Ciphertext data not as expected");
3057 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3059 struct crypto_testsuite_params *ts_params = &testsuite_params;
3060 struct crypto_unittest_params *ut_params = &unittest_params;
3063 uint8_t *plaintext, *ciphertext;
3064 unsigned plaintext_pad_len;
3065 unsigned plaintext_len;
3067 /* Verify the capabilities */
3068 struct rte_cryptodev_sym_capability_idx cap_idx;
3069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3070 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3071 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3075 /* Create KASUMI session */
3076 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3077 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3078 RTE_CRYPTO_CIPHER_KASUMI_F8,
3079 tdata->key.data, tdata->key.len,
3080 tdata->cipher_iv.len);
3084 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3085 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3087 /* Clear mbuf payload */
3088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3089 rte_pktmbuf_tailroom(ut_params->ibuf));
3091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3092 /* Append data which is padded to a multiple */
3093 /* of the algorithms block size */
3094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3097 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3098 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3100 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3102 /* Create KASUMI operation */
3103 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3104 tdata->cipher_iv.len,
3105 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3106 tdata->validCipherOffsetInBits.len);
3110 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3112 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3114 ut_params->obuf = ut_params->op->sym->m_dst;
3115 if (ut_params->obuf)
3116 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3118 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3120 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3122 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3123 (tdata->validCipherOffsetInBits.len >> 3);
3125 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3127 reference_ciphertext,
3128 tdata->validCipherLenInBits.len,
3129 "KASUMI Ciphertext data not as expected");
3134 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3136 struct crypto_testsuite_params *ts_params = &testsuite_params;
3137 struct crypto_unittest_params *ut_params = &unittest_params;
3140 unsigned int plaintext_pad_len;
3141 unsigned int plaintext_len;
3143 const uint8_t *ciphertext;
3144 uint8_t buffer[2048];
3146 struct rte_cryptodev_info dev_info;
3148 /* Verify the capabilities */
3149 struct rte_cryptodev_sym_capability_idx cap_idx;
3150 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3151 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3152 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3156 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3158 uint64_t feat_flags = dev_info.feature_flags;
3159 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3160 printf("Device doesn't support out-of-place scatter-gather "
3161 "in both input and output mbufs. "
3166 /* Create KASUMI session */
3167 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3168 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3169 RTE_CRYPTO_CIPHER_KASUMI_F8,
3170 tdata->key.data, tdata->key.len,
3171 tdata->cipher_iv.len);
3175 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3176 /* Append data which is padded to a multiple */
3177 /* of the algorithms block size */
3178 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3180 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3181 plaintext_pad_len, 10, 0);
3182 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3183 plaintext_pad_len, 3, 0);
3185 /* Append data which is padded to a multiple */
3186 /* of the algorithms block size */
3187 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3189 /* Create KASUMI operation */
3190 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3191 tdata->cipher_iv.len,
3192 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3193 tdata->validCipherOffsetInBits.len);
3197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3199 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3201 ut_params->obuf = ut_params->op->sym->m_dst;
3202 if (ut_params->obuf)
3203 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3204 plaintext_pad_len, buffer);
3206 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3207 tdata->validCipherOffsetInBits.len >> 3,
3208 plaintext_pad_len, buffer);
3210 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3211 (tdata->validCipherOffsetInBits.len >> 3);
3213 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3215 reference_ciphertext,
3216 tdata->validCipherLenInBits.len,
3217 "KASUMI Ciphertext data not as expected");
3223 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3225 struct crypto_testsuite_params *ts_params = &testsuite_params;
3226 struct crypto_unittest_params *ut_params = &unittest_params;
3229 uint8_t *ciphertext, *plaintext;
3230 unsigned ciphertext_pad_len;
3231 unsigned ciphertext_len;
3233 /* Verify the capabilities */
3234 struct rte_cryptodev_sym_capability_idx cap_idx;
3235 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3236 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3241 /* Create KASUMI session */
3242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3243 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3244 RTE_CRYPTO_CIPHER_KASUMI_F8,
3245 tdata->key.data, tdata->key.len,
3246 tdata->cipher_iv.len);
3250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3253 /* Clear mbuf payload */
3254 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3255 rte_pktmbuf_tailroom(ut_params->ibuf));
3257 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3258 /* Append data which is padded to a multiple */
3259 /* of the algorithms block size */
3260 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3261 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3262 ciphertext_pad_len);
3263 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3264 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3266 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3268 /* Create KASUMI operation */
3269 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3270 tdata->cipher_iv.len,
3271 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3272 tdata->validCipherOffsetInBits.len);
3276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_dst;
3281 if (ut_params->obuf)
3282 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3284 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3286 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3288 const uint8_t *reference_plaintext = tdata->plaintext.data +
3289 (tdata->validCipherOffsetInBits.len >> 3);
3291 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3293 reference_plaintext,
3294 tdata->validCipherLenInBits.len,
3295 "KASUMI Plaintext data not as expected");
3300 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3302 struct crypto_testsuite_params *ts_params = &testsuite_params;
3303 struct crypto_unittest_params *ut_params = &unittest_params;
3306 uint8_t *ciphertext, *plaintext;
3307 unsigned ciphertext_pad_len;
3308 unsigned ciphertext_len;
3310 /* Verify the capabilities */
3311 struct rte_cryptodev_sym_capability_idx cap_idx;
3312 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3313 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3314 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3318 /* Create KASUMI session */
3319 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3320 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3321 RTE_CRYPTO_CIPHER_KASUMI_F8,
3322 tdata->key.data, tdata->key.len,
3323 tdata->cipher_iv.len);
3327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3329 /* Clear mbuf payload */
3330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3331 rte_pktmbuf_tailroom(ut_params->ibuf));
3333 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3334 /* Append data which is padded to a multiple */
3335 /* of the algorithms block size */
3336 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3337 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3338 ciphertext_pad_len);
3339 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3341 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3343 /* Create KASUMI operation */
3344 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3345 tdata->cipher_iv.len,
3346 tdata->ciphertext.len,
3347 tdata->validCipherOffsetInBits.len);
3351 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3353 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3355 ut_params->obuf = ut_params->op->sym->m_dst;
3356 if (ut_params->obuf)
3357 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3359 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3361 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3363 const uint8_t *reference_plaintext = tdata->plaintext.data +
3364 (tdata->validCipherOffsetInBits.len >> 3);
3366 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3368 reference_plaintext,
3369 tdata->validCipherLenInBits.len,
3370 "KASUMI Plaintext data not as expected");
3375 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3377 struct crypto_testsuite_params *ts_params = &testsuite_params;
3378 struct crypto_unittest_params *ut_params = &unittest_params;
3381 uint8_t *plaintext, *ciphertext;
3382 unsigned plaintext_pad_len;
3383 unsigned plaintext_len;
3385 /* Verify the capabilities */
3386 struct rte_cryptodev_sym_capability_idx cap_idx;
3387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3393 /* Create SNOW 3G session */
3394 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3395 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3396 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3397 tdata->key.data, tdata->key.len,
3398 tdata->cipher_iv.len);
3402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3404 /* Clear mbuf payload */
3405 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3406 rte_pktmbuf_tailroom(ut_params->ibuf));
3408 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3409 /* Append data which is padded to a multiple of */
3410 /* the algorithms block size */
3411 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3412 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3414 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3416 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3418 /* Create SNOW 3G operation */
3419 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3420 tdata->cipher_iv.len,
3421 tdata->validCipherLenInBits.len,
3426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3430 ut_params->obuf = ut_params->op->sym->m_dst;
3431 if (ut_params->obuf)
3432 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3434 ciphertext = plaintext;
3436 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3439 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3441 tdata->ciphertext.data,
3442 tdata->validDataLenInBits.len,
3443 "SNOW 3G Ciphertext data not as expected");
3449 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3453 uint8_t *plaintext, *ciphertext;
3456 unsigned plaintext_pad_len;
3457 unsigned plaintext_len;
3459 /* Verify the capabilities */
3460 struct rte_cryptodev_sym_capability_idx cap_idx;
3461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3462 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3467 /* Create SNOW 3G session */
3468 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3470 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3471 tdata->key.data, tdata->key.len,
3472 tdata->cipher_iv.len);
3476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3480 "Failed to allocate input buffer in mempool");
3481 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3482 "Failed to allocate output buffer in mempool");
3484 /* Clear mbuf payload */
3485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3486 rte_pktmbuf_tailroom(ut_params->ibuf));
3488 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3489 /* Append data which is padded to a multiple of */
3490 /* the algorithms block size */
3491 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3492 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3494 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3497 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3499 /* Create SNOW 3G operation */
3500 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3501 tdata->cipher_iv.len,
3502 tdata->validCipherLenInBits.len,
3507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 ut_params->obuf = ut_params->op->sym->m_dst;
3512 if (ut_params->obuf)
3513 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3515 ciphertext = plaintext;
3517 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3520 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3522 tdata->ciphertext.data,
3523 tdata->validDataLenInBits.len,
3524 "SNOW 3G Ciphertext data not as expected");
3529 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3531 struct crypto_testsuite_params *ts_params = &testsuite_params;
3532 struct crypto_unittest_params *ut_params = &unittest_params;
3535 unsigned int plaintext_pad_len;
3536 unsigned int plaintext_len;
3537 uint8_t buffer[10000];
3538 const uint8_t *ciphertext;
3540 struct rte_cryptodev_info dev_info;
3542 /* Verify the capabilities */
3543 struct rte_cryptodev_sym_capability_idx cap_idx;
3544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3545 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3550 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3552 uint64_t feat_flags = dev_info.feature_flags;
3554 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3555 printf("Device doesn't support out-of-place scatter-gather "
3556 "in both input and output mbufs. "
3561 /* Create SNOW 3G session */
3562 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3563 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3564 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3565 tdata->key.data, tdata->key.len,
3566 tdata->cipher_iv.len);
3570 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3571 /* Append data which is padded to a multiple of */
3572 /* the algorithms block size */
3573 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3575 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3576 plaintext_pad_len, 10, 0);
3577 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 3, 0);
3580 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3581 "Failed to allocate input buffer in mempool");
3582 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3583 "Failed to allocate output buffer in mempool");
3585 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3587 /* Create SNOW 3G operation */
3588 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3589 tdata->cipher_iv.len,
3590 tdata->validCipherLenInBits.len,
3595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3597 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3599 ut_params->obuf = ut_params->op->sym->m_dst;
3600 if (ut_params->obuf)
3601 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3602 plaintext_len, buffer);
3604 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3605 plaintext_len, buffer);
3607 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3610 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3612 tdata->ciphertext.data,
3613 tdata->validDataLenInBits.len,
3614 "SNOW 3G Ciphertext data not as expected");
3619 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3621 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3623 uint8_t curr_byte, prev_byte;
3624 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3625 uint8_t lower_byte_mask = (1 << offset) - 1;
3628 prev_byte = buffer[0];
3629 buffer[0] >>= offset;
3631 for (i = 1; i < length_in_bytes; i++) {
3632 curr_byte = buffer[i];
3633 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3634 (curr_byte >> offset);
3635 prev_byte = curr_byte;
3640 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3642 struct crypto_testsuite_params *ts_params = &testsuite_params;
3643 struct crypto_unittest_params *ut_params = &unittest_params;
3644 uint8_t *plaintext, *ciphertext;
3646 uint32_t plaintext_len;
3647 uint32_t plaintext_pad_len;
3648 uint8_t extra_offset = 4;
3649 uint8_t *expected_ciphertext_shifted;
3650 struct rte_cryptodev_info dev_info;
3652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3653 uint64_t feat_flags = dev_info.feature_flags;
3655 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3656 ((tdata->validDataLenInBits.len % 8) != 0)) {
3657 printf("Device doesn't support NON-Byte Aligned Data.\n");
3661 /* Verify the capabilities */
3662 struct rte_cryptodev_sym_capability_idx cap_idx;
3663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3664 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3669 /* Create SNOW 3G session */
3670 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3671 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3672 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3673 tdata->key.data, tdata->key.len,
3674 tdata->cipher_iv.len);
3678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3681 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3682 "Failed to allocate input buffer in mempool");
3683 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3684 "Failed to allocate output buffer in mempool");
3686 /* Clear mbuf payload */
3687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 rte_pktmbuf_tailroom(ut_params->ibuf));
3690 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3692 * Append data which is padded to a
3693 * multiple of the algorithms block size
3695 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3697 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3700 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3702 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3703 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3705 #ifdef RTE_APP_TEST_DEBUG
3706 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3708 /* Create SNOW 3G operation */
3709 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3710 tdata->cipher_iv.len,
3711 tdata->validCipherLenInBits.len,
3716 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3720 ut_params->obuf = ut_params->op->sym->m_dst;
3721 if (ut_params->obuf)
3722 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3724 ciphertext = plaintext;
3726 #ifdef RTE_APP_TEST_DEBUG
3727 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3730 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3732 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3733 "failed to reserve memory for ciphertext shifted\n");
3735 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3736 ceil_byte_length(tdata->ciphertext.len));
3737 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3742 expected_ciphertext_shifted,
3743 tdata->validDataLenInBits.len,
3745 "SNOW 3G Ciphertext data not as expected");
3749 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3751 struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 struct crypto_unittest_params *ut_params = &unittest_params;
3756 uint8_t *plaintext, *ciphertext;
3757 unsigned ciphertext_pad_len;
3758 unsigned ciphertext_len;
3760 /* Verify the capabilities */
3761 struct rte_cryptodev_sym_capability_idx cap_idx;
3762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3763 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3768 /* Create SNOW 3G session */
3769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3770 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3772 tdata->key.data, tdata->key.len,
3773 tdata->cipher_iv.len);
3777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3779 /* Clear mbuf payload */
3780 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3781 rte_pktmbuf_tailroom(ut_params->ibuf));
3783 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3784 /* Append data which is padded to a multiple of */
3785 /* the algorithms block size */
3786 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3787 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 ciphertext_pad_len);
3789 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3791 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3793 /* Create SNOW 3G operation */
3794 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3795 tdata->cipher_iv.len,
3796 tdata->validCipherLenInBits.len,
3797 tdata->cipher.offset_bits);
3801 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3803 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3804 ut_params->obuf = ut_params->op->sym->m_dst;
3805 if (ut_params->obuf)
3806 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3808 plaintext = ciphertext;
3810 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3814 tdata->plaintext.data,
3815 tdata->validDataLenInBits.len,
3816 "SNOW 3G Plaintext data not as expected");
3820 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3822 struct crypto_testsuite_params *ts_params = &testsuite_params;
3823 struct crypto_unittest_params *ut_params = &unittest_params;
3827 uint8_t *plaintext, *ciphertext;
3828 unsigned ciphertext_pad_len;
3829 unsigned ciphertext_len;
3831 /* Verify the capabilities */
3832 struct rte_cryptodev_sym_capability_idx cap_idx;
3833 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3834 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3839 /* Create SNOW 3G session */
3840 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3841 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3842 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3843 tdata->key.data, tdata->key.len,
3844 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3849 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3852 "Failed to allocate input buffer");
3853 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3854 "Failed to allocate output buffer");
3856 /* Clear mbuf payload */
3857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3858 rte_pktmbuf_tailroom(ut_params->ibuf));
3860 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3861 rte_pktmbuf_tailroom(ut_params->obuf));
3863 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3864 /* Append data which is padded to a multiple of */
3865 /* the algorithms block size */
3866 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3867 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 ciphertext_pad_len);
3869 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3870 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3874 /* Create SNOW 3G operation */
3875 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3876 tdata->cipher_iv.len,
3877 tdata->validCipherLenInBits.len,
3882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3885 ut_params->obuf = ut_params->op->sym->m_dst;
3886 if (ut_params->obuf)
3887 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3889 plaintext = ciphertext;
3891 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3895 tdata->plaintext.data,
3896 tdata->validDataLenInBits.len,
3897 "SNOW 3G Plaintext data not as expected");
3902 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3904 struct crypto_testsuite_params *ts_params = &testsuite_params;
3905 struct crypto_unittest_params *ut_params = &unittest_params;
3909 uint8_t *plaintext, *ciphertext;
3910 unsigned int plaintext_pad_len;
3911 unsigned int plaintext_len;
3913 struct rte_cryptodev_info dev_info;
3914 struct rte_cryptodev_sym_capability_idx cap_idx;
3916 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3917 uint64_t feat_flags = dev_info.feature_flags;
3919 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3920 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3921 (tdata->validDataLenInBits.len % 8 != 0))) {
3922 printf("Device doesn't support NON-Byte Aligned Data.\n");
3926 /* Check if device supports ZUC EEA3 */
3927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3928 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3930 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3934 /* Check if device supports ZUC EIA3 */
3935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3936 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3938 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3942 /* Create ZUC session */
3943 retval = create_zuc_cipher_auth_encrypt_generate_session(
3944 ts_params->valid_devs[0],
3948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3950 /* clear mbuf payload */
3951 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3952 rte_pktmbuf_tailroom(ut_params->ibuf));
3954 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3955 /* Append data which is padded to a multiple of */
3956 /* the algorithms block size */
3957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3958 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3960 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3962 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3964 /* Create ZUC operation */
3965 retval = create_zuc_cipher_hash_generate_operation(tdata);
3969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3972 ut_params->obuf = ut_params->op->sym->m_src;
3973 if (ut_params->obuf)
3974 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3976 ciphertext = plaintext;
3978 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 tdata->ciphertext.data,
3983 tdata->validDataLenInBits.len,
3984 "ZUC Ciphertext data not as expected");
3986 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3987 + plaintext_pad_len;
3990 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3994 "ZUC Generated auth tag not as expected");
3999 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4001 struct crypto_testsuite_params *ts_params = &testsuite_params;
4002 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *plaintext, *ciphertext;
4007 unsigned plaintext_pad_len;
4008 unsigned plaintext_len;
4010 /* Verify the capabilities */
4011 struct rte_cryptodev_sym_capability_idx cap_idx;
4012 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4013 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4014 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4018 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4023 /* Create SNOW 3G session */
4024 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4025 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4026 RTE_CRYPTO_AUTH_OP_GENERATE,
4027 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4029 tdata->key.data, tdata->key.len,
4030 tdata->auth_iv.len, tdata->digest.len,
4031 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 /* clear mbuf payload */
4037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4038 rte_pktmbuf_tailroom(ut_params->ibuf));
4040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4041 /* Append data which is padded to a multiple of */
4042 /* the algorithms block size */
4043 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4044 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4048 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4052 tdata->digest.len, tdata->auth_iv.data,
4054 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4055 tdata->cipher_iv.data, tdata->cipher_iv.len,
4056 tdata->validCipherLenInBits.len,
4058 tdata->validAuthLenInBits.len,
4064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4066 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4067 ut_params->obuf = ut_params->op->sym->m_src;
4068 if (ut_params->obuf)
4069 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4071 ciphertext = plaintext;
4073 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4077 tdata->ciphertext.data,
4078 tdata->validDataLenInBits.len,
4079 "SNOW 3G Ciphertext data not as expected");
4081 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4082 + plaintext_pad_len;
4085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4088 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4089 "SNOW 3G Generated auth tag not as expected");
4094 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4095 uint8_t op_mode, uint8_t verify)
4097 struct crypto_testsuite_params *ts_params = &testsuite_params;
4098 struct crypto_unittest_params *ut_params = &unittest_params;
4102 uint8_t *plaintext = NULL, *ciphertext = NULL;
4103 unsigned int plaintext_pad_len;
4104 unsigned int plaintext_len;
4105 unsigned int ciphertext_pad_len;
4106 unsigned int ciphertext_len;
4108 struct rte_cryptodev_info dev_info;
4110 /* Verify the capabilities */
4111 struct rte_cryptodev_sym_capability_idx cap_idx;
4112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4113 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4114 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4117 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4118 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4119 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4123 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4125 uint64_t feat_flags = dev_info.feature_flags;
4127 if (op_mode == OUT_OF_PLACE) {
4128 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4129 printf("Device doesn't support digest encrypted.\n");
4134 /* Create SNOW 3G session */
4135 retval = create_wireless_algo_auth_cipher_session(
4136 ts_params->valid_devs[0],
4137 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4138 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4139 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4140 : RTE_CRYPTO_AUTH_OP_GENERATE),
4141 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4142 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4143 tdata->key.data, tdata->key.len,
4144 tdata->auth_iv.len, tdata->digest.len,
4145 tdata->cipher_iv.len);
4150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4151 if (op_mode == OUT_OF_PLACE)
4152 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4154 /* clear mbuf payload */
4155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4156 rte_pktmbuf_tailroom(ut_params->ibuf));
4157 if (op_mode == OUT_OF_PLACE)
4158 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4159 rte_pktmbuf_tailroom(ut_params->obuf));
4161 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4162 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4163 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4164 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4167 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4168 ciphertext_pad_len);
4169 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4170 if (op_mode == OUT_OF_PLACE)
4171 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4172 debug_hexdump(stdout, "ciphertext:", ciphertext,
4175 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4177 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4178 if (op_mode == OUT_OF_PLACE)
4179 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4180 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4183 /* Create SNOW 3G operation */
4184 retval = create_wireless_algo_auth_cipher_operation(
4185 tdata->digest.data, tdata->digest.len,
4186 tdata->cipher_iv.data, tdata->cipher_iv.len,
4187 tdata->auth_iv.data, tdata->auth_iv.len,
4188 (tdata->digest.offset_bytes == 0 ?
4189 (verify ? ciphertext_pad_len : plaintext_pad_len)
4190 : tdata->digest.offset_bytes),
4191 tdata->validCipherLenInBits.len,
4192 tdata->cipher.offset_bits,
4193 tdata->validAuthLenInBits.len,
4194 tdata->auth.offset_bits,
4195 op_mode, 0, verify);
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4205 ut_params->obuf = (op_mode == IN_PLACE ?
4206 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4209 if (ut_params->obuf)
4210 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4213 plaintext = ciphertext +
4214 (tdata->cipher.offset_bits >> 3);
4216 debug_hexdump(stdout, "plaintext:", plaintext,
4217 (tdata->plaintext.len >> 3) - tdata->digest.len);
4218 debug_hexdump(stdout, "plaintext expected:",
4219 tdata->plaintext.data,
4220 (tdata->plaintext.len >> 3) - tdata->digest.len);
4222 if (ut_params->obuf)
4223 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4226 ciphertext = plaintext;
4228 debug_hexdump(stdout, "ciphertext:", ciphertext,
4230 debug_hexdump(stdout, "ciphertext expected:",
4231 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4233 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4234 + (tdata->digest.offset_bytes == 0 ?
4235 plaintext_pad_len : tdata->digest.offset_bytes);
4237 debug_hexdump(stdout, "digest:", ut_params->digest,
4239 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4245 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4247 tdata->plaintext.data,
4248 tdata->plaintext.len >> 3,
4249 "SNOW 3G Plaintext data not as expected");
4251 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4253 tdata->ciphertext.data,
4254 tdata->validDataLenInBits.len,
4255 "SNOW 3G Ciphertext data not as expected");
4257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4260 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4261 "SNOW 3G Generated auth tag not as expected");
4267 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4268 uint8_t op_mode, uint8_t verify)
4270 struct crypto_testsuite_params *ts_params = &testsuite_params;
4271 struct crypto_unittest_params *ut_params = &unittest_params;
4275 const uint8_t *plaintext = NULL;
4276 const uint8_t *ciphertext = NULL;
4277 const uint8_t *digest = NULL;
4278 unsigned int plaintext_pad_len;
4279 unsigned int plaintext_len;
4280 unsigned int ciphertext_pad_len;
4281 unsigned int ciphertext_len;
4282 uint8_t buffer[10000];
4283 uint8_t digest_buffer[10000];
4285 struct rte_cryptodev_info dev_info;
4287 /* Verify the capabilities */
4288 struct rte_cryptodev_sym_capability_idx cap_idx;
4289 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4290 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4291 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4294 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4295 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4302 uint64_t feat_flags = dev_info.feature_flags;
4304 if (op_mode == IN_PLACE) {
4305 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4306 printf("Device doesn't support in-place scatter-gather "
4307 "in both input and output mbufs.\n");
4311 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4312 printf("Device doesn't support out-of-place scatter-gather "
4313 "in both input and output mbufs.\n");
4316 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4317 printf("Device doesn't support digest encrypted.\n");
4322 /* Create SNOW 3G session */
4323 retval = create_wireless_algo_auth_cipher_session(
4324 ts_params->valid_devs[0],
4325 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4326 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4327 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4328 : RTE_CRYPTO_AUTH_OP_GENERATE),
4329 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4330 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4331 tdata->key.data, tdata->key.len,
4332 tdata->auth_iv.len, tdata->digest.len,
4333 tdata->cipher_iv.len);
4338 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4339 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4340 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4341 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4343 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4344 plaintext_pad_len, 15, 0);
4345 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4346 "Failed to allocate input buffer in mempool");
4348 if (op_mode == OUT_OF_PLACE) {
4349 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4350 plaintext_pad_len, 15, 0);
4351 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4352 "Failed to allocate output buffer in mempool");
4356 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4357 tdata->ciphertext.data);
4358 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4359 ciphertext_len, buffer);
4360 debug_hexdump(stdout, "ciphertext:", ciphertext,
4363 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4364 tdata->plaintext.data);
4365 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4366 plaintext_len, buffer);
4367 debug_hexdump(stdout, "plaintext:", plaintext,
4370 memset(buffer, 0, sizeof(buffer));
4372 /* Create SNOW 3G operation */
4373 retval = create_wireless_algo_auth_cipher_operation(
4374 tdata->digest.data, tdata->digest.len,
4375 tdata->cipher_iv.data, tdata->cipher_iv.len,
4376 tdata->auth_iv.data, tdata->auth_iv.len,
4377 (tdata->digest.offset_bytes == 0 ?
4378 (verify ? ciphertext_pad_len : plaintext_pad_len)
4379 : tdata->digest.offset_bytes),
4380 tdata->validCipherLenInBits.len,
4381 tdata->cipher.offset_bits,
4382 tdata->validAuthLenInBits.len,
4383 tdata->auth.offset_bits,
4384 op_mode, 1, verify);
4389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4394 ut_params->obuf = (op_mode == IN_PLACE ?
4395 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4398 if (ut_params->obuf)
4399 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4400 plaintext_len, buffer);
4402 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4403 plaintext_len, buffer);
4405 debug_hexdump(stdout, "plaintext:", plaintext,
4406 (tdata->plaintext.len >> 3) - tdata->digest.len);
4407 debug_hexdump(stdout, "plaintext expected:",
4408 tdata->plaintext.data,
4409 (tdata->plaintext.len >> 3) - tdata->digest.len);
4411 if (ut_params->obuf)
4412 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4413 ciphertext_len, buffer);
4415 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4416 ciphertext_len, buffer);
4418 debug_hexdump(stdout, "ciphertext:", ciphertext,
4420 debug_hexdump(stdout, "ciphertext expected:",
4421 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4423 if (ut_params->obuf)
4424 digest = rte_pktmbuf_read(ut_params->obuf,
4425 (tdata->digest.offset_bytes == 0 ?
4426 plaintext_pad_len : tdata->digest.offset_bytes),
4427 tdata->digest.len, digest_buffer);
4429 digest = rte_pktmbuf_read(ut_params->ibuf,
4430 (tdata->digest.offset_bytes == 0 ?
4431 plaintext_pad_len : tdata->digest.offset_bytes),
4432 tdata->digest.len, digest_buffer);
4434 debug_hexdump(stdout, "digest:", digest,
4436 debug_hexdump(stdout, "digest expected:",
4437 tdata->digest.data, tdata->digest.len);
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4444 tdata->plaintext.data,
4445 tdata->plaintext.len >> 3,
4446 "SNOW 3G Plaintext data not as expected");
4448 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4450 tdata->ciphertext.data,
4451 tdata->validDataLenInBits.len,
4452 "SNOW 3G Ciphertext data not as expected");
4454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4457 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4458 "SNOW 3G Generated auth tag not as expected");
4464 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4465 uint8_t op_mode, uint8_t verify)
4467 struct crypto_testsuite_params *ts_params = &testsuite_params;
4468 struct crypto_unittest_params *ut_params = &unittest_params;
4472 uint8_t *plaintext = NULL, *ciphertext = NULL;
4473 unsigned int plaintext_pad_len;
4474 unsigned int plaintext_len;
4475 unsigned int ciphertext_pad_len;
4476 unsigned int ciphertext_len;
4478 struct rte_cryptodev_info dev_info;
4480 /* Verify the capabilities */
4481 struct rte_cryptodev_sym_capability_idx cap_idx;
4482 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4483 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4484 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4489 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4493 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4495 uint64_t feat_flags = dev_info.feature_flags;
4497 if (op_mode == OUT_OF_PLACE) {
4498 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4499 printf("Device doesn't support digest encrypted.\n");
4504 /* Create KASUMI session */
4505 retval = create_wireless_algo_auth_cipher_session(
4506 ts_params->valid_devs[0],
4507 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4508 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4509 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4510 : RTE_CRYPTO_AUTH_OP_GENERATE),
4511 RTE_CRYPTO_AUTH_KASUMI_F9,
4512 RTE_CRYPTO_CIPHER_KASUMI_F8,
4513 tdata->key.data, tdata->key.len,
4514 0, tdata->digest.len,
4515 tdata->cipher_iv.len);
4520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4521 if (op_mode == OUT_OF_PLACE)
4522 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4524 /* clear mbuf payload */
4525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4526 rte_pktmbuf_tailroom(ut_params->ibuf));
4527 if (op_mode == OUT_OF_PLACE)
4528 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4529 rte_pktmbuf_tailroom(ut_params->obuf));
4531 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4532 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4533 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4534 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4537 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4538 ciphertext_pad_len);
4539 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4540 if (op_mode == OUT_OF_PLACE)
4541 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4542 debug_hexdump(stdout, "ciphertext:", ciphertext,
4545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4548 if (op_mode == OUT_OF_PLACE)
4549 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4550 debug_hexdump(stdout, "plaintext:", plaintext,
4554 /* Create KASUMI operation */
4555 retval = create_wireless_algo_auth_cipher_operation(
4556 tdata->digest.data, tdata->digest.len,
4557 tdata->cipher_iv.data, tdata->cipher_iv.len,
4559 (tdata->digest.offset_bytes == 0 ?
4560 (verify ? ciphertext_pad_len : plaintext_pad_len)
4561 : tdata->digest.offset_bytes),
4562 tdata->validCipherLenInBits.len,
4563 tdata->validCipherOffsetInBits.len,
4564 tdata->validAuthLenInBits.len,
4566 op_mode, 0, verify);
4571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4574 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4576 ut_params->obuf = (op_mode == IN_PLACE ?
4577 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4581 if (ut_params->obuf)
4582 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4585 plaintext = ciphertext;
4587 debug_hexdump(stdout, "plaintext:", plaintext,
4588 (tdata->plaintext.len >> 3) - tdata->digest.len);
4589 debug_hexdump(stdout, "plaintext expected:",
4590 tdata->plaintext.data,
4591 (tdata->plaintext.len >> 3) - tdata->digest.len);
4593 if (ut_params->obuf)
4594 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4597 ciphertext = plaintext;
4599 debug_hexdump(stdout, "ciphertext:", ciphertext,
4601 debug_hexdump(stdout, "ciphertext expected:",
4602 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4604 ut_params->digest = rte_pktmbuf_mtod(
4605 ut_params->obuf, uint8_t *) +
4606 (tdata->digest.offset_bytes == 0 ?
4607 plaintext_pad_len : tdata->digest.offset_bytes);
4609 debug_hexdump(stdout, "digest:", ut_params->digest,
4611 debug_hexdump(stdout, "digest expected:",
4612 tdata->digest.data, tdata->digest.len);
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4619 tdata->plaintext.data,
4620 tdata->plaintext.len >> 3,
4621 "KASUMI Plaintext data not as expected");
4623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4625 tdata->ciphertext.data,
4626 tdata->ciphertext.len >> 3,
4627 "KASUMI Ciphertext data not as expected");
4629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4632 DIGEST_BYTE_LENGTH_KASUMI_F9,
4633 "KASUMI Generated auth tag not as expected");
4639 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4640 uint8_t op_mode, uint8_t verify)
4642 struct crypto_testsuite_params *ts_params = &testsuite_params;
4643 struct crypto_unittest_params *ut_params = &unittest_params;
4647 const uint8_t *plaintext = NULL;
4648 const uint8_t *ciphertext = NULL;
4649 const uint8_t *digest = NULL;
4650 unsigned int plaintext_pad_len;
4651 unsigned int plaintext_len;
4652 unsigned int ciphertext_pad_len;
4653 unsigned int ciphertext_len;
4654 uint8_t buffer[10000];
4655 uint8_t digest_buffer[10000];
4657 struct rte_cryptodev_info dev_info;
4659 /* Verify the capabilities */
4660 struct rte_cryptodev_sym_capability_idx cap_idx;
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4662 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4666 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4667 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4674 uint64_t feat_flags = dev_info.feature_flags;
4676 if (op_mode == IN_PLACE) {
4677 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4678 printf("Device doesn't support in-place scatter-gather "
4679 "in both input and output mbufs.\n");
4683 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4684 printf("Device doesn't support out-of-place scatter-gather "
4685 "in both input and output mbufs.\n");
4688 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4689 printf("Device doesn't support digest encrypted.\n");
4694 /* Create KASUMI session */
4695 retval = create_wireless_algo_auth_cipher_session(
4696 ts_params->valid_devs[0],
4697 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4698 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4699 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4700 : RTE_CRYPTO_AUTH_OP_GENERATE),
4701 RTE_CRYPTO_AUTH_KASUMI_F9,
4702 RTE_CRYPTO_CIPHER_KASUMI_F8,
4703 tdata->key.data, tdata->key.len,
4704 0, tdata->digest.len,
4705 tdata->cipher_iv.len);
4710 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4711 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4712 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4713 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4715 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4716 plaintext_pad_len, 15, 0);
4717 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4718 "Failed to allocate input buffer in mempool");
4720 if (op_mode == OUT_OF_PLACE) {
4721 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4722 plaintext_pad_len, 15, 0);
4723 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4724 "Failed to allocate output buffer in mempool");
4728 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4729 tdata->ciphertext.data);
4730 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4731 ciphertext_len, buffer);
4732 debug_hexdump(stdout, "ciphertext:", ciphertext,
4735 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4736 tdata->plaintext.data);
4737 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4738 plaintext_len, buffer);
4739 debug_hexdump(stdout, "plaintext:", plaintext,
4742 memset(buffer, 0, sizeof(buffer));
4744 /* Create KASUMI operation */
4745 retval = create_wireless_algo_auth_cipher_operation(
4746 tdata->digest.data, tdata->digest.len,
4747 tdata->cipher_iv.data, tdata->cipher_iv.len,
4749 (tdata->digest.offset_bytes == 0 ?
4750 (verify ? ciphertext_pad_len : plaintext_pad_len)
4751 : tdata->digest.offset_bytes),
4752 tdata->validCipherLenInBits.len,
4753 tdata->validCipherOffsetInBits.len,
4754 tdata->validAuthLenInBits.len,
4756 op_mode, 1, verify);
4761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4764 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4766 ut_params->obuf = (op_mode == IN_PLACE ?
4767 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4770 if (ut_params->obuf)
4771 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4772 plaintext_len, buffer);
4774 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4775 plaintext_len, buffer);
4777 debug_hexdump(stdout, "plaintext:", plaintext,
4778 (tdata->plaintext.len >> 3) - tdata->digest.len);
4779 debug_hexdump(stdout, "plaintext expected:",
4780 tdata->plaintext.data,
4781 (tdata->plaintext.len >> 3) - tdata->digest.len);
4783 if (ut_params->obuf)
4784 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4785 ciphertext_len, buffer);
4787 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4788 ciphertext_len, buffer);
4790 debug_hexdump(stdout, "ciphertext:", ciphertext,
4792 debug_hexdump(stdout, "ciphertext expected:",
4793 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4795 if (ut_params->obuf)
4796 digest = rte_pktmbuf_read(ut_params->obuf,
4797 (tdata->digest.offset_bytes == 0 ?
4798 plaintext_pad_len : tdata->digest.offset_bytes),
4799 tdata->digest.len, digest_buffer);
4801 digest = rte_pktmbuf_read(ut_params->ibuf,
4802 (tdata->digest.offset_bytes == 0 ?
4803 plaintext_pad_len : tdata->digest.offset_bytes),
4804 tdata->digest.len, digest_buffer);
4806 debug_hexdump(stdout, "digest:", digest,
4808 debug_hexdump(stdout, "digest expected:",
4809 tdata->digest.data, tdata->digest.len);
4814 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4816 tdata->plaintext.data,
4817 tdata->plaintext.len >> 3,
4818 "KASUMI Plaintext data not as expected");
4820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4822 tdata->ciphertext.data,
4823 tdata->validDataLenInBits.len,
4824 "KASUMI Ciphertext data not as expected");
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4829 DIGEST_BYTE_LENGTH_KASUMI_F9,
4830 "KASUMI Generated auth tag not as expected");
4836 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4838 struct crypto_testsuite_params *ts_params = &testsuite_params;
4839 struct crypto_unittest_params *ut_params = &unittest_params;
4843 uint8_t *plaintext, *ciphertext;
4844 unsigned plaintext_pad_len;
4845 unsigned plaintext_len;
4847 /* Verify the capabilities */
4848 struct rte_cryptodev_sym_capability_idx cap_idx;
4849 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4850 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4851 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4854 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4855 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4856 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4860 /* Create KASUMI session */
4861 retval = create_wireless_algo_cipher_auth_session(
4862 ts_params->valid_devs[0],
4863 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4864 RTE_CRYPTO_AUTH_OP_GENERATE,
4865 RTE_CRYPTO_AUTH_KASUMI_F9,
4866 RTE_CRYPTO_CIPHER_KASUMI_F8,
4867 tdata->key.data, tdata->key.len,
4868 0, tdata->digest.len,
4869 tdata->cipher_iv.len);
4873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4875 /* clear mbuf payload */
4876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4877 rte_pktmbuf_tailroom(ut_params->ibuf));
4879 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4880 /* Append data which is padded to a multiple of */
4881 /* the algorithms block size */
4882 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4883 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4885 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4887 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4889 /* Create KASUMI operation */
4890 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4891 tdata->digest.len, NULL, 0,
4892 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4893 tdata->cipher_iv.data, tdata->cipher_iv.len,
4894 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4895 tdata->validCipherOffsetInBits.len,
4896 tdata->validAuthLenInBits.len,
4902 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4904 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4906 if (ut_params->op->sym->m_dst)
4907 ut_params->obuf = ut_params->op->sym->m_dst;
4909 ut_params->obuf = ut_params->op->sym->m_src;
4911 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4912 tdata->validCipherOffsetInBits.len >> 3);
4914 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4915 + plaintext_pad_len;
4917 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4918 (tdata->validCipherOffsetInBits.len >> 3);
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4922 reference_ciphertext,
4923 tdata->validCipherLenInBits.len,
4924 "KASUMI Ciphertext data not as expected");
4927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4930 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4931 "KASUMI Generated auth tag not as expected");
4936 test_zuc_encryption(const struct wireless_test_data *tdata)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4939 struct crypto_unittest_params *ut_params = &unittest_params;
4942 uint8_t *plaintext, *ciphertext;
4943 unsigned plaintext_pad_len;
4944 unsigned plaintext_len;
4946 struct rte_cryptodev_sym_capability_idx cap_idx;
4948 /* Check if device supports ZUC EEA3 */
4949 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4950 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4956 /* Create ZUC session */
4957 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4958 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4959 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4960 tdata->key.data, tdata->key.len,
4961 tdata->cipher_iv.len);
4965 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4967 /* Clear mbuf payload */
4968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4969 rte_pktmbuf_tailroom(ut_params->ibuf));
4971 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4972 /* Append data which is padded to a multiple */
4973 /* of the algorithms block size */
4974 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4975 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4977 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4979 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4981 /* Create ZUC operation */
4982 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4983 tdata->cipher_iv.len,
4984 tdata->plaintext.len,
4989 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4991 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4993 ut_params->obuf = ut_params->op->sym->m_dst;
4994 if (ut_params->obuf)
4995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4997 ciphertext = plaintext;
4999 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5004 tdata->ciphertext.data,
5005 tdata->validCipherLenInBits.len,
5006 "ZUC Ciphertext data not as expected");
5011 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5013 struct crypto_testsuite_params *ts_params = &testsuite_params;
5014 struct crypto_unittest_params *ut_params = &unittest_params;
5018 unsigned int plaintext_pad_len;
5019 unsigned int plaintext_len;
5020 const uint8_t *ciphertext;
5021 uint8_t ciphertext_buffer[2048];
5022 struct rte_cryptodev_info dev_info;
5024 struct rte_cryptodev_sym_capability_idx cap_idx;
5026 /* Check if device supports ZUC EEA3 */
5027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5028 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5030 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5034 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5036 uint64_t feat_flags = dev_info.feature_flags;
5038 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5039 printf("Device doesn't support in-place scatter-gather. "
5044 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5046 /* Append data which is padded to a multiple */
5047 /* of the algorithms block size */
5048 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5050 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5051 plaintext_pad_len, 10, 0);
5053 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5054 tdata->plaintext.data);
5056 /* Create ZUC session */
5057 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5058 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5059 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5060 tdata->key.data, tdata->key.len,
5061 tdata->cipher_iv.len);
5065 /* Clear mbuf payload */
5067 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5069 /* Create ZUC operation */
5070 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5071 tdata->cipher_iv.len, tdata->plaintext.len,
5076 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5078 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5080 ut_params->obuf = ut_params->op->sym->m_dst;
5081 if (ut_params->obuf)
5082 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5083 0, plaintext_len, ciphertext_buffer);
5085 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5086 0, plaintext_len, ciphertext_buffer);
5089 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5092 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5094 tdata->ciphertext.data,
5095 tdata->validCipherLenInBits.len,
5096 "ZUC Ciphertext data not as expected");
5102 test_zuc_authentication(const struct wireless_test_data *tdata)
5104 struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 struct crypto_unittest_params *ut_params = &unittest_params;
5108 unsigned plaintext_pad_len;
5109 unsigned plaintext_len;
5112 struct rte_cryptodev_sym_capability_idx cap_idx;
5113 struct rte_cryptodev_info dev_info;
5115 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5116 uint64_t feat_flags = dev_info.feature_flags;
5118 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5119 (tdata->validAuthLenInBits.len % 8 != 0)) {
5120 printf("Device doesn't support NON-Byte Aligned Data.\n");
5124 /* Check if device supports ZUC EIA3 */
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5126 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5128 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5132 /* Create ZUC session */
5133 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5134 tdata->key.data, tdata->key.len,
5135 tdata->auth_iv.len, tdata->digest.len,
5136 RTE_CRYPTO_AUTH_OP_GENERATE,
5137 RTE_CRYPTO_AUTH_ZUC_EIA3);
5141 /* alloc mbuf and set payload */
5142 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5145 rte_pktmbuf_tailroom(ut_params->ibuf));
5147 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5148 /* Append data which is padded to a multiple of */
5149 /* the algorithms block size */
5150 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5151 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5153 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5155 /* Create ZUC operation */
5156 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5157 tdata->auth_iv.data, tdata->auth_iv.len,
5158 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5159 tdata->validAuthLenInBits.len,
5164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5166 ut_params->obuf = ut_params->op->sym->m_src;
5167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5168 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5169 + plaintext_pad_len;
5172 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 "ZUC Generated auth tag not as expected");
5182 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5183 uint8_t op_mode, uint8_t verify)
5185 struct crypto_testsuite_params *ts_params = &testsuite_params;
5186 struct crypto_unittest_params *ut_params = &unittest_params;
5190 uint8_t *plaintext = NULL, *ciphertext = NULL;
5191 unsigned int plaintext_pad_len;
5192 unsigned int plaintext_len;
5193 unsigned int ciphertext_pad_len;
5194 unsigned int ciphertext_len;
5196 struct rte_cryptodev_info dev_info;
5197 struct rte_cryptodev_sym_capability_idx cap_idx;
5199 /* Check if device supports ZUC EIA3 */
5200 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5201 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5207 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5209 uint64_t feat_flags = dev_info.feature_flags;
5211 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5212 printf("Device doesn't support digest encrypted.\n");
5215 if (op_mode == IN_PLACE) {
5216 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5217 printf("Device doesn't support in-place scatter-gather "
5218 "in both input and output mbufs.\n");
5222 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5223 printf("Device doesn't support out-of-place scatter-gather "
5224 "in both input and output mbufs.\n");
5229 /* Create ZUC session */
5230 retval = create_wireless_algo_auth_cipher_session(
5231 ts_params->valid_devs[0],
5232 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5233 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5234 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5235 : RTE_CRYPTO_AUTH_OP_GENERATE),
5236 RTE_CRYPTO_AUTH_ZUC_EIA3,
5237 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5238 tdata->key.data, tdata->key.len,
5239 tdata->auth_iv.len, tdata->digest.len,
5240 tdata->cipher_iv.len);
5245 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5246 if (op_mode == OUT_OF_PLACE)
5247 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5249 /* clear mbuf payload */
5250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5251 rte_pktmbuf_tailroom(ut_params->ibuf));
5252 if (op_mode == OUT_OF_PLACE)
5253 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5254 rte_pktmbuf_tailroom(ut_params->obuf));
5256 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5257 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5258 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5259 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5262 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5263 ciphertext_pad_len);
5264 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5265 if (op_mode == OUT_OF_PLACE)
5266 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5267 debug_hexdump(stdout, "ciphertext:", ciphertext,
5270 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5272 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5273 if (op_mode == OUT_OF_PLACE)
5274 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5275 debug_hexdump(stdout, "plaintext:", plaintext,
5279 /* Create ZUC operation */
5280 retval = create_wireless_algo_auth_cipher_operation(
5281 tdata->digest.data, tdata->digest.len,
5282 tdata->cipher_iv.data, tdata->cipher_iv.len,
5283 tdata->auth_iv.data, tdata->auth_iv.len,
5284 (tdata->digest.offset_bytes == 0 ?
5285 (verify ? ciphertext_pad_len : plaintext_pad_len)
5286 : tdata->digest.offset_bytes),
5287 tdata->validCipherLenInBits.len,
5288 tdata->validCipherOffsetInBits.len,
5289 tdata->validAuthLenInBits.len,
5291 op_mode, 0, verify);
5296 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5299 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5301 ut_params->obuf = (op_mode == IN_PLACE ?
5302 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5306 if (ut_params->obuf)
5307 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5310 plaintext = ciphertext;
5312 debug_hexdump(stdout, "plaintext:", plaintext,
5313 (tdata->plaintext.len >> 3) - tdata->digest.len);
5314 debug_hexdump(stdout, "plaintext expected:",
5315 tdata->plaintext.data,
5316 (tdata->plaintext.len >> 3) - tdata->digest.len);
5318 if (ut_params->obuf)
5319 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5322 ciphertext = plaintext;
5324 debug_hexdump(stdout, "ciphertext:", ciphertext,
5326 debug_hexdump(stdout, "ciphertext expected:",
5327 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5329 ut_params->digest = rte_pktmbuf_mtod(
5330 ut_params->obuf, uint8_t *) +
5331 (tdata->digest.offset_bytes == 0 ?
5332 plaintext_pad_len : tdata->digest.offset_bytes);
5334 debug_hexdump(stdout, "digest:", ut_params->digest,
5336 debug_hexdump(stdout, "digest expected:",
5337 tdata->digest.data, tdata->digest.len);
5342 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5344 tdata->plaintext.data,
5345 tdata->plaintext.len >> 3,
5346 "ZUC Plaintext data not as expected");
5348 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5350 tdata->ciphertext.data,
5351 tdata->ciphertext.len >> 3,
5352 "ZUC Ciphertext data not as expected");
5354 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5357 DIGEST_BYTE_LENGTH_KASUMI_F9,
5358 "ZUC Generated auth tag not as expected");
5364 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5365 uint8_t op_mode, uint8_t verify)
5367 struct crypto_testsuite_params *ts_params = &testsuite_params;
5368 struct crypto_unittest_params *ut_params = &unittest_params;
5372 const uint8_t *plaintext = NULL;
5373 const uint8_t *ciphertext = NULL;
5374 const uint8_t *digest = NULL;
5375 unsigned int plaintext_pad_len;
5376 unsigned int plaintext_len;
5377 unsigned int ciphertext_pad_len;
5378 unsigned int ciphertext_len;
5379 uint8_t buffer[10000];
5380 uint8_t digest_buffer[10000];
5382 struct rte_cryptodev_info dev_info;
5383 struct rte_cryptodev_sym_capability_idx cap_idx;
5385 /* Check if device supports ZUC EIA3 */
5386 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5387 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5393 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5395 uint64_t feat_flags = dev_info.feature_flags;
5397 if (op_mode == IN_PLACE) {
5398 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5399 printf("Device doesn't support in-place scatter-gather "
5400 "in both input and output mbufs.\n");
5404 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5405 printf("Device doesn't support out-of-place scatter-gather "
5406 "in both input and output mbufs.\n");
5409 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5410 printf("Device doesn't support digest encrypted.\n");
5415 /* Create ZUC session */
5416 retval = create_wireless_algo_auth_cipher_session(
5417 ts_params->valid_devs[0],
5418 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5419 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5420 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5421 : RTE_CRYPTO_AUTH_OP_GENERATE),
5422 RTE_CRYPTO_AUTH_ZUC_EIA3,
5423 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5424 tdata->key.data, tdata->key.len,
5425 tdata->auth_iv.len, tdata->digest.len,
5426 tdata->cipher_iv.len);
5431 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5433 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5434 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5436 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5437 plaintext_pad_len, 15, 0);
5438 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5439 "Failed to allocate input buffer in mempool");
5441 if (op_mode == OUT_OF_PLACE) {
5442 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5443 plaintext_pad_len, 15, 0);
5444 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5445 "Failed to allocate output buffer in mempool");
5449 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5450 tdata->ciphertext.data);
5451 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5452 ciphertext_len, buffer);
5453 debug_hexdump(stdout, "ciphertext:", ciphertext,
5456 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5457 tdata->plaintext.data);
5458 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5459 plaintext_len, buffer);
5460 debug_hexdump(stdout, "plaintext:", plaintext,
5463 memset(buffer, 0, sizeof(buffer));
5465 /* Create ZUC operation */
5466 retval = create_wireless_algo_auth_cipher_operation(
5467 tdata->digest.data, tdata->digest.len,
5468 tdata->cipher_iv.data, tdata->cipher_iv.len,
5470 (tdata->digest.offset_bytes == 0 ?
5471 (verify ? ciphertext_pad_len : plaintext_pad_len)
5472 : tdata->digest.offset_bytes),
5473 tdata->validCipherLenInBits.len,
5474 tdata->validCipherOffsetInBits.len,
5475 tdata->validAuthLenInBits.len,
5477 op_mode, 1, verify);
5482 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5485 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5487 ut_params->obuf = (op_mode == IN_PLACE ?
5488 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5491 if (ut_params->obuf)
5492 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5493 plaintext_len, buffer);
5495 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5496 plaintext_len, buffer);
5498 debug_hexdump(stdout, "plaintext:", plaintext,
5499 (tdata->plaintext.len >> 3) - tdata->digest.len);
5500 debug_hexdump(stdout, "plaintext expected:",
5501 tdata->plaintext.data,
5502 (tdata->plaintext.len >> 3) - tdata->digest.len);
5504 if (ut_params->obuf)
5505 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5506 ciphertext_len, buffer);
5508 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5509 ciphertext_len, buffer);
5511 debug_hexdump(stdout, "ciphertext:", ciphertext,
5513 debug_hexdump(stdout, "ciphertext expected:",
5514 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5516 if (ut_params->obuf)
5517 digest = rte_pktmbuf_read(ut_params->obuf,
5518 (tdata->digest.offset_bytes == 0 ?
5519 plaintext_pad_len : tdata->digest.offset_bytes),
5520 tdata->digest.len, digest_buffer);
5522 digest = rte_pktmbuf_read(ut_params->ibuf,
5523 (tdata->digest.offset_bytes == 0 ?
5524 plaintext_pad_len : tdata->digest.offset_bytes),
5525 tdata->digest.len, digest_buffer);
5527 debug_hexdump(stdout, "digest:", digest,
5529 debug_hexdump(stdout, "digest expected:",
5530 tdata->digest.data, tdata->digest.len);
5535 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5537 tdata->plaintext.data,
5538 tdata->plaintext.len >> 3,
5539 "ZUC Plaintext data not as expected");
5541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5543 tdata->ciphertext.data,
5544 tdata->validDataLenInBits.len,
5545 "ZUC Ciphertext data not as expected");
5547 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5550 DIGEST_BYTE_LENGTH_KASUMI_F9,
5551 "ZUC Generated auth tag not as expected");
5557 test_kasumi_encryption_test_case_1(void)
5559 return test_kasumi_encryption(&kasumi_test_case_1);
5563 test_kasumi_encryption_test_case_1_sgl(void)
5565 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5569 test_kasumi_encryption_test_case_1_oop(void)
5571 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5575 test_kasumi_encryption_test_case_1_oop_sgl(void)
5577 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5581 test_kasumi_encryption_test_case_2(void)
5583 return test_kasumi_encryption(&kasumi_test_case_2);
5587 test_kasumi_encryption_test_case_3(void)
5589 return test_kasumi_encryption(&kasumi_test_case_3);
5593 test_kasumi_encryption_test_case_4(void)
5595 return test_kasumi_encryption(&kasumi_test_case_4);
5599 test_kasumi_encryption_test_case_5(void)
5601 return test_kasumi_encryption(&kasumi_test_case_5);
5605 test_kasumi_decryption_test_case_1(void)
5607 return test_kasumi_decryption(&kasumi_test_case_1);
5611 test_kasumi_decryption_test_case_1_oop(void)
5613 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5617 test_kasumi_decryption_test_case_2(void)
5619 return test_kasumi_decryption(&kasumi_test_case_2);
5623 test_kasumi_decryption_test_case_3(void)
5625 return test_kasumi_decryption(&kasumi_test_case_3);
5629 test_kasumi_decryption_test_case_4(void)
5631 return test_kasumi_decryption(&kasumi_test_case_4);
5635 test_kasumi_decryption_test_case_5(void)
5637 return test_kasumi_decryption(&kasumi_test_case_5);
5640 test_snow3g_encryption_test_case_1(void)
5642 return test_snow3g_encryption(&snow3g_test_case_1);
5646 test_snow3g_encryption_test_case_1_oop(void)
5648 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5652 test_snow3g_encryption_test_case_1_oop_sgl(void)
5654 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5659 test_snow3g_encryption_test_case_1_offset_oop(void)
5661 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5665 test_snow3g_encryption_test_case_2(void)
5667 return test_snow3g_encryption(&snow3g_test_case_2);
5671 test_snow3g_encryption_test_case_3(void)
5673 return test_snow3g_encryption(&snow3g_test_case_3);
5677 test_snow3g_encryption_test_case_4(void)
5679 return test_snow3g_encryption(&snow3g_test_case_4);
5683 test_snow3g_encryption_test_case_5(void)
5685 return test_snow3g_encryption(&snow3g_test_case_5);
5689 test_snow3g_decryption_test_case_1(void)
5691 return test_snow3g_decryption(&snow3g_test_case_1);
5695 test_snow3g_decryption_test_case_1_oop(void)
5697 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5701 test_snow3g_decryption_test_case_2(void)
5703 return test_snow3g_decryption(&snow3g_test_case_2);
5707 test_snow3g_decryption_test_case_3(void)
5709 return test_snow3g_decryption(&snow3g_test_case_3);
5713 test_snow3g_decryption_test_case_4(void)
5715 return test_snow3g_decryption(&snow3g_test_case_4);
5719 test_snow3g_decryption_test_case_5(void)
5721 return test_snow3g_decryption(&snow3g_test_case_5);
5725 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5726 * Pattern digest from snow3g_test_data must be allocated as
5727 * 4 last bytes in plaintext.
5730 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5731 struct snow3g_hash_test_data *output)
5733 if ((pattern != NULL) && (output != NULL)) {
5734 output->key.len = pattern->key.len;
5736 memcpy(output->key.data,
5737 pattern->key.data, pattern->key.len);
5739 output->auth_iv.len = pattern->auth_iv.len;
5741 memcpy(output->auth_iv.data,
5742 pattern->auth_iv.data, pattern->auth_iv.len);
5744 output->plaintext.len = pattern->plaintext.len;
5746 memcpy(output->plaintext.data,
5747 pattern->plaintext.data, pattern->plaintext.len >> 3);
5749 output->digest.len = pattern->digest.len;
5751 memcpy(output->digest.data,
5752 &pattern->plaintext.data[pattern->digest.offset_bytes],
5753 pattern->digest.len);
5755 output->validAuthLenInBits.len =
5756 pattern->validAuthLenInBits.len;
5761 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5764 test_snow3g_decryption_with_digest_test_case_1(void)
5766 struct snow3g_hash_test_data snow3g_hash_data;
5769 * Function prepare data for hash veryfication test case.
5770 * Digest is allocated in 4 last bytes in plaintext, pattern.
5772 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5774 return test_snow3g_decryption(&snow3g_test_case_7) &
5775 test_snow3g_authentication_verify(&snow3g_hash_data);
5779 test_snow3g_cipher_auth_test_case_1(void)
5781 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5785 test_snow3g_auth_cipher_test_case_1(void)
5787 return test_snow3g_auth_cipher(
5788 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5792 test_snow3g_auth_cipher_test_case_2(void)
5794 return test_snow3g_auth_cipher(
5795 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5799 test_snow3g_auth_cipher_test_case_2_oop(void)
5801 return test_snow3g_auth_cipher(
5802 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5806 test_snow3g_auth_cipher_part_digest_enc(void)
5808 return test_snow3g_auth_cipher(
5809 &snow3g_auth_cipher_partial_digest_encryption,
5814 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5816 return test_snow3g_auth_cipher(
5817 &snow3g_auth_cipher_partial_digest_encryption,
5822 test_snow3g_auth_cipher_test_case_3_sgl(void)
5824 return test_snow3g_auth_cipher_sgl(
5825 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5829 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5831 return test_snow3g_auth_cipher_sgl(
5832 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5836 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5838 return test_snow3g_auth_cipher_sgl(
5839 &snow3g_auth_cipher_partial_digest_encryption,
5844 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5846 return test_snow3g_auth_cipher_sgl(
5847 &snow3g_auth_cipher_partial_digest_encryption,
5852 test_snow3g_auth_cipher_verify_test_case_1(void)
5854 return test_snow3g_auth_cipher(
5855 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5859 test_snow3g_auth_cipher_verify_test_case_2(void)
5861 return test_snow3g_auth_cipher(
5862 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5866 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5868 return test_snow3g_auth_cipher(
5869 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5873 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5875 return test_snow3g_auth_cipher(
5876 &snow3g_auth_cipher_partial_digest_encryption,
5881 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5883 return test_snow3g_auth_cipher(
5884 &snow3g_auth_cipher_partial_digest_encryption,
5889 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5891 return test_snow3g_auth_cipher_sgl(
5892 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5896 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5898 return test_snow3g_auth_cipher_sgl(
5899 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5903 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5905 return test_snow3g_auth_cipher_sgl(
5906 &snow3g_auth_cipher_partial_digest_encryption,
5911 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5913 return test_snow3g_auth_cipher_sgl(
5914 &snow3g_auth_cipher_partial_digest_encryption,
5919 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5921 return test_snow3g_auth_cipher(
5922 &snow3g_test_case_7, IN_PLACE, 0);
5926 test_kasumi_auth_cipher_test_case_1(void)
5928 return test_kasumi_auth_cipher(
5929 &kasumi_test_case_3, IN_PLACE, 0);
5933 test_kasumi_auth_cipher_test_case_2(void)
5935 return test_kasumi_auth_cipher(
5936 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5940 test_kasumi_auth_cipher_test_case_2_oop(void)
5942 return test_kasumi_auth_cipher(
5943 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5947 test_kasumi_auth_cipher_test_case_2_sgl(void)
5949 return test_kasumi_auth_cipher_sgl(
5950 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5954 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5956 return test_kasumi_auth_cipher_sgl(
5957 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5961 test_kasumi_auth_cipher_verify_test_case_1(void)
5963 return test_kasumi_auth_cipher(
5964 &kasumi_test_case_3, IN_PLACE, 1);
5968 test_kasumi_auth_cipher_verify_test_case_2(void)
5970 return test_kasumi_auth_cipher(
5971 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5975 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5977 return test_kasumi_auth_cipher(
5978 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5982 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5984 return test_kasumi_auth_cipher_sgl(
5985 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5989 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5991 return test_kasumi_auth_cipher_sgl(
5992 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5996 test_kasumi_cipher_auth_test_case_1(void)
5998 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6002 test_zuc_encryption_test_case_1(void)
6004 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6008 test_zuc_encryption_test_case_2(void)
6010 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6014 test_zuc_encryption_test_case_3(void)
6016 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6020 test_zuc_encryption_test_case_4(void)
6022 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6026 test_zuc_encryption_test_case_5(void)
6028 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6032 test_zuc_encryption_test_case_6_sgl(void)
6034 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6038 test_zuc_hash_generate_test_case_1(void)
6040 return test_zuc_authentication(&zuc_test_case_auth_1b);
6044 test_zuc_hash_generate_test_case_2(void)
6046 return test_zuc_authentication(&zuc_test_case_auth_90b);
6050 test_zuc_hash_generate_test_case_3(void)
6052 return test_zuc_authentication(&zuc_test_case_auth_577b);
6056 test_zuc_hash_generate_test_case_4(void)
6058 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6062 test_zuc_hash_generate_test_case_5(void)
6064 return test_zuc_authentication(&zuc_test_auth_5670b);
6068 test_zuc_hash_generate_test_case_6(void)
6070 return test_zuc_authentication(&zuc_test_case_auth_128b);
6074 test_zuc_hash_generate_test_case_7(void)
6076 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6080 test_zuc_hash_generate_test_case_8(void)
6082 return test_zuc_authentication(&zuc_test_case_auth_584b);
6086 test_zuc_cipher_auth_test_case_1(void)
6088 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6092 test_zuc_cipher_auth_test_case_2(void)
6094 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6098 test_zuc_auth_cipher_test_case_1(void)
6100 return test_zuc_auth_cipher(
6101 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6105 test_zuc_auth_cipher_test_case_1_oop(void)
6107 return test_zuc_auth_cipher(
6108 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6112 test_zuc_auth_cipher_test_case_1_sgl(void)
6114 return test_zuc_auth_cipher_sgl(
6115 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6119 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6121 return test_zuc_auth_cipher_sgl(
6122 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6126 test_zuc_auth_cipher_verify_test_case_1(void)
6128 return test_zuc_auth_cipher(
6129 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6133 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6135 return test_zuc_auth_cipher(
6136 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6140 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6142 return test_zuc_auth_cipher_sgl(
6143 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6147 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6149 return test_zuc_auth_cipher_sgl(
6150 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6154 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6156 uint8_t dev_id = testsuite_params.valid_devs[0];
6158 struct rte_cryptodev_sym_capability_idx cap_idx;
6160 /* Check if device supports particular cipher algorithm */
6161 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6162 cap_idx.algo.cipher = tdata->cipher_algo;
6163 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6166 /* Check if device supports particular hash algorithm */
6167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6168 cap_idx.algo.auth = tdata->auth_algo;
6169 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6176 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6177 uint8_t op_mode, uint8_t verify)
6179 struct crypto_testsuite_params *ts_params = &testsuite_params;
6180 struct crypto_unittest_params *ut_params = &unittest_params;
6184 uint8_t *plaintext = NULL, *ciphertext = NULL;
6185 unsigned int plaintext_pad_len;
6186 unsigned int plaintext_len;
6187 unsigned int ciphertext_pad_len;
6188 unsigned int ciphertext_len;
6190 struct rte_cryptodev_info dev_info;
6191 struct rte_crypto_op *op;
6193 /* Check if device supports particular algorithms separately */
6194 if (test_mixed_check_if_unsupported(tdata))
6197 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6199 uint64_t feat_flags = dev_info.feature_flags;
6201 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6202 printf("Device doesn't support digest encrypted.\n");
6206 /* Create the session */
6208 retval = create_wireless_algo_cipher_auth_session(
6209 ts_params->valid_devs[0],
6210 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6211 RTE_CRYPTO_AUTH_OP_VERIFY,
6214 tdata->auth_key.data, tdata->auth_key.len,
6215 tdata->auth_iv.len, tdata->digest_enc.len,
6216 tdata->cipher_iv.len);
6218 retval = create_wireless_algo_auth_cipher_session(
6219 ts_params->valid_devs[0],
6220 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6221 RTE_CRYPTO_AUTH_OP_GENERATE,
6224 tdata->auth_key.data, tdata->auth_key.len,
6225 tdata->auth_iv.len, tdata->digest_enc.len,
6226 tdata->cipher_iv.len);
6230 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6231 if (op_mode == OUT_OF_PLACE)
6232 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6234 /* clear mbuf payload */
6235 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6236 rte_pktmbuf_tailroom(ut_params->ibuf));
6237 if (op_mode == OUT_OF_PLACE)
6238 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6239 rte_pktmbuf_tailroom(ut_params->obuf));
6241 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6242 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6243 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6244 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6247 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6248 ciphertext_pad_len);
6249 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6250 if (op_mode == OUT_OF_PLACE)
6251 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6252 debug_hexdump(stdout, "ciphertext:", ciphertext,
6255 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6257 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6258 if (op_mode == OUT_OF_PLACE)
6259 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6260 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6263 /* Create the operation */
6264 retval = create_wireless_algo_auth_cipher_operation(
6265 tdata->digest_enc.data, tdata->digest_enc.len,
6266 tdata->cipher_iv.data, tdata->cipher_iv.len,
6267 tdata->auth_iv.data, tdata->auth_iv.len,
6268 (tdata->digest_enc.offset == 0 ?
6270 : tdata->digest_enc.offset),
6271 tdata->validCipherLen.len_bits,
6272 tdata->cipher.offset_bits,
6273 tdata->validAuthLen.len_bits,
6274 tdata->auth.offset_bits,
6275 op_mode, 0, verify);
6280 op = process_crypto_request(ts_params->valid_devs[0],
6283 /* Check if the op failed because the device doesn't */
6284 /* support this particular combination of algorithms */
6285 if (op == NULL && ut_params->op->status ==
6286 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6287 printf("Device doesn't support this mixed combination. "
6293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6295 ut_params->obuf = (op_mode == IN_PLACE ?
6296 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6299 if (ut_params->obuf)
6300 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6303 plaintext = ciphertext +
6304 (tdata->cipher.offset_bits >> 3);
6306 debug_hexdump(stdout, "plaintext:", plaintext,
6307 tdata->plaintext.len_bits >> 3);
6308 debug_hexdump(stdout, "plaintext expected:",
6309 tdata->plaintext.data,
6310 tdata->plaintext.len_bits >> 3);
6312 if (ut_params->obuf)
6313 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6316 ciphertext = plaintext;
6318 debug_hexdump(stdout, "ciphertext:", ciphertext,
6320 debug_hexdump(stdout, "ciphertext expected:",
6321 tdata->ciphertext.data,
6322 tdata->ciphertext.len_bits >> 3);
6324 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6325 + (tdata->digest_enc.offset == 0 ?
6326 plaintext_pad_len : tdata->digest_enc.offset);
6328 debug_hexdump(stdout, "digest:", ut_params->digest,
6329 tdata->digest_enc.len);
6330 debug_hexdump(stdout, "digest expected:",
6331 tdata->digest_enc.data,
6332 tdata->digest_enc.len);
6337 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6339 tdata->plaintext.data,
6340 tdata->plaintext.len_bits >> 3,
6341 "Plaintext data not as expected");
6343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6345 tdata->ciphertext.data,
6346 tdata->validDataLen.len_bits,
6347 "Ciphertext data not as expected");
6349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6351 tdata->digest_enc.data,
6352 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6353 "Generated auth tag not as expected");
6356 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6357 "crypto op processing failed");
6363 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6364 uint8_t op_mode, uint8_t verify)
6366 struct crypto_testsuite_params *ts_params = &testsuite_params;
6367 struct crypto_unittest_params *ut_params = &unittest_params;
6371 const uint8_t *plaintext = NULL;
6372 const uint8_t *ciphertext = NULL;
6373 const uint8_t *digest = NULL;
6374 unsigned int plaintext_pad_len;
6375 unsigned int plaintext_len;
6376 unsigned int ciphertext_pad_len;
6377 unsigned int ciphertext_len;
6378 uint8_t buffer[10000];
6379 uint8_t digest_buffer[10000];
6381 struct rte_cryptodev_info dev_info;
6382 struct rte_crypto_op *op;
6384 /* Check if device supports particular algorithms */
6385 if (test_mixed_check_if_unsupported(tdata))
6388 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6390 uint64_t feat_flags = dev_info.feature_flags;
6392 if (op_mode == IN_PLACE) {
6393 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6394 printf("Device doesn't support in-place scatter-gather "
6395 "in both input and output mbufs.\n");
6399 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6400 printf("Device doesn't support out-of-place scatter-gather "
6401 "in both input and output mbufs.\n");
6404 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6405 printf("Device doesn't support digest encrypted.\n");
6410 /* Create the session */
6412 retval = create_wireless_algo_cipher_auth_session(
6413 ts_params->valid_devs[0],
6414 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6415 RTE_CRYPTO_AUTH_OP_VERIFY,
6418 tdata->auth_key.data, tdata->auth_key.len,
6419 tdata->auth_iv.len, tdata->digest_enc.len,
6420 tdata->cipher_iv.len);
6422 retval = create_wireless_algo_auth_cipher_session(
6423 ts_params->valid_devs[0],
6424 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6425 RTE_CRYPTO_AUTH_OP_GENERATE,
6428 tdata->auth_key.data, tdata->auth_key.len,
6429 tdata->auth_iv.len, tdata->digest_enc.len,
6430 tdata->cipher_iv.len);
6434 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6435 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6436 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6437 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6439 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6440 ciphertext_pad_len, 15, 0);
6441 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6442 "Failed to allocate input buffer in mempool");
6444 if (op_mode == OUT_OF_PLACE) {
6445 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6446 plaintext_pad_len, 15, 0);
6447 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6448 "Failed to allocate output buffer in mempool");
6452 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6453 tdata->ciphertext.data);
6454 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6455 ciphertext_len, buffer);
6456 debug_hexdump(stdout, "ciphertext:", ciphertext,
6459 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6460 tdata->plaintext.data);
6461 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6462 plaintext_len, buffer);
6463 debug_hexdump(stdout, "plaintext:", plaintext,
6466 memset(buffer, 0, sizeof(buffer));
6468 /* Create the operation */
6469 retval = create_wireless_algo_auth_cipher_operation(
6470 tdata->digest_enc.data, tdata->digest_enc.len,
6471 tdata->cipher_iv.data, tdata->cipher_iv.len,
6472 tdata->auth_iv.data, tdata->auth_iv.len,
6473 (tdata->digest_enc.offset == 0 ?
6475 : tdata->digest_enc.offset),
6476 tdata->validCipherLen.len_bits,
6477 tdata->cipher.offset_bits,
6478 tdata->validAuthLen.len_bits,
6479 tdata->auth.offset_bits,
6480 op_mode, 1, verify);
6485 op = process_crypto_request(ts_params->valid_devs[0],
6488 /* Check if the op failed because the device doesn't */
6489 /* support this particular combination of algorithms */
6490 if (op == NULL && ut_params->op->status ==
6491 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6492 printf("Device doesn't support this mixed combination. "
6499 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6501 ut_params->obuf = (op_mode == IN_PLACE ?
6502 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6505 if (ut_params->obuf)
6506 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6507 plaintext_len, buffer);
6509 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6510 plaintext_len, buffer);
6512 debug_hexdump(stdout, "plaintext:", plaintext,
6513 (tdata->plaintext.len_bits >> 3) -
6514 tdata->digest_enc.len);
6515 debug_hexdump(stdout, "plaintext expected:",
6516 tdata->plaintext.data,
6517 (tdata->plaintext.len_bits >> 3) -
6518 tdata->digest_enc.len);
6520 if (ut_params->obuf)
6521 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6522 ciphertext_len, buffer);
6524 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6525 ciphertext_len, buffer);
6527 debug_hexdump(stdout, "ciphertext:", ciphertext,
6529 debug_hexdump(stdout, "ciphertext expected:",
6530 tdata->ciphertext.data,
6531 tdata->ciphertext.len_bits >> 3);
6533 if (ut_params->obuf)
6534 digest = rte_pktmbuf_read(ut_params->obuf,
6535 (tdata->digest_enc.offset == 0 ?
6537 tdata->digest_enc.offset),
6538 tdata->digest_enc.len, digest_buffer);
6540 digest = rte_pktmbuf_read(ut_params->ibuf,
6541 (tdata->digest_enc.offset == 0 ?
6543 tdata->digest_enc.offset),
6544 tdata->digest_enc.len, digest_buffer);
6546 debug_hexdump(stdout, "digest:", digest,
6547 tdata->digest_enc.len);
6548 debug_hexdump(stdout, "digest expected:",
6549 tdata->digest_enc.data, tdata->digest_enc.len);
6554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6556 tdata->plaintext.data,
6557 tdata->plaintext.len_bits >> 3,
6558 "Plaintext data not as expected");
6560 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6562 tdata->ciphertext.data,
6563 tdata->validDataLen.len_bits,
6564 "Ciphertext data not as expected");
6565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6567 tdata->digest_enc.data,
6568 tdata->digest_enc.len,
6569 "Generated auth tag not as expected");
6572 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6573 "crypto op processing failed");
6578 /** AUTH AES CMAC + CIPHER AES CTR */
6581 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6583 return test_mixed_auth_cipher(
6584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6588 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6590 return test_mixed_auth_cipher(
6591 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6595 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6597 return test_mixed_auth_cipher_sgl(
6598 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6602 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6604 return test_mixed_auth_cipher_sgl(
6605 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6609 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6611 return test_mixed_auth_cipher(
6612 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6616 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6618 return test_mixed_auth_cipher(
6619 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6623 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6625 return test_mixed_auth_cipher_sgl(
6626 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6630 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6632 return test_mixed_auth_cipher_sgl(
6633 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6636 /** MIXED AUTH + CIPHER */
6639 test_auth_zuc_cipher_snow_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6646 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6653 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6660 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6667 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6669 return test_mixed_auth_cipher(
6670 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6674 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6676 return test_mixed_auth_cipher(
6677 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6681 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6683 return test_mixed_auth_cipher(
6684 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6688 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6690 return test_mixed_auth_cipher(
6691 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6695 test_auth_snow_cipher_zuc_test_case_1(void)
6697 return test_mixed_auth_cipher(
6698 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6702 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6704 return test_mixed_auth_cipher(
6705 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6709 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6711 return test_mixed_auth_cipher(
6712 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6716 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6718 return test_mixed_auth_cipher(
6719 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6723 test_auth_null_cipher_snow_test_case_1(void)
6725 return test_mixed_auth_cipher(
6726 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6730 test_verify_auth_null_cipher_snow_test_case_1(void)
6732 return test_mixed_auth_cipher(
6733 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6737 test_auth_null_cipher_zuc_test_case_1(void)
6739 return test_mixed_auth_cipher(
6740 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6744 test_verify_auth_null_cipher_zuc_test_case_1(void)
6746 return test_mixed_auth_cipher(
6747 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6751 test_auth_snow_cipher_null_test_case_1(void)
6753 return test_mixed_auth_cipher(
6754 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6758 test_verify_auth_snow_cipher_null_test_case_1(void)
6760 return test_mixed_auth_cipher(
6761 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6765 test_auth_zuc_cipher_null_test_case_1(void)
6767 return test_mixed_auth_cipher(
6768 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6772 test_verify_auth_zuc_cipher_null_test_case_1(void)
6774 return test_mixed_auth_cipher(
6775 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6779 test_auth_null_cipher_aes_ctr_test_case_1(void)
6781 return test_mixed_auth_cipher(
6782 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6786 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6788 return test_mixed_auth_cipher(
6789 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6793 test_auth_aes_cmac_cipher_null_test_case_1(void)
6795 return test_mixed_auth_cipher(
6796 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6800 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6802 return test_mixed_auth_cipher(
6803 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6806 /* ***** AEAD algorithm Tests ***** */
6809 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6810 enum rte_crypto_aead_operation op,
6811 const uint8_t *key, const uint8_t key_len,
6812 const uint16_t aad_len, const uint8_t auth_len,
6815 uint8_t aead_key[key_len];
6817 struct crypto_testsuite_params *ts_params = &testsuite_params;
6818 struct crypto_unittest_params *ut_params = &unittest_params;
6820 memcpy(aead_key, key, key_len);
6822 /* Setup AEAD Parameters */
6823 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6824 ut_params->aead_xform.next = NULL;
6825 ut_params->aead_xform.aead.algo = algo;
6826 ut_params->aead_xform.aead.op = op;
6827 ut_params->aead_xform.aead.key.data = aead_key;
6828 ut_params->aead_xform.aead.key.length = key_len;
6829 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6830 ut_params->aead_xform.aead.iv.length = iv_len;
6831 ut_params->aead_xform.aead.digest_length = auth_len;
6832 ut_params->aead_xform.aead.aad_length = aad_len;
6834 debug_hexdump(stdout, "key:", key, key_len);
6836 /* Create Crypto session*/
6837 ut_params->sess = rte_cryptodev_sym_session_create(
6838 ts_params->session_mpool);
6840 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6841 &ut_params->aead_xform,
6842 ts_params->session_priv_mpool);
6844 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6850 create_aead_xform(struct rte_crypto_op *op,
6851 enum rte_crypto_aead_algorithm algo,
6852 enum rte_crypto_aead_operation aead_op,
6853 uint8_t *key, const uint8_t key_len,
6854 const uint8_t aad_len, const uint8_t auth_len,
6857 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6858 "failed to allocate space for crypto transform");
6860 struct rte_crypto_sym_op *sym_op = op->sym;
6862 /* Setup AEAD Parameters */
6863 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6864 sym_op->xform->next = NULL;
6865 sym_op->xform->aead.algo = algo;
6866 sym_op->xform->aead.op = aead_op;
6867 sym_op->xform->aead.key.data = key;
6868 sym_op->xform->aead.key.length = key_len;
6869 sym_op->xform->aead.iv.offset = IV_OFFSET;
6870 sym_op->xform->aead.iv.length = iv_len;
6871 sym_op->xform->aead.digest_length = auth_len;
6872 sym_op->xform->aead.aad_length = aad_len;
6874 debug_hexdump(stdout, "key:", key, key_len);
6880 create_aead_operation(enum rte_crypto_aead_operation op,
6881 const struct aead_test_data *tdata)
6883 struct crypto_testsuite_params *ts_params = &testsuite_params;
6884 struct crypto_unittest_params *ut_params = &unittest_params;
6886 uint8_t *plaintext, *ciphertext;
6887 unsigned int aad_pad_len, plaintext_pad_len;
6889 /* Generate Crypto op data structure */
6890 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6891 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6892 TEST_ASSERT_NOT_NULL(ut_params->op,
6893 "Failed to allocate symmetric crypto operation struct");
6895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6897 /* Append aad data */
6898 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6899 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6900 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6902 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6903 "no room to append aad");
6905 sym_op->aead.aad.phys_addr =
6906 rte_pktmbuf_iova(ut_params->ibuf);
6907 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6908 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6909 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6912 /* Append IV at the end of the crypto operation*/
6913 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6914 uint8_t *, IV_OFFSET);
6916 /* Copy IV 1 byte after the IV pointer, according to the API */
6917 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6918 debug_hexdump(stdout, "iv:", iv_ptr,
6921 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6922 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6924 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6925 "no room to append aad");
6927 sym_op->aead.aad.phys_addr =
6928 rte_pktmbuf_iova(ut_params->ibuf);
6929 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6930 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6933 /* Append IV at the end of the crypto operation*/
6934 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6935 uint8_t *, IV_OFFSET);
6937 if (tdata->iv.len == 0) {
6938 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6939 debug_hexdump(stdout, "iv:", iv_ptr,
6942 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6943 debug_hexdump(stdout, "iv:", iv_ptr,
6948 /* Append plaintext/ciphertext */
6949 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6950 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6953 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6955 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6956 debug_hexdump(stdout, "plaintext:", plaintext,
6957 tdata->plaintext.len);
6959 if (ut_params->obuf) {
6960 ciphertext = (uint8_t *)rte_pktmbuf_append(
6962 plaintext_pad_len + aad_pad_len);
6963 TEST_ASSERT_NOT_NULL(ciphertext,
6964 "no room to append ciphertext");
6966 memset(ciphertext + aad_pad_len, 0,
6967 tdata->ciphertext.len);
6970 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6971 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6973 TEST_ASSERT_NOT_NULL(ciphertext,
6974 "no room to append ciphertext");
6976 memcpy(ciphertext, tdata->ciphertext.data,
6977 tdata->ciphertext.len);
6978 debug_hexdump(stdout, "ciphertext:", ciphertext,
6979 tdata->ciphertext.len);
6981 if (ut_params->obuf) {
6982 plaintext = (uint8_t *)rte_pktmbuf_append(
6984 plaintext_pad_len + aad_pad_len);
6985 TEST_ASSERT_NOT_NULL(plaintext,
6986 "no room to append plaintext");
6988 memset(plaintext + aad_pad_len, 0,
6989 tdata->plaintext.len);
6993 /* Append digest data */
6994 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6995 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6996 ut_params->obuf ? ut_params->obuf :
6998 tdata->auth_tag.len);
6999 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7000 "no room to append digest");
7001 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7002 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7003 ut_params->obuf ? ut_params->obuf :
7008 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7009 ut_params->ibuf, tdata->auth_tag.len);
7010 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7011 "no room to append digest");
7012 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7014 plaintext_pad_len + aad_pad_len);
7016 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7017 tdata->auth_tag.len);
7018 debug_hexdump(stdout, "digest:",
7019 sym_op->aead.digest.data,
7020 tdata->auth_tag.len);
7023 sym_op->aead.data.length = tdata->plaintext.len;
7024 sym_op->aead.data.offset = aad_pad_len;
7030 test_authenticated_encryption(const struct aead_test_data *tdata)
7032 struct crypto_testsuite_params *ts_params = &testsuite_params;
7033 struct crypto_unittest_params *ut_params = &unittest_params;
7036 uint8_t *ciphertext, *auth_tag;
7037 uint16_t plaintext_pad_len;
7040 /* Verify the capabilities */
7041 struct rte_cryptodev_sym_capability_idx cap_idx;
7042 const struct rte_cryptodev_symmetric_capability *capability;
7043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7044 cap_idx.algo.aead = tdata->algo;
7045 capability = rte_cryptodev_sym_capability_get(
7046 ts_params->valid_devs[0], &cap_idx);
7047 if (capability == NULL)
7049 if (rte_cryptodev_sym_capability_check_aead(
7050 capability, tdata->key.len, tdata->auth_tag.len,
7051 tdata->aad.len, tdata->iv.len))
7054 /* Create AEAD session */
7055 retval = create_aead_session(ts_params->valid_devs[0],
7057 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7058 tdata->key.data, tdata->key.len,
7059 tdata->aad.len, tdata->auth_tag.len,
7064 if (tdata->aad.len > MBUF_SIZE) {
7065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7066 /* Populate full size of add data */
7067 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7068 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7072 /* clear mbuf payload */
7073 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7074 rte_pktmbuf_tailroom(ut_params->ibuf));
7076 /* Create AEAD operation */
7077 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7081 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7083 ut_params->op->sym->m_src = ut_params->ibuf;
7085 /* Process crypto operation */
7086 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7087 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7089 TEST_ASSERT_NOT_NULL(
7090 process_crypto_request(ts_params->valid_devs[0],
7091 ut_params->op), "failed to process sym crypto op");
7093 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7094 "crypto op processing failed");
7096 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7098 if (ut_params->op->sym->m_dst) {
7099 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7101 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7102 uint8_t *, plaintext_pad_len);
7104 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7106 ut_params->op->sym->cipher.data.offset);
7107 auth_tag = ciphertext + plaintext_pad_len;
7110 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7111 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7114 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7116 tdata->ciphertext.data,
7117 tdata->ciphertext.len,
7118 "Ciphertext data not as expected");
7120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7122 tdata->auth_tag.data,
7123 tdata->auth_tag.len,
7124 "Generated auth tag not as expected");
7130 #ifdef RTE_LIBRTE_SECURITY
7131 /* Basic algorithm run function for async inplace mode.
7132 * Creates a session from input parameters and runs one operation
7133 * on input_vec. Checks the output of the crypto operation against
7137 test_pdcp_proto(int i, int oop,
7138 enum rte_crypto_cipher_operation opc,
7139 enum rte_crypto_auth_operation opa,
7141 unsigned int input_vec_len,
7142 uint8_t *output_vec,
7143 unsigned int output_vec_len)
7145 struct crypto_testsuite_params *ts_params = &testsuite_params;
7146 struct crypto_unittest_params *ut_params = &unittest_params;
7148 int ret = TEST_SUCCESS;
7149 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7150 rte_cryptodev_get_sec_ctx(
7151 ts_params->valid_devs[0]);
7153 /* Verify the capabilities */
7154 struct rte_security_capability_idx sec_cap_idx;
7156 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7157 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7158 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7159 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7162 /* Generate test mbuf data */
7163 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7165 /* clear mbuf payload */
7166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7167 rte_pktmbuf_tailroom(ut_params->ibuf));
7169 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7171 memcpy(plaintext, input_vec, input_vec_len);
7173 /* Out of place support */
7176 * For out-op-place we need to alloc another mbuf
7178 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7179 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7182 /* Set crypto type as IPSEC */
7183 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7185 /* Setup Cipher Parameters */
7186 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7187 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7188 ut_params->cipher_xform.cipher.op = opc;
7189 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7190 ut_params->cipher_xform.cipher.key.length =
7191 pdcp_test_params[i].cipher_key_len;
7192 ut_params->cipher_xform.cipher.iv.length = 0;
7194 /* Setup HMAC Parameters if ICV header is required */
7195 if (pdcp_test_params[i].auth_alg != 0) {
7196 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7197 ut_params->auth_xform.next = NULL;
7198 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7199 ut_params->auth_xform.auth.op = opa;
7200 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7201 ut_params->auth_xform.auth.key.length =
7202 pdcp_test_params[i].auth_key_len;
7204 ut_params->cipher_xform.next = &ut_params->auth_xform;
7206 ut_params->cipher_xform.next = NULL;
7209 struct rte_security_session_conf sess_conf = {
7210 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7211 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7213 .bearer = pdcp_test_bearer[i],
7214 .domain = pdcp_test_params[i].domain,
7215 .pkt_dir = pdcp_test_packet_direction[i],
7216 .sn_size = pdcp_test_data_sn_size[i],
7217 .hfn = pdcp_test_hfn[i],
7218 .hfn_threshold = pdcp_test_hfn_threshold[i],
7220 .crypto_xform = &ut_params->cipher_xform
7223 /* Create security session */
7224 ut_params->sec_session = rte_security_session_create(ctx,
7225 &sess_conf, ts_params->session_priv_mpool);
7227 if (!ut_params->sec_session) {
7228 printf("TestCase %s()-%d line %d failed %s: ",
7229 __func__, i, __LINE__, "Failed to allocate session");
7234 /* Generate crypto op data structure */
7235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7237 if (!ut_params->op) {
7238 printf("TestCase %s()-%d line %d failed %s: ",
7239 __func__, i, __LINE__,
7240 "Failed to allocate symmetric crypto operation struct");
7245 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7247 /* set crypto operation source mbuf */
7248 ut_params->op->sym->m_src = ut_params->ibuf;
7250 ut_params->op->sym->m_dst = ut_params->obuf;
7252 /* Process crypto operation */
7253 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7255 printf("TestCase %s()-%d line %d failed %s: ",
7256 __func__, i, __LINE__,
7257 "failed to process sym crypto op");
7262 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7263 printf("TestCase %s()-%d line %d failed %s: ",
7264 __func__, i, __LINE__, "crypto op processing failed");
7270 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7273 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7277 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7278 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7279 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7280 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7286 rte_crypto_op_free(ut_params->op);
7287 ut_params->op = NULL;
7289 if (ut_params->sec_session)
7290 rte_security_session_destroy(ctx, ut_params->sec_session);
7291 ut_params->sec_session = NULL;
7293 rte_pktmbuf_free(ut_params->ibuf);
7294 ut_params->ibuf = NULL;
7296 rte_pktmbuf_free(ut_params->obuf);
7297 ut_params->obuf = NULL;
7304 test_pdcp_proto_SGL(int i, int oop,
7305 enum rte_crypto_cipher_operation opc,
7306 enum rte_crypto_auth_operation opa,
7308 unsigned int input_vec_len,
7309 uint8_t *output_vec,
7310 unsigned int output_vec_len,
7312 uint32_t fragsz_oop)
7314 struct crypto_testsuite_params *ts_params = &testsuite_params;
7315 struct crypto_unittest_params *ut_params = &unittest_params;
7317 struct rte_mbuf *buf, *buf_oop = NULL;
7318 int ret = TEST_SUCCESS;
7322 unsigned int trn_data = 0;
7323 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7324 rte_cryptodev_get_sec_ctx(
7325 ts_params->valid_devs[0]);
7327 /* Verify the capabilities */
7328 struct rte_security_capability_idx sec_cap_idx;
7330 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7331 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7332 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7333 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7336 if (fragsz > input_vec_len)
7337 fragsz = input_vec_len;
7339 uint16_t plaintext_len = fragsz;
7340 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7342 if (fragsz_oop > output_vec_len)
7343 frag_size_oop = output_vec_len;
7346 if (input_vec_len % fragsz != 0) {
7347 if (input_vec_len / fragsz + 1 > 16)
7349 } else if (input_vec_len / fragsz > 16)
7352 /* Out of place support */
7355 * For out-op-place we need to alloc another mbuf
7357 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7358 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7359 buf_oop = ut_params->obuf;
7362 /* Generate test mbuf data */
7363 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7365 /* clear mbuf payload */
7366 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7367 rte_pktmbuf_tailroom(ut_params->ibuf));
7369 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7371 memcpy(plaintext, input_vec, plaintext_len);
7372 trn_data += plaintext_len;
7374 buf = ut_params->ibuf;
7377 * Loop until no more fragments
7380 while (trn_data < input_vec_len) {
7382 to_trn = (input_vec_len - trn_data < fragsz) ?
7383 (input_vec_len - trn_data) : fragsz;
7385 to_trn_tbl[ecx++] = to_trn;
7387 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7390 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7391 rte_pktmbuf_tailroom(buf));
7394 if (oop && !fragsz_oop) {
7396 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7397 buf_oop = buf_oop->next;
7398 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7399 0, rte_pktmbuf_tailroom(buf_oop));
7400 rte_pktmbuf_append(buf_oop, to_trn);
7403 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7406 memcpy(plaintext, input_vec + trn_data, to_trn);
7410 ut_params->ibuf->nb_segs = segs;
7413 if (fragsz_oop && oop) {
7417 trn_data = frag_size_oop;
7418 while (trn_data < output_vec_len) {
7421 (output_vec_len - trn_data <
7423 (output_vec_len - trn_data) :
7426 to_trn_tbl[ecx++] = to_trn;
7429 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7430 buf_oop = buf_oop->next;
7431 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7432 0, rte_pktmbuf_tailroom(buf_oop));
7433 rte_pktmbuf_append(buf_oop, to_trn);
7437 ut_params->obuf->nb_segs = segs;
7440 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7442 /* Setup Cipher Parameters */
7443 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7444 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7445 ut_params->cipher_xform.cipher.op = opc;
7446 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7447 ut_params->cipher_xform.cipher.key.length =
7448 pdcp_test_params[i].cipher_key_len;
7449 ut_params->cipher_xform.cipher.iv.length = 0;
7451 /* Setup HMAC Parameters if ICV header is required */
7452 if (pdcp_test_params[i].auth_alg != 0) {
7453 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7454 ut_params->auth_xform.next = NULL;
7455 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7456 ut_params->auth_xform.auth.op = opa;
7457 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7458 ut_params->auth_xform.auth.key.length =
7459 pdcp_test_params[i].auth_key_len;
7461 ut_params->cipher_xform.next = &ut_params->auth_xform;
7463 ut_params->cipher_xform.next = NULL;
7466 struct rte_security_session_conf sess_conf = {
7467 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7468 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7470 .bearer = pdcp_test_bearer[i],
7471 .domain = pdcp_test_params[i].domain,
7472 .pkt_dir = pdcp_test_packet_direction[i],
7473 .sn_size = pdcp_test_data_sn_size[i],
7474 .hfn = pdcp_test_hfn[i],
7475 .hfn_threshold = pdcp_test_hfn_threshold[i],
7477 .crypto_xform = &ut_params->cipher_xform
7480 /* Create security session */
7481 ut_params->sec_session = rte_security_session_create(ctx,
7482 &sess_conf, ts_params->session_priv_mpool);
7484 if (!ut_params->sec_session) {
7485 printf("TestCase %s()-%d line %d failed %s: ",
7486 __func__, i, __LINE__, "Failed to allocate session");
7491 /* Generate crypto op data structure */
7492 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7493 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7494 if (!ut_params->op) {
7495 printf("TestCase %s()-%d line %d failed %s: ",
7496 __func__, i, __LINE__,
7497 "Failed to allocate symmetric crypto operation struct");
7502 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7504 /* set crypto operation source mbuf */
7505 ut_params->op->sym->m_src = ut_params->ibuf;
7507 ut_params->op->sym->m_dst = ut_params->obuf;
7509 /* Process crypto operation */
7510 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7512 printf("TestCase %s()-%d line %d failed %s: ",
7513 __func__, i, __LINE__,
7514 "failed to process sym crypto op");
7519 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7520 printf("TestCase %s()-%d line %d failed %s: ",
7521 __func__, i, __LINE__, "crypto op processing failed");
7527 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7530 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7534 fragsz = frag_size_oop;
7535 if (memcmp(ciphertext, output_vec, fragsz)) {
7536 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7537 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7538 rte_hexdump(stdout, "reference", output_vec, fragsz);
7543 buf = ut_params->op->sym->m_src->next;
7545 buf = ut_params->op->sym->m_dst->next;
7547 unsigned int off = fragsz;
7551 ciphertext = rte_pktmbuf_mtod(buf,
7553 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7554 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7555 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7556 rte_hexdump(stdout, "reference", output_vec + off,
7561 off += to_trn_tbl[ecx++];
7565 rte_crypto_op_free(ut_params->op);
7566 ut_params->op = NULL;
7568 if (ut_params->sec_session)
7569 rte_security_session_destroy(ctx, ut_params->sec_session);
7570 ut_params->sec_session = NULL;
7572 rte_pktmbuf_free(ut_params->ibuf);
7573 ut_params->ibuf = NULL;
7575 rte_pktmbuf_free(ut_params->obuf);
7576 ut_params->obuf = NULL;
7583 test_pdcp_proto_cplane_encap(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7587 RTE_CRYPTO_AUTH_OP_GENERATE,
7588 pdcp_test_data_in[i],
7589 pdcp_test_data_in_len[i],
7590 pdcp_test_data_out[i],
7591 pdcp_test_data_in_len[i]+4);
7595 test_pdcp_proto_uplane_encap(int i)
7597 return test_pdcp_proto(i, 0,
7598 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7599 RTE_CRYPTO_AUTH_OP_GENERATE,
7600 pdcp_test_data_in[i],
7601 pdcp_test_data_in_len[i],
7602 pdcp_test_data_out[i],
7603 pdcp_test_data_in_len[i]);
7608 test_pdcp_proto_uplane_encap_with_int(int i)
7610 return test_pdcp_proto(i, 0,
7611 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7612 RTE_CRYPTO_AUTH_OP_GENERATE,
7613 pdcp_test_data_in[i],
7614 pdcp_test_data_in_len[i],
7615 pdcp_test_data_out[i],
7616 pdcp_test_data_in_len[i] + 4);
7620 test_pdcp_proto_cplane_decap(int i)
7622 return test_pdcp_proto(i, 0,
7623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7624 RTE_CRYPTO_AUTH_OP_VERIFY,
7625 pdcp_test_data_out[i],
7626 pdcp_test_data_in_len[i] + 4,
7627 pdcp_test_data_in[i],
7628 pdcp_test_data_in_len[i]);
7632 test_pdcp_proto_uplane_decap(int i)
7634 return test_pdcp_proto(i, 0,
7635 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7636 RTE_CRYPTO_AUTH_OP_VERIFY,
7637 pdcp_test_data_out[i],
7638 pdcp_test_data_in_len[i],
7639 pdcp_test_data_in[i],
7640 pdcp_test_data_in_len[i]);
7644 test_pdcp_proto_uplane_decap_with_int(int i)
7646 return test_pdcp_proto(i, 0,
7647 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7648 RTE_CRYPTO_AUTH_OP_VERIFY,
7649 pdcp_test_data_out[i],
7650 pdcp_test_data_in_len[i] + 4,
7651 pdcp_test_data_in[i],
7652 pdcp_test_data_in_len[i]);
7656 test_PDCP_PROTO_SGL_in_place_32B(void)
7658 /* i can be used for running any PDCP case
7659 * In this case it is uplane 12-bit AES-SNOW DL encap
7661 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7662 return test_pdcp_proto_SGL(i, IN_PLACE,
7663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 RTE_CRYPTO_AUTH_OP_GENERATE,
7665 pdcp_test_data_in[i],
7666 pdcp_test_data_in_len[i],
7667 pdcp_test_data_out[i],
7668 pdcp_test_data_in_len[i]+4,
7672 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7674 /* i can be used for running any PDCP case
7675 * In this case it is uplane 18-bit NULL-NULL DL encap
7677 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7678 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7679 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7680 RTE_CRYPTO_AUTH_OP_GENERATE,
7681 pdcp_test_data_in[i],
7682 pdcp_test_data_in_len[i],
7683 pdcp_test_data_out[i],
7684 pdcp_test_data_in_len[i]+4,
7688 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7690 /* i can be used for running any PDCP case
7691 * In this case it is uplane 18-bit AES DL encap
7693 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7695 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7697 RTE_CRYPTO_AUTH_OP_GENERATE,
7698 pdcp_test_data_in[i],
7699 pdcp_test_data_in_len[i],
7700 pdcp_test_data_out[i],
7701 pdcp_test_data_in_len[i],
7705 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7707 /* i can be used for running any PDCP case
7708 * In this case it is cplane 12-bit AES-ZUC DL encap
7710 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7711 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7712 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7713 RTE_CRYPTO_AUTH_OP_GENERATE,
7714 pdcp_test_data_in[i],
7715 pdcp_test_data_in_len[i],
7716 pdcp_test_data_out[i],
7717 pdcp_test_data_in_len[i]+4,
7723 test_AES_GCM_authenticated_encryption_test_case_1(void)
7725 return test_authenticated_encryption(&gcm_test_case_1);
7729 test_AES_GCM_authenticated_encryption_test_case_2(void)
7731 return test_authenticated_encryption(&gcm_test_case_2);
7735 test_AES_GCM_authenticated_encryption_test_case_3(void)
7737 return test_authenticated_encryption(&gcm_test_case_3);
7741 test_AES_GCM_authenticated_encryption_test_case_4(void)
7743 return test_authenticated_encryption(&gcm_test_case_4);
7747 test_AES_GCM_authenticated_encryption_test_case_5(void)
7749 return test_authenticated_encryption(&gcm_test_case_5);
7753 test_AES_GCM_authenticated_encryption_test_case_6(void)
7755 return test_authenticated_encryption(&gcm_test_case_6);
7759 test_AES_GCM_authenticated_encryption_test_case_7(void)
7761 return test_authenticated_encryption(&gcm_test_case_7);
7765 test_AES_GCM_authenticated_encryption_test_case_8(void)
7767 return test_authenticated_encryption(&gcm_test_case_8);
7771 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7773 return test_authenticated_encryption(&gcm_J0_test_case_1);
7777 test_AES_GCM_auth_encryption_test_case_192_1(void)
7779 return test_authenticated_encryption(&gcm_test_case_192_1);
7783 test_AES_GCM_auth_encryption_test_case_192_2(void)
7785 return test_authenticated_encryption(&gcm_test_case_192_2);
7789 test_AES_GCM_auth_encryption_test_case_192_3(void)
7791 return test_authenticated_encryption(&gcm_test_case_192_3);
7795 test_AES_GCM_auth_encryption_test_case_192_4(void)
7797 return test_authenticated_encryption(&gcm_test_case_192_4);
7801 test_AES_GCM_auth_encryption_test_case_192_5(void)
7803 return test_authenticated_encryption(&gcm_test_case_192_5);
7807 test_AES_GCM_auth_encryption_test_case_192_6(void)
7809 return test_authenticated_encryption(&gcm_test_case_192_6);
7813 test_AES_GCM_auth_encryption_test_case_192_7(void)
7815 return test_authenticated_encryption(&gcm_test_case_192_7);
7819 test_AES_GCM_auth_encryption_test_case_256_1(void)
7821 return test_authenticated_encryption(&gcm_test_case_256_1);
7825 test_AES_GCM_auth_encryption_test_case_256_2(void)
7827 return test_authenticated_encryption(&gcm_test_case_256_2);
7831 test_AES_GCM_auth_encryption_test_case_256_3(void)
7833 return test_authenticated_encryption(&gcm_test_case_256_3);
7837 test_AES_GCM_auth_encryption_test_case_256_4(void)
7839 return test_authenticated_encryption(&gcm_test_case_256_4);
7843 test_AES_GCM_auth_encryption_test_case_256_5(void)
7845 return test_authenticated_encryption(&gcm_test_case_256_5);
7849 test_AES_GCM_auth_encryption_test_case_256_6(void)
7851 return test_authenticated_encryption(&gcm_test_case_256_6);
7855 test_AES_GCM_auth_encryption_test_case_256_7(void)
7857 return test_authenticated_encryption(&gcm_test_case_256_7);
7861 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7863 return test_authenticated_encryption(&gcm_test_case_aad_1);
7867 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7869 return test_authenticated_encryption(&gcm_test_case_aad_2);
7873 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7875 struct aead_test_data tdata;
7878 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7879 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7880 tdata.iv.data[0] += 1;
7881 res = test_authenticated_encryption(&tdata);
7882 if (res == -ENOTSUP)
7884 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7885 return TEST_SUCCESS;
7889 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7891 struct aead_test_data tdata;
7894 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7895 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7896 tdata.plaintext.data[0] += 1;
7897 res = test_authenticated_encryption(&tdata);
7898 if (res == -ENOTSUP)
7900 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7901 return TEST_SUCCESS;
7905 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7907 struct aead_test_data tdata;
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 tdata.ciphertext.data[0] += 1;
7913 res = test_authenticated_encryption(&tdata);
7914 if (res == -ENOTSUP)
7916 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7917 return TEST_SUCCESS;
7921 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7923 struct aead_test_data tdata;
7926 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7927 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7929 res = test_authenticated_encryption(&tdata);
7930 if (res == -ENOTSUP)
7932 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7933 return TEST_SUCCESS;
7937 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7939 struct aead_test_data tdata;
7940 uint8_t aad[gcm_test_case_7.aad.len];
7943 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7944 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7945 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7947 tdata.aad.data = aad;
7948 res = test_authenticated_encryption(&tdata);
7949 if (res == -ENOTSUP)
7951 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7952 return TEST_SUCCESS;
7956 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7958 struct aead_test_data tdata;
7961 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7962 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7963 tdata.auth_tag.data[0] += 1;
7964 res = test_authenticated_encryption(&tdata);
7965 if (res == -ENOTSUP)
7967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7968 return TEST_SUCCESS;
7972 test_authenticated_decryption(const struct aead_test_data *tdata)
7974 struct crypto_testsuite_params *ts_params = &testsuite_params;
7975 struct crypto_unittest_params *ut_params = &unittest_params;
7981 /* Verify the capabilities */
7982 struct rte_cryptodev_sym_capability_idx cap_idx;
7983 const struct rte_cryptodev_symmetric_capability *capability;
7984 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7985 cap_idx.algo.aead = tdata->algo;
7986 capability = rte_cryptodev_sym_capability_get(
7987 ts_params->valid_devs[0], &cap_idx);
7988 if (capability == NULL)
7990 if (rte_cryptodev_sym_capability_check_aead(
7991 capability, tdata->key.len, tdata->auth_tag.len,
7992 tdata->aad.len, tdata->iv.len))
7995 /* Create AEAD session */
7996 retval = create_aead_session(ts_params->valid_devs[0],
7998 RTE_CRYPTO_AEAD_OP_DECRYPT,
7999 tdata->key.data, tdata->key.len,
8000 tdata->aad.len, tdata->auth_tag.len,
8005 /* alloc mbuf and set payload */
8006 if (tdata->aad.len > MBUF_SIZE) {
8007 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8008 /* Populate full size of add data */
8009 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8010 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8014 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8015 rte_pktmbuf_tailroom(ut_params->ibuf));
8017 /* Create AEAD operation */
8018 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8022 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8024 ut_params->op->sym->m_src = ut_params->ibuf;
8026 /* Process crypto operation */
8027 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8028 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8030 TEST_ASSERT_NOT_NULL(
8031 process_crypto_request(ts_params->valid_devs[0],
8032 ut_params->op), "failed to process sym crypto op");
8034 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8035 "crypto op processing failed");
8037 if (ut_params->op->sym->m_dst)
8038 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8041 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8043 ut_params->op->sym->cipher.data.offset);
8045 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8050 tdata->plaintext.data,
8051 tdata->plaintext.len,
8052 "Plaintext data not as expected");
8054 TEST_ASSERT_EQUAL(ut_params->op->status,
8055 RTE_CRYPTO_OP_STATUS_SUCCESS,
8056 "Authentication failed");
8062 test_AES_GCM_authenticated_decryption_test_case_1(void)
8064 return test_authenticated_decryption(&gcm_test_case_1);
8068 test_AES_GCM_authenticated_decryption_test_case_2(void)
8070 return test_authenticated_decryption(&gcm_test_case_2);
8074 test_AES_GCM_authenticated_decryption_test_case_3(void)
8076 return test_authenticated_decryption(&gcm_test_case_3);
8080 test_AES_GCM_authenticated_decryption_test_case_4(void)
8082 return test_authenticated_decryption(&gcm_test_case_4);
8086 test_AES_GCM_authenticated_decryption_test_case_5(void)
8088 return test_authenticated_decryption(&gcm_test_case_5);
8092 test_AES_GCM_authenticated_decryption_test_case_6(void)
8094 return test_authenticated_decryption(&gcm_test_case_6);
8098 test_AES_GCM_authenticated_decryption_test_case_7(void)
8100 return test_authenticated_decryption(&gcm_test_case_7);
8104 test_AES_GCM_authenticated_decryption_test_case_8(void)
8106 return test_authenticated_decryption(&gcm_test_case_8);
8110 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8112 return test_authenticated_decryption(&gcm_J0_test_case_1);
8116 test_AES_GCM_auth_decryption_test_case_192_1(void)
8118 return test_authenticated_decryption(&gcm_test_case_192_1);
8122 test_AES_GCM_auth_decryption_test_case_192_2(void)
8124 return test_authenticated_decryption(&gcm_test_case_192_2);
8128 test_AES_GCM_auth_decryption_test_case_192_3(void)
8130 return test_authenticated_decryption(&gcm_test_case_192_3);
8134 test_AES_GCM_auth_decryption_test_case_192_4(void)
8136 return test_authenticated_decryption(&gcm_test_case_192_4);
8140 test_AES_GCM_auth_decryption_test_case_192_5(void)
8142 return test_authenticated_decryption(&gcm_test_case_192_5);
8146 test_AES_GCM_auth_decryption_test_case_192_6(void)
8148 return test_authenticated_decryption(&gcm_test_case_192_6);
8152 test_AES_GCM_auth_decryption_test_case_192_7(void)
8154 return test_authenticated_decryption(&gcm_test_case_192_7);
8158 test_AES_GCM_auth_decryption_test_case_256_1(void)
8160 return test_authenticated_decryption(&gcm_test_case_256_1);
8164 test_AES_GCM_auth_decryption_test_case_256_2(void)
8166 return test_authenticated_decryption(&gcm_test_case_256_2);
8170 test_AES_GCM_auth_decryption_test_case_256_3(void)
8172 return test_authenticated_decryption(&gcm_test_case_256_3);
8176 test_AES_GCM_auth_decryption_test_case_256_4(void)
8178 return test_authenticated_decryption(&gcm_test_case_256_4);
8182 test_AES_GCM_auth_decryption_test_case_256_5(void)
8184 return test_authenticated_decryption(&gcm_test_case_256_5);
8188 test_AES_GCM_auth_decryption_test_case_256_6(void)
8190 return test_authenticated_decryption(&gcm_test_case_256_6);
8194 test_AES_GCM_auth_decryption_test_case_256_7(void)
8196 return test_authenticated_decryption(&gcm_test_case_256_7);
8200 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8202 return test_authenticated_decryption(&gcm_test_case_aad_1);
8206 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8208 return test_authenticated_decryption(&gcm_test_case_aad_2);
8212 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8214 struct aead_test_data tdata;
8217 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8218 tdata.iv.data[0] += 1;
8219 res = test_authenticated_decryption(&tdata);
8220 if (res == -ENOTSUP)
8222 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8223 return TEST_SUCCESS;
8227 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8229 struct aead_test_data tdata;
8232 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8233 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8234 tdata.plaintext.data[0] += 1;
8235 res = test_authenticated_decryption(&tdata);
8236 if (res == -ENOTSUP)
8238 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8239 return TEST_SUCCESS;
8243 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8245 struct aead_test_data tdata;
8248 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8249 tdata.ciphertext.data[0] += 1;
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_aad_len_corrupt(void)
8260 struct aead_test_data tdata;
8263 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8265 res = test_authenticated_decryption(&tdata);
8266 if (res == -ENOTSUP)
8268 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8269 return TEST_SUCCESS;
8273 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8275 struct aead_test_data tdata;
8276 uint8_t aad[gcm_test_case_7.aad.len];
8279 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8280 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8282 tdata.aad.data = aad;
8283 res = test_authenticated_decryption(&tdata);
8284 if (res == -ENOTSUP)
8286 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8287 return TEST_SUCCESS;
8291 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8293 struct aead_test_data tdata;
8296 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8297 tdata.auth_tag.data[0] += 1;
8298 res = test_authenticated_decryption(&tdata);
8299 if (res == -ENOTSUP)
8301 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8302 return TEST_SUCCESS;
8306 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8308 struct crypto_testsuite_params *ts_params = &testsuite_params;
8309 struct crypto_unittest_params *ut_params = &unittest_params;
8312 uint8_t *ciphertext, *auth_tag;
8313 uint16_t plaintext_pad_len;
8315 /* Verify the capabilities */
8316 struct rte_cryptodev_sym_capability_idx cap_idx;
8317 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8318 cap_idx.algo.aead = tdata->algo;
8319 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8323 /* not supported with CPU crypto */
8324 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8327 /* Create AEAD session */
8328 retval = create_aead_session(ts_params->valid_devs[0],
8330 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8331 tdata->key.data, tdata->key.len,
8332 tdata->aad.len, tdata->auth_tag.len,
8337 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8338 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8340 /* clear mbuf payload */
8341 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8342 rte_pktmbuf_tailroom(ut_params->ibuf));
8343 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8344 rte_pktmbuf_tailroom(ut_params->obuf));
8346 /* Create AEAD operation */
8347 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8351 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8353 ut_params->op->sym->m_src = ut_params->ibuf;
8354 ut_params->op->sym->m_dst = ut_params->obuf;
8356 /* Process crypto operation */
8357 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8358 ut_params->op), "failed to process sym crypto op");
8360 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8361 "crypto op processing failed");
8363 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8365 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8366 ut_params->op->sym->cipher.data.offset);
8367 auth_tag = ciphertext + plaintext_pad_len;
8369 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8370 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8373 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8375 tdata->ciphertext.data,
8376 tdata->ciphertext.len,
8377 "Ciphertext data not as expected");
8379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8381 tdata->auth_tag.data,
8382 tdata->auth_tag.len,
8383 "Generated auth tag not as expected");
8390 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8392 return test_authenticated_encryption_oop(&gcm_test_case_5);
8396 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8398 struct crypto_testsuite_params *ts_params = &testsuite_params;
8399 struct crypto_unittest_params *ut_params = &unittest_params;
8404 /* Verify the capabilities */
8405 struct rte_cryptodev_sym_capability_idx cap_idx;
8406 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8407 cap_idx.algo.aead = tdata->algo;
8408 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8412 /* not supported with CPU crypto */
8413 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8416 /* Create AEAD session */
8417 retval = create_aead_session(ts_params->valid_devs[0],
8419 RTE_CRYPTO_AEAD_OP_DECRYPT,
8420 tdata->key.data, tdata->key.len,
8421 tdata->aad.len, tdata->auth_tag.len,
8426 /* alloc mbuf and set payload */
8427 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8428 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8430 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8431 rte_pktmbuf_tailroom(ut_params->ibuf));
8432 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8433 rte_pktmbuf_tailroom(ut_params->obuf));
8435 /* Create AEAD operation */
8436 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8440 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8442 ut_params->op->sym->m_src = ut_params->ibuf;
8443 ut_params->op->sym->m_dst = ut_params->obuf;
8445 /* Process crypto operation */
8446 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8447 ut_params->op), "failed to process sym crypto op");
8449 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8450 "crypto op processing failed");
8452 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8453 ut_params->op->sym->cipher.data.offset);
8455 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8458 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8460 tdata->plaintext.data,
8461 tdata->plaintext.len,
8462 "Plaintext data not as expected");
8464 TEST_ASSERT_EQUAL(ut_params->op->status,
8465 RTE_CRYPTO_OP_STATUS_SUCCESS,
8466 "Authentication failed");
8471 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8473 return test_authenticated_decryption_oop(&gcm_test_case_5);
8477 test_authenticated_encryption_sessionless(
8478 const struct aead_test_data *tdata)
8480 struct crypto_testsuite_params *ts_params = &testsuite_params;
8481 struct crypto_unittest_params *ut_params = &unittest_params;
8484 uint8_t *ciphertext, *auth_tag;
8485 uint16_t plaintext_pad_len;
8486 uint8_t key[tdata->key.len + 1];
8487 struct rte_cryptodev_info dev_info;
8489 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8490 uint64_t feat_flags = dev_info.feature_flags;
8492 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8493 printf("Device doesn't support Sessionless ops.\n");
8497 /* not supported with CPU crypto */
8498 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8501 /* Verify the capabilities */
8502 struct rte_cryptodev_sym_capability_idx cap_idx;
8503 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8504 cap_idx.algo.aead = tdata->algo;
8505 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8509 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8511 /* clear mbuf payload */
8512 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8513 rte_pktmbuf_tailroom(ut_params->ibuf));
8515 /* Create AEAD operation */
8516 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8520 /* Create GCM xform */
8521 memcpy(key, tdata->key.data, tdata->key.len);
8522 retval = create_aead_xform(ut_params->op,
8524 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8525 key, tdata->key.len,
8526 tdata->aad.len, tdata->auth_tag.len,
8531 ut_params->op->sym->m_src = ut_params->ibuf;
8533 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8534 RTE_CRYPTO_OP_SESSIONLESS,
8535 "crypto op session type not sessionless");
8537 /* Process crypto operation */
8538 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8539 ut_params->op), "failed to process sym crypto op");
8541 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8543 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8544 "crypto op status not success");
8546 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8548 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8549 ut_params->op->sym->cipher.data.offset);
8550 auth_tag = ciphertext + plaintext_pad_len;
8552 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8553 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8556 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8558 tdata->ciphertext.data,
8559 tdata->ciphertext.len,
8560 "Ciphertext data not as expected");
8562 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8564 tdata->auth_tag.data,
8565 tdata->auth_tag.len,
8566 "Generated auth tag not as expected");
8573 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8575 return test_authenticated_encryption_sessionless(
8580 test_authenticated_decryption_sessionless(
8581 const struct aead_test_data *tdata)
8583 struct crypto_testsuite_params *ts_params = &testsuite_params;
8584 struct crypto_unittest_params *ut_params = &unittest_params;
8588 uint8_t key[tdata->key.len + 1];
8589 struct rte_cryptodev_info dev_info;
8591 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8592 uint64_t feat_flags = dev_info.feature_flags;
8594 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8595 printf("Device doesn't support Sessionless ops.\n");
8599 /* not supported with CPU crypto */
8600 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8603 /* Verify the capabilities */
8604 struct rte_cryptodev_sym_capability_idx cap_idx;
8605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8606 cap_idx.algo.aead = tdata->algo;
8607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8611 /* alloc mbuf and set payload */
8612 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8614 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8615 rte_pktmbuf_tailroom(ut_params->ibuf));
8617 /* Create AEAD operation */
8618 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8622 /* Create AEAD xform */
8623 memcpy(key, tdata->key.data, tdata->key.len);
8624 retval = create_aead_xform(ut_params->op,
8626 RTE_CRYPTO_AEAD_OP_DECRYPT,
8627 key, tdata->key.len,
8628 tdata->aad.len, tdata->auth_tag.len,
8633 ut_params->op->sym->m_src = ut_params->ibuf;
8635 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8636 RTE_CRYPTO_OP_SESSIONLESS,
8637 "crypto op session type not sessionless");
8639 /* Process crypto operation */
8640 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8641 ut_params->op), "failed to process sym crypto op");
8643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8645 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8646 "crypto op status not success");
8648 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8649 ut_params->op->sym->cipher.data.offset);
8651 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8654 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8656 tdata->plaintext.data,
8657 tdata->plaintext.len,
8658 "Plaintext data not as expected");
8660 TEST_ASSERT_EQUAL(ut_params->op->status,
8661 RTE_CRYPTO_OP_STATUS_SUCCESS,
8662 "Authentication failed");
8667 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8669 return test_authenticated_decryption_sessionless(
8674 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8676 return test_authenticated_encryption(&ccm_test_case_128_1);
8680 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8682 return test_authenticated_encryption(&ccm_test_case_128_2);
8686 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8688 return test_authenticated_encryption(&ccm_test_case_128_3);
8692 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8694 return test_authenticated_decryption(&ccm_test_case_128_1);
8698 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8700 return test_authenticated_decryption(&ccm_test_case_128_2);
8704 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8706 return test_authenticated_decryption(&ccm_test_case_128_3);
8710 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8712 return test_authenticated_encryption(&ccm_test_case_192_1);
8716 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8718 return test_authenticated_encryption(&ccm_test_case_192_2);
8722 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8724 return test_authenticated_encryption(&ccm_test_case_192_3);
8728 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8730 return test_authenticated_decryption(&ccm_test_case_192_1);
8734 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8736 return test_authenticated_decryption(&ccm_test_case_192_2);
8740 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8742 return test_authenticated_decryption(&ccm_test_case_192_3);
8746 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8748 return test_authenticated_encryption(&ccm_test_case_256_1);
8752 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8754 return test_authenticated_encryption(&ccm_test_case_256_2);
8758 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8760 return test_authenticated_encryption(&ccm_test_case_256_3);
8764 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8766 return test_authenticated_decryption(&ccm_test_case_256_1);
8770 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8772 return test_authenticated_decryption(&ccm_test_case_256_2);
8776 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8778 return test_authenticated_decryption(&ccm_test_case_256_3);
8784 struct crypto_testsuite_params *ts_params = &testsuite_params;
8785 struct rte_cryptodev_stats stats;
8786 struct rte_cryptodev *dev;
8787 cryptodev_stats_get_t temp_pfn;
8789 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8792 /* Verify the capabilities */
8793 struct rte_cryptodev_sym_capability_idx cap_idx;
8794 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8795 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8796 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8799 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8800 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8801 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8805 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8806 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8807 &stats) == -ENODEV),
8808 "rte_cryptodev_stats_get invalid dev failed");
8809 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8810 "rte_cryptodev_stats_get invalid Param failed");
8811 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8812 temp_pfn = dev->dev_ops->stats_get;
8813 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8814 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8816 "rte_cryptodev_stats_get invalid Param failed");
8817 dev->dev_ops->stats_get = temp_pfn;
8819 /* Test expected values */
8821 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8823 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8825 "rte_cryptodev_stats_get failed");
8826 TEST_ASSERT((stats.enqueued_count == 1),
8827 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8828 TEST_ASSERT((stats.dequeued_count == 1),
8829 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8830 TEST_ASSERT((stats.enqueue_err_count == 0),
8831 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8832 TEST_ASSERT((stats.dequeue_err_count == 0),
8833 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8835 /* invalid device but should ignore and not reset device stats*/
8836 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8837 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8839 "rte_cryptodev_stats_get failed");
8840 TEST_ASSERT((stats.enqueued_count == 1),
8841 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8843 /* check that a valid reset clears stats */
8844 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8845 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8847 "rte_cryptodev_stats_get failed");
8848 TEST_ASSERT((stats.enqueued_count == 0),
8849 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8850 TEST_ASSERT((stats.dequeued_count == 0),
8851 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8853 return TEST_SUCCESS;
8856 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8857 struct crypto_unittest_params *ut_params,
8858 enum rte_crypto_auth_operation op,
8859 const struct HMAC_MD5_vector *test_case)
8863 memcpy(key, test_case->key.data, test_case->key.len);
8865 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8866 ut_params->auth_xform.next = NULL;
8867 ut_params->auth_xform.auth.op = op;
8869 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8871 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8872 ut_params->auth_xform.auth.key.length = test_case->key.len;
8873 ut_params->auth_xform.auth.key.data = key;
8875 ut_params->sess = rte_cryptodev_sym_session_create(
8876 ts_params->session_mpool);
8878 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8879 ut_params->sess, &ut_params->auth_xform,
8880 ts_params->session_priv_mpool);
8882 if (ut_params->sess == NULL)
8885 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8887 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8888 rte_pktmbuf_tailroom(ut_params->ibuf));
8893 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8894 const struct HMAC_MD5_vector *test_case,
8895 uint8_t **plaintext)
8897 uint16_t plaintext_pad_len;
8899 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8901 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8904 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8906 memcpy(*plaintext, test_case->plaintext.data,
8907 test_case->plaintext.len);
8909 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8910 ut_params->ibuf, MD5_DIGEST_LEN);
8911 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8912 "no room to append digest");
8913 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8914 ut_params->ibuf, plaintext_pad_len);
8916 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8917 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8918 test_case->auth_tag.len);
8921 sym_op->auth.data.offset = 0;
8922 sym_op->auth.data.length = test_case->plaintext.len;
8924 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8925 ut_params->op->sym->m_src = ut_params->ibuf;
8931 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8933 uint16_t plaintext_pad_len;
8934 uint8_t *plaintext, *auth_tag;
8936 struct crypto_testsuite_params *ts_params = &testsuite_params;
8937 struct crypto_unittest_params *ut_params = &unittest_params;
8939 /* Verify the capabilities */
8940 struct rte_cryptodev_sym_capability_idx cap_idx;
8941 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8942 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8943 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8947 if (MD5_HMAC_create_session(ts_params, ut_params,
8948 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8951 /* Generate Crypto op data structure */
8952 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8953 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8954 TEST_ASSERT_NOT_NULL(ut_params->op,
8955 "Failed to allocate symmetric crypto operation struct");
8957 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8960 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8963 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8964 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8967 TEST_ASSERT_NOT_NULL(
8968 process_crypto_request(ts_params->valid_devs[0],
8970 "failed to process sym crypto op");
8972 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8973 "crypto op processing failed");
8975 if (ut_params->op->sym->m_dst) {
8976 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8977 uint8_t *, plaintext_pad_len);
8979 auth_tag = plaintext + plaintext_pad_len;
8982 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8984 test_case->auth_tag.data,
8985 test_case->auth_tag.len,
8986 "HMAC_MD5 generated tag not as expected");
8988 return TEST_SUCCESS;
8992 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8996 struct crypto_testsuite_params *ts_params = &testsuite_params;
8997 struct crypto_unittest_params *ut_params = &unittest_params;
8999 /* Verify the capabilities */
9000 struct rte_cryptodev_sym_capability_idx cap_idx;
9001 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9002 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9003 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9007 if (MD5_HMAC_create_session(ts_params, ut_params,
9008 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9012 /* Generate Crypto op data structure */
9013 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9014 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9015 TEST_ASSERT_NOT_NULL(ut_params->op,
9016 "Failed to allocate symmetric crypto operation struct");
9018 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9021 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9022 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9025 TEST_ASSERT_NOT_NULL(
9026 process_crypto_request(ts_params->valid_devs[0],
9028 "failed to process sym crypto op");
9030 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9031 "HMAC_MD5 crypto op processing failed");
9033 return TEST_SUCCESS;
9037 test_MD5_HMAC_generate_case_1(void)
9039 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9043 test_MD5_HMAC_verify_case_1(void)
9045 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9049 test_MD5_HMAC_generate_case_2(void)
9051 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9055 test_MD5_HMAC_verify_case_2(void)
9057 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9061 test_multi_session(void)
9063 struct crypto_testsuite_params *ts_params = &testsuite_params;
9064 struct crypto_unittest_params *ut_params = &unittest_params;
9066 struct rte_cryptodev_info dev_info;
9067 struct rte_cryptodev_sym_session **sessions;
9071 /* Verify the capabilities */
9072 struct rte_cryptodev_sym_capability_idx cap_idx;
9073 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9074 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9075 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9078 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9079 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9080 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9084 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9085 aes_cbc_key, hmac_sha512_key);
9088 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9090 sessions = rte_malloc(NULL,
9091 (sizeof(struct rte_cryptodev_sym_session *) *
9092 MAX_NB_SESSIONS) + 1, 0);
9094 /* Create multiple crypto sessions*/
9095 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9097 sessions[i] = rte_cryptodev_sym_session_create(
9098 ts_params->session_mpool);
9100 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9101 sessions[i], &ut_params->auth_xform,
9102 ts_params->session_priv_mpool);
9103 TEST_ASSERT_NOT_NULL(sessions[i],
9104 "Session creation failed at session number %u",
9107 /* Attempt to send a request on each session */
9108 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9112 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9113 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9115 "Failed to perform decrypt on request number %u.", i);
9116 /* free crypto operation structure */
9118 rte_crypto_op_free(ut_params->op);
9121 * free mbuf - both obuf and ibuf are usually the same,
9122 * so check if they point at the same address is necessary,
9123 * to avoid freeing the mbuf twice.
9125 if (ut_params->obuf) {
9126 rte_pktmbuf_free(ut_params->obuf);
9127 if (ut_params->ibuf == ut_params->obuf)
9128 ut_params->ibuf = 0;
9129 ut_params->obuf = 0;
9131 if (ut_params->ibuf) {
9132 rte_pktmbuf_free(ut_params->ibuf);
9133 ut_params->ibuf = 0;
9137 /* Next session create should fail */
9138 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9139 sessions[i], &ut_params->auth_xform,
9140 ts_params->session_priv_mpool);
9141 TEST_ASSERT_NULL(sessions[i],
9142 "Session creation succeeded unexpectedly!");
9144 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9145 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9147 rte_cryptodev_sym_session_free(sessions[i]);
9152 return TEST_SUCCESS;
9155 struct multi_session_params {
9156 struct crypto_unittest_params ut_params;
9157 uint8_t *cipher_key;
9159 const uint8_t *cipher;
9160 const uint8_t *digest;
9164 #define MB_SESSION_NUMBER 3
9167 test_multi_session_random_usage(void)
9169 struct crypto_testsuite_params *ts_params = &testsuite_params;
9170 struct rte_cryptodev_info dev_info;
9171 struct rte_cryptodev_sym_session **sessions;
9173 struct multi_session_params ut_paramz[] = {
9176 .cipher_key = ms_aes_cbc_key0,
9177 .hmac_key = ms_hmac_key0,
9178 .cipher = ms_aes_cbc_cipher0,
9179 .digest = ms_hmac_digest0,
9180 .iv = ms_aes_cbc_iv0
9183 .cipher_key = ms_aes_cbc_key1,
9184 .hmac_key = ms_hmac_key1,
9185 .cipher = ms_aes_cbc_cipher1,
9186 .digest = ms_hmac_digest1,
9187 .iv = ms_aes_cbc_iv1
9190 .cipher_key = ms_aes_cbc_key2,
9191 .hmac_key = ms_hmac_key2,
9192 .cipher = ms_aes_cbc_cipher2,
9193 .digest = ms_hmac_digest2,
9194 .iv = ms_aes_cbc_iv2
9199 /* Verify the capabilities */
9200 struct rte_cryptodev_sym_capability_idx cap_idx;
9201 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9202 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9206 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9207 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9208 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9212 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9214 sessions = rte_malloc(NULL,
9215 (sizeof(struct rte_cryptodev_sym_session *)
9216 * MAX_NB_SESSIONS) + 1, 0);
9218 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9219 sessions[i] = rte_cryptodev_sym_session_create(
9220 ts_params->session_mpool);
9222 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9223 sizeof(struct crypto_unittest_params));
9225 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9226 &ut_paramz[i].ut_params,
9227 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9229 /* Create multiple crypto sessions*/
9230 rte_cryptodev_sym_session_init(
9231 ts_params->valid_devs[0],
9233 &ut_paramz[i].ut_params.auth_xform,
9234 ts_params->session_priv_mpool);
9236 TEST_ASSERT_NOT_NULL(sessions[i],
9237 "Session creation failed at session number %u",
9243 for (i = 0; i < 40000; i++) {
9245 j = rand() % MB_SESSION_NUMBER;
9247 TEST_ASSERT_SUCCESS(
9248 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9250 &ut_paramz[j].ut_params,
9251 ts_params, ut_paramz[j].cipher,
9252 ut_paramz[j].digest,
9254 "Failed to perform decrypt on request number %u.", i);
9256 if (ut_paramz[j].ut_params.op)
9257 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9260 * free mbuf - both obuf and ibuf are usually the same,
9261 * so check if they point at the same address is necessary,
9262 * to avoid freeing the mbuf twice.
9264 if (ut_paramz[j].ut_params.obuf) {
9265 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9266 if (ut_paramz[j].ut_params.ibuf
9267 == ut_paramz[j].ut_params.obuf)
9268 ut_paramz[j].ut_params.ibuf = 0;
9269 ut_paramz[j].ut_params.obuf = 0;
9271 if (ut_paramz[j].ut_params.ibuf) {
9272 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9273 ut_paramz[j].ut_params.ibuf = 0;
9277 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9278 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9280 rte_cryptodev_sym_session_free(sessions[i]);
9285 return TEST_SUCCESS;
9289 test_null_cipher_only_operation(void)
9291 struct crypto_testsuite_params *ts_params = &testsuite_params;
9292 struct crypto_unittest_params *ut_params = &unittest_params;
9294 /* Verify the capabilities */
9295 struct rte_cryptodev_sym_capability_idx cap_idx;
9296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9297 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9302 /* Generate test mbuf data and space for digest */
9303 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9304 catch_22_quote, QUOTE_512_BYTES, 0);
9306 /* Setup Cipher Parameters */
9307 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9308 ut_params->cipher_xform.next = NULL;
9310 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9311 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9313 ut_params->sess = rte_cryptodev_sym_session_create(
9314 ts_params->session_mpool);
9316 /* Create Crypto session*/
9317 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9319 &ut_params->cipher_xform,
9320 ts_params->session_priv_mpool);
9321 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9323 /* Generate Crypto op data structure */
9324 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9325 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9326 TEST_ASSERT_NOT_NULL(ut_params->op,
9327 "Failed to allocate symmetric crypto operation struct");
9329 /* Set crypto operation data parameters */
9330 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9332 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9334 /* set crypto operation source mbuf */
9335 sym_op->m_src = ut_params->ibuf;
9337 sym_op->cipher.data.offset = 0;
9338 sym_op->cipher.data.length = QUOTE_512_BYTES;
9340 /* Process crypto operation */
9341 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9343 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9345 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9346 "crypto operation processing failed");
9349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9350 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9353 "Ciphertext data not as expected");
9355 return TEST_SUCCESS;
9357 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9358 0xab, 0xab, 0xab, 0xab,
9359 0xab, 0xab, 0xab, 0xab,
9360 0xab, 0xab, 0xab, 0xab};
9362 test_null_auth_only_operation(void)
9364 struct crypto_testsuite_params *ts_params = &testsuite_params;
9365 struct crypto_unittest_params *ut_params = &unittest_params;
9368 /* Verify the capabilities */
9369 struct rte_cryptodev_sym_capability_idx cap_idx;
9370 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9371 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9372 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9376 /* Generate test mbuf data and space for digest */
9377 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9378 catch_22_quote, QUOTE_512_BYTES, 0);
9380 /* create a pointer for digest, but don't expect anything to be written
9381 * here in a NULL auth algo so no mbuf append done.
9383 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9385 /* prefill the memory pointed to by digest */
9386 memcpy(digest, orig_data, sizeof(orig_data));
9388 /* Setup HMAC Parameters */
9389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9390 ut_params->auth_xform.next = NULL;
9392 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9393 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9395 ut_params->sess = rte_cryptodev_sym_session_create(
9396 ts_params->session_mpool);
9398 /* Create Crypto session*/
9399 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9400 ut_params->sess, &ut_params->auth_xform,
9401 ts_params->session_priv_mpool);
9402 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9404 /* Generate Crypto op data structure */
9405 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9406 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9407 TEST_ASSERT_NOT_NULL(ut_params->op,
9408 "Failed to allocate symmetric crypto operation struct");
9410 /* Set crypto operation data parameters */
9411 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9413 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9415 sym_op->m_src = ut_params->ibuf;
9417 sym_op->auth.data.offset = 0;
9418 sym_op->auth.data.length = QUOTE_512_BYTES;
9419 sym_op->auth.digest.data = digest;
9420 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9423 /* Process crypto operation */
9424 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9426 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9428 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9429 "crypto operation processing failed");
9430 /* Make sure memory pointed to by digest hasn't been overwritten */
9431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9435 "Memory at digest ptr overwritten unexpectedly");
9437 return TEST_SUCCESS;
9442 test_null_cipher_auth_operation(void)
9444 struct crypto_testsuite_params *ts_params = &testsuite_params;
9445 struct crypto_unittest_params *ut_params = &unittest_params;
9448 /* Verify the capabilities */
9449 struct rte_cryptodev_sym_capability_idx cap_idx;
9450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9451 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9452 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9455 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9456 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9457 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9461 /* Generate test mbuf data and space for digest */
9462 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9463 catch_22_quote, QUOTE_512_BYTES, 0);
9465 /* create a pointer for digest, but don't expect anything to be written
9466 * here in a NULL auth algo so no mbuf append done.
9468 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9470 /* prefill the memory pointed to by digest */
9471 memcpy(digest, orig_data, sizeof(orig_data));
9473 /* Setup Cipher Parameters */
9474 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9475 ut_params->cipher_xform.next = &ut_params->auth_xform;
9477 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9478 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9480 /* Setup HMAC Parameters */
9481 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9482 ut_params->auth_xform.next = NULL;
9484 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9485 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9487 ut_params->sess = rte_cryptodev_sym_session_create(
9488 ts_params->session_mpool);
9490 /* Create Crypto session*/
9491 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9492 ut_params->sess, &ut_params->cipher_xform,
9493 ts_params->session_priv_mpool);
9494 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9496 /* Generate Crypto op data structure */
9497 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9498 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9499 TEST_ASSERT_NOT_NULL(ut_params->op,
9500 "Failed to allocate symmetric crypto operation struct");
9502 /* Set crypto operation data parameters */
9503 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9505 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9507 sym_op->m_src = ut_params->ibuf;
9509 sym_op->cipher.data.offset = 0;
9510 sym_op->cipher.data.length = QUOTE_512_BYTES;
9512 sym_op->auth.data.offset = 0;
9513 sym_op->auth.data.length = QUOTE_512_BYTES;
9514 sym_op->auth.digest.data = digest;
9515 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9518 /* Process crypto operation */
9519 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9521 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9523 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9524 "crypto operation processing failed");
9527 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9528 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9531 "Ciphertext data not as expected");
9532 /* Make sure memory pointed to by digest hasn't been overwritten */
9533 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9537 "Memory at digest ptr overwritten unexpectedly");
9539 return TEST_SUCCESS;
9543 test_null_auth_cipher_operation(void)
9545 struct crypto_testsuite_params *ts_params = &testsuite_params;
9546 struct crypto_unittest_params *ut_params = &unittest_params;
9549 /* Verify the capabilities */
9550 struct rte_cryptodev_sym_capability_idx cap_idx;
9551 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9552 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9553 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9556 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9557 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9558 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9562 /* Generate test mbuf data */
9563 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9564 catch_22_quote, QUOTE_512_BYTES, 0);
9566 /* create a pointer for digest, but don't expect anything to be written
9567 * here in a NULL auth algo so no mbuf append done.
9569 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9571 /* prefill the memory pointed to by digest */
9572 memcpy(digest, orig_data, sizeof(orig_data));
9574 /* Setup Cipher Parameters */
9575 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9576 ut_params->cipher_xform.next = NULL;
9578 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9579 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9581 /* Setup HMAC Parameters */
9582 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9583 ut_params->auth_xform.next = &ut_params->cipher_xform;
9585 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9586 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9588 ut_params->sess = rte_cryptodev_sym_session_create(
9589 ts_params->session_mpool);
9591 /* Create Crypto session*/
9592 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9593 ut_params->sess, &ut_params->cipher_xform,
9594 ts_params->session_priv_mpool);
9595 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9597 /* Generate Crypto op data structure */
9598 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9599 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9600 TEST_ASSERT_NOT_NULL(ut_params->op,
9601 "Failed to allocate symmetric crypto operation struct");
9603 /* Set crypto operation data parameters */
9604 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9606 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9608 sym_op->m_src = ut_params->ibuf;
9610 sym_op->cipher.data.offset = 0;
9611 sym_op->cipher.data.length = QUOTE_512_BYTES;
9613 sym_op->auth.data.offset = 0;
9614 sym_op->auth.data.length = QUOTE_512_BYTES;
9615 sym_op->auth.digest.data = digest;
9616 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9619 /* Process crypto operation */
9620 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9622 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9624 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9625 "crypto operation processing failed");
9628 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9629 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9632 "Ciphertext data not as expected");
9633 /* Make sure memory pointed to by digest hasn't been overwritten */
9634 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9638 "Memory at digest ptr overwritten unexpectedly");
9640 return TEST_SUCCESS;
9645 test_null_invalid_operation(void)
9647 struct crypto_testsuite_params *ts_params = &testsuite_params;
9648 struct crypto_unittest_params *ut_params = &unittest_params;
9651 /* This test is for NULL PMD only */
9652 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9653 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9656 /* Setup Cipher Parameters */
9657 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9658 ut_params->cipher_xform.next = NULL;
9660 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9661 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9663 ut_params->sess = rte_cryptodev_sym_session_create(
9664 ts_params->session_mpool);
9666 /* Create Crypto session*/
9667 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9668 ut_params->sess, &ut_params->cipher_xform,
9669 ts_params->session_priv_mpool);
9670 TEST_ASSERT(ret < 0,
9671 "Session creation succeeded unexpectedly");
9674 /* Setup HMAC Parameters */
9675 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9676 ut_params->auth_xform.next = NULL;
9678 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9679 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9681 ut_params->sess = rte_cryptodev_sym_session_create(
9682 ts_params->session_mpool);
9684 /* Create Crypto session*/
9685 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9686 ut_params->sess, &ut_params->auth_xform,
9687 ts_params->session_priv_mpool);
9688 TEST_ASSERT(ret < 0,
9689 "Session creation succeeded unexpectedly");
9691 return TEST_SUCCESS;
9695 #define NULL_BURST_LENGTH (32)
9698 test_null_burst_operation(void)
9700 struct crypto_testsuite_params *ts_params = &testsuite_params;
9701 struct crypto_unittest_params *ut_params = &unittest_params;
9703 unsigned i, burst_len = NULL_BURST_LENGTH;
9705 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9706 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9708 /* This test is for NULL PMD only */
9709 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9710 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9713 /* Setup Cipher Parameters */
9714 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9715 ut_params->cipher_xform.next = &ut_params->auth_xform;
9717 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9718 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9720 /* Setup HMAC Parameters */
9721 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9722 ut_params->auth_xform.next = NULL;
9724 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9725 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9727 ut_params->sess = rte_cryptodev_sym_session_create(
9728 ts_params->session_mpool);
9730 /* Create Crypto session*/
9731 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9732 ut_params->sess, &ut_params->cipher_xform,
9733 ts_params->session_priv_mpool);
9734 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9736 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9737 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9738 burst_len, "failed to generate burst of crypto ops");
9740 /* Generate an operation for each mbuf in burst */
9741 for (i = 0; i < burst_len; i++) {
9742 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9744 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9746 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9750 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9752 burst[i]->sym->m_src = m;
9755 /* Process crypto operation */
9756 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9757 0, burst, burst_len),
9759 "Error enqueuing burst");
9761 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9762 0, burst_dequeued, burst_len),
9764 "Error dequeuing burst");
9767 for (i = 0; i < burst_len; i++) {
9769 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9770 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9772 "data not as expected");
9774 rte_pktmbuf_free(burst[i]->sym->m_src);
9775 rte_crypto_op_free(burst[i]);
9778 return TEST_SUCCESS;
9782 generate_gmac_large_plaintext(uint8_t *data)
9786 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9787 memcpy(&data[i], &data[0], 32);
9791 create_gmac_operation(enum rte_crypto_auth_operation op,
9792 const struct gmac_test_data *tdata)
9794 struct crypto_testsuite_params *ts_params = &testsuite_params;
9795 struct crypto_unittest_params *ut_params = &unittest_params;
9796 struct rte_crypto_sym_op *sym_op;
9798 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9800 /* Generate Crypto op data structure */
9801 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9802 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9803 TEST_ASSERT_NOT_NULL(ut_params->op,
9804 "Failed to allocate symmetric crypto operation struct");
9806 sym_op = ut_params->op->sym;
9808 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9809 ut_params->ibuf, tdata->gmac_tag.len);
9810 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9811 "no room to append digest");
9813 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9814 ut_params->ibuf, plaintext_pad_len);
9816 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9817 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9818 tdata->gmac_tag.len);
9819 debug_hexdump(stdout, "digest:",
9820 sym_op->auth.digest.data,
9821 tdata->gmac_tag.len);
9824 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9825 uint8_t *, IV_OFFSET);
9827 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9829 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9831 sym_op->cipher.data.length = 0;
9832 sym_op->cipher.data.offset = 0;
9834 sym_op->auth.data.offset = 0;
9835 sym_op->auth.data.length = tdata->plaintext.len;
9840 static int create_gmac_session(uint8_t dev_id,
9841 const struct gmac_test_data *tdata,
9842 enum rte_crypto_auth_operation auth_op)
9844 uint8_t auth_key[tdata->key.len];
9846 struct crypto_testsuite_params *ts_params = &testsuite_params;
9847 struct crypto_unittest_params *ut_params = &unittest_params;
9849 memcpy(auth_key, tdata->key.data, tdata->key.len);
9851 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9852 ut_params->auth_xform.next = NULL;
9854 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9855 ut_params->auth_xform.auth.op = auth_op;
9856 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9857 ut_params->auth_xform.auth.key.length = tdata->key.len;
9858 ut_params->auth_xform.auth.key.data = auth_key;
9859 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9860 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9863 ut_params->sess = rte_cryptodev_sym_session_create(
9864 ts_params->session_mpool);
9866 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9867 &ut_params->auth_xform,
9868 ts_params->session_priv_mpool);
9870 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9876 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9878 struct crypto_testsuite_params *ts_params = &testsuite_params;
9879 struct crypto_unittest_params *ut_params = &unittest_params;
9883 uint8_t *auth_tag, *plaintext;
9884 uint16_t plaintext_pad_len;
9886 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9887 "No GMAC length in the source data");
9889 /* Verify the capabilities */
9890 struct rte_cryptodev_sym_capability_idx cap_idx;
9891 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9892 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9893 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9897 retval = create_gmac_session(ts_params->valid_devs[0],
9898 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9903 if (tdata->plaintext.len > MBUF_SIZE)
9904 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9907 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9908 "Failed to allocate input buffer in mempool");
9910 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9911 rte_pktmbuf_tailroom(ut_params->ibuf));
9913 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9915 * Runtime generate the large plain text instead of use hard code
9916 * plain text vector. It is done to avoid create huge source file
9917 * with the test vector.
9919 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9920 generate_gmac_large_plaintext(tdata->plaintext.data);
9922 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9924 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9926 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9927 debug_hexdump(stdout, "plaintext:", plaintext,
9928 tdata->plaintext.len);
9930 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9936 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9938 ut_params->op->sym->m_src = ut_params->ibuf;
9940 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9941 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9944 TEST_ASSERT_NOT_NULL(
9945 process_crypto_request(ts_params->valid_devs[0],
9946 ut_params->op), "failed to process sym crypto op");
9948 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9949 "crypto op processing failed");
9951 if (ut_params->op->sym->m_dst) {
9952 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9953 uint8_t *, plaintext_pad_len);
9955 auth_tag = plaintext + plaintext_pad_len;
9958 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9962 tdata->gmac_tag.data,
9963 tdata->gmac_tag.len,
9964 "GMAC Generated auth tag not as expected");
9970 test_AES_GMAC_authentication_test_case_1(void)
9972 return test_AES_GMAC_authentication(&gmac_test_case_1);
9976 test_AES_GMAC_authentication_test_case_2(void)
9978 return test_AES_GMAC_authentication(&gmac_test_case_2);
9982 test_AES_GMAC_authentication_test_case_3(void)
9984 return test_AES_GMAC_authentication(&gmac_test_case_3);
9988 test_AES_GMAC_authentication_test_case_4(void)
9990 return test_AES_GMAC_authentication(&gmac_test_case_4);
9994 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9996 struct crypto_testsuite_params *ts_params = &testsuite_params;
9997 struct crypto_unittest_params *ut_params = &unittest_params;
9999 uint32_t plaintext_pad_len;
10000 uint8_t *plaintext;
10002 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10003 "No GMAC length in the source data");
10005 /* Verify the capabilities */
10006 struct rte_cryptodev_sym_capability_idx cap_idx;
10007 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10008 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10009 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10013 retval = create_gmac_session(ts_params->valid_devs[0],
10014 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10019 if (tdata->plaintext.len > MBUF_SIZE)
10020 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10022 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10023 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10024 "Failed to allocate input buffer in mempool");
10026 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10027 rte_pktmbuf_tailroom(ut_params->ibuf));
10029 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10032 * Runtime generate the large plain text instead of use hard code
10033 * plain text vector. It is done to avoid create huge source file
10034 * with the test vector.
10036 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10037 generate_gmac_large_plaintext(tdata->plaintext.data);
10039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10040 plaintext_pad_len);
10041 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10043 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10044 debug_hexdump(stdout, "plaintext:", plaintext,
10045 tdata->plaintext.len);
10047 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10053 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10055 ut_params->op->sym->m_src = ut_params->ibuf;
10057 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10058 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10061 TEST_ASSERT_NOT_NULL(
10062 process_crypto_request(ts_params->valid_devs[0],
10063 ut_params->op), "failed to process sym crypto op");
10065 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10066 "crypto op processing failed");
10073 test_AES_GMAC_authentication_verify_test_case_1(void)
10075 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10079 test_AES_GMAC_authentication_verify_test_case_2(void)
10081 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10085 test_AES_GMAC_authentication_verify_test_case_3(void)
10087 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10091 test_AES_GMAC_authentication_verify_test_case_4(void)
10093 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10096 struct test_crypto_vector {
10097 enum rte_crypto_cipher_algorithm crypto_algo;
10098 unsigned int cipher_offset;
10099 unsigned int cipher_len;
10112 const uint8_t *data;
10117 const uint8_t *data;
10121 enum rte_crypto_auth_algorithm auth_algo;
10122 unsigned int auth_offset;
10130 const uint8_t *data;
10140 static const struct test_crypto_vector
10141 hmac_sha1_test_crypto_vector = {
10142 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10144 .data = plaintext_hash,
10149 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10150 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10151 0xDE, 0xF4, 0xDE, 0xAD
10157 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10158 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10159 0x3F, 0x91, 0x64, 0x59
10165 static const struct test_crypto_vector
10166 aes128_gmac_test_vector = {
10167 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10169 .data = plaintext_hash,
10174 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10175 0x08, 0x09, 0x0A, 0x0B
10181 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10182 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10188 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10189 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10195 static const struct test_crypto_vector
10196 aes128cbc_hmac_sha1_test_vector = {
10197 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10198 .cipher_offset = 0,
10202 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10203 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10209 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10210 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10215 .data = plaintext_hash,
10219 .data = ciphertext512_aes128cbc,
10222 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10226 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10227 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10228 0xDE, 0xF4, 0xDE, 0xAD
10234 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10235 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10236 0x18, 0x8C, 0x1D, 0x32
10242 static const struct test_crypto_vector
10243 aes128cbc_hmac_sha1_aad_test_vector = {
10244 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10245 .cipher_offset = 12,
10249 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10250 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10256 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10257 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10262 .data = plaintext_hash,
10266 .data = ciphertext512_aes128cbc_aad,
10269 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10273 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10274 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10275 0xDE, 0xF4, 0xDE, 0xAD
10281 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10282 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10283 0x62, 0x8D, 0x62, 0x65
10290 data_corruption(uint8_t *data)
10296 tag_corruption(uint8_t *data, unsigned int tag_offset)
10298 data[tag_offset] += 1;
10302 create_auth_session(struct crypto_unittest_params *ut_params,
10304 const struct test_crypto_vector *reference,
10305 enum rte_crypto_auth_operation auth_op)
10307 struct crypto_testsuite_params *ts_params = &testsuite_params;
10308 uint8_t auth_key[reference->auth_key.len + 1];
10310 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10312 /* Setup Authentication Parameters */
10313 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10314 ut_params->auth_xform.auth.op = auth_op;
10315 ut_params->auth_xform.next = NULL;
10316 ut_params->auth_xform.auth.algo = reference->auth_algo;
10317 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10318 ut_params->auth_xform.auth.key.data = auth_key;
10319 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10321 /* Create Crypto session*/
10322 ut_params->sess = rte_cryptodev_sym_session_create(
10323 ts_params->session_mpool);
10325 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10326 &ut_params->auth_xform,
10327 ts_params->session_priv_mpool);
10329 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10335 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10337 const struct test_crypto_vector *reference,
10338 enum rte_crypto_auth_operation auth_op,
10339 enum rte_crypto_cipher_operation cipher_op)
10341 struct crypto_testsuite_params *ts_params = &testsuite_params;
10342 uint8_t cipher_key[reference->cipher_key.len + 1];
10343 uint8_t auth_key[reference->auth_key.len + 1];
10345 memcpy(cipher_key, reference->cipher_key.data,
10346 reference->cipher_key.len);
10347 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10349 /* Setup Authentication Parameters */
10350 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10351 ut_params->auth_xform.auth.op = auth_op;
10352 ut_params->auth_xform.auth.algo = reference->auth_algo;
10353 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10354 ut_params->auth_xform.auth.key.data = auth_key;
10355 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10357 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10358 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10359 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10361 ut_params->auth_xform.next = &ut_params->cipher_xform;
10363 /* Setup Cipher Parameters */
10364 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10365 ut_params->cipher_xform.next = NULL;
10366 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10367 ut_params->cipher_xform.cipher.op = cipher_op;
10368 ut_params->cipher_xform.cipher.key.data = cipher_key;
10369 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10370 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10371 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10374 /* Create Crypto session*/
10375 ut_params->sess = rte_cryptodev_sym_session_create(
10376 ts_params->session_mpool);
10378 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10379 &ut_params->auth_xform,
10380 ts_params->session_priv_mpool);
10382 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10388 create_auth_operation(struct crypto_testsuite_params *ts_params,
10389 struct crypto_unittest_params *ut_params,
10390 const struct test_crypto_vector *reference,
10391 unsigned int auth_generate)
10393 /* Generate Crypto op data structure */
10394 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10395 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10396 TEST_ASSERT_NOT_NULL(ut_params->op,
10397 "Failed to allocate pktmbuf offload");
10399 /* Set crypto operation data parameters */
10400 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10402 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10404 /* set crypto operation source mbuf */
10405 sym_op->m_src = ut_params->ibuf;
10408 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10409 ut_params->ibuf, reference->digest.len);
10411 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10412 "no room to append auth tag");
10414 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10415 ut_params->ibuf, reference->plaintext.len);
10418 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10420 memcpy(sym_op->auth.digest.data,
10421 reference->digest.data,
10422 reference->digest.len);
10424 debug_hexdump(stdout, "digest:",
10425 sym_op->auth.digest.data,
10426 reference->digest.len);
10428 sym_op->auth.data.length = reference->plaintext.len;
10429 sym_op->auth.data.offset = 0;
10435 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10436 struct crypto_unittest_params *ut_params,
10437 const struct test_crypto_vector *reference,
10438 unsigned int auth_generate)
10440 /* Generate Crypto op data structure */
10441 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10442 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10443 TEST_ASSERT_NOT_NULL(ut_params->op,
10444 "Failed to allocate pktmbuf offload");
10446 /* Set crypto operation data parameters */
10447 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10449 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10451 /* set crypto operation source mbuf */
10452 sym_op->m_src = ut_params->ibuf;
10455 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10456 ut_params->ibuf, reference->digest.len);
10458 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10459 "no room to append auth tag");
10461 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10462 ut_params->ibuf, reference->ciphertext.len);
10465 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10467 memcpy(sym_op->auth.digest.data,
10468 reference->digest.data,
10469 reference->digest.len);
10471 debug_hexdump(stdout, "digest:",
10472 sym_op->auth.digest.data,
10473 reference->digest.len);
10475 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10476 reference->iv.data, reference->iv.len);
10478 sym_op->cipher.data.length = 0;
10479 sym_op->cipher.data.offset = 0;
10481 sym_op->auth.data.length = reference->plaintext.len;
10482 sym_op->auth.data.offset = 0;
10488 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10489 struct crypto_unittest_params *ut_params,
10490 const struct test_crypto_vector *reference,
10491 unsigned int auth_generate)
10493 /* Generate Crypto op data structure */
10494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10496 TEST_ASSERT_NOT_NULL(ut_params->op,
10497 "Failed to allocate pktmbuf offload");
10499 /* Set crypto operation data parameters */
10500 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10502 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10504 /* set crypto operation source mbuf */
10505 sym_op->m_src = ut_params->ibuf;
10508 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10509 ut_params->ibuf, reference->digest.len);
10511 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10512 "no room to append auth tag");
10514 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10515 ut_params->ibuf, reference->ciphertext.len);
10518 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10520 memcpy(sym_op->auth.digest.data,
10521 reference->digest.data,
10522 reference->digest.len);
10524 debug_hexdump(stdout, "digest:",
10525 sym_op->auth.digest.data,
10526 reference->digest.len);
10528 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10529 reference->iv.data, reference->iv.len);
10531 sym_op->cipher.data.length = reference->cipher_len;
10532 sym_op->cipher.data.offset = reference->cipher_offset;
10534 sym_op->auth.data.length = reference->plaintext.len;
10535 sym_op->auth.data.offset = reference->auth_offset;
10541 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10542 struct crypto_unittest_params *ut_params,
10543 const struct test_crypto_vector *reference)
10545 return create_auth_operation(ts_params, ut_params, reference, 0);
10549 create_auth_verify_GMAC_operation(
10550 struct crypto_testsuite_params *ts_params,
10551 struct crypto_unittest_params *ut_params,
10552 const struct test_crypto_vector *reference)
10554 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10558 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10559 struct crypto_unittest_params *ut_params,
10560 const struct test_crypto_vector *reference)
10562 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10566 test_authentication_verify_fail_when_data_corruption(
10567 struct crypto_testsuite_params *ts_params,
10568 struct crypto_unittest_params *ut_params,
10569 const struct test_crypto_vector *reference,
10570 unsigned int data_corrupted)
10574 uint8_t *plaintext;
10576 /* Verify the capabilities */
10577 struct rte_cryptodev_sym_capability_idx cap_idx;
10578 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10579 cap_idx.algo.auth = reference->auth_algo;
10580 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10584 /* Create session */
10585 retval = create_auth_session(ut_params,
10586 ts_params->valid_devs[0],
10588 RTE_CRYPTO_AUTH_OP_VERIFY);
10592 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10593 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10594 "Failed to allocate input buffer in mempool");
10596 /* clear mbuf payload */
10597 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10598 rte_pktmbuf_tailroom(ut_params->ibuf));
10600 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10601 reference->plaintext.len);
10602 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10603 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10605 debug_hexdump(stdout, "plaintext:", plaintext,
10606 reference->plaintext.len);
10608 /* Create operation */
10609 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10614 if (data_corrupted)
10615 data_corruption(plaintext);
10617 tag_corruption(plaintext, reference->plaintext.len);
10619 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10620 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10622 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10623 RTE_CRYPTO_OP_STATUS_SUCCESS,
10624 "authentication not failed");
10626 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10628 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10635 test_authentication_verify_GMAC_fail_when_corruption(
10636 struct crypto_testsuite_params *ts_params,
10637 struct crypto_unittest_params *ut_params,
10638 const struct test_crypto_vector *reference,
10639 unsigned int data_corrupted)
10642 uint8_t *plaintext;
10644 /* Verify the capabilities */
10645 struct rte_cryptodev_sym_capability_idx cap_idx;
10646 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10647 cap_idx.algo.auth = reference->auth_algo;
10648 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10652 /* Create session */
10653 retval = create_auth_cipher_session(ut_params,
10654 ts_params->valid_devs[0],
10656 RTE_CRYPTO_AUTH_OP_VERIFY,
10657 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10661 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10662 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10663 "Failed to allocate input buffer in mempool");
10665 /* clear mbuf payload */
10666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10667 rte_pktmbuf_tailroom(ut_params->ibuf));
10669 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10670 reference->plaintext.len);
10671 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10672 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10674 debug_hexdump(stdout, "plaintext:", plaintext,
10675 reference->plaintext.len);
10677 /* Create operation */
10678 retval = create_auth_verify_GMAC_operation(ts_params,
10685 if (data_corrupted)
10686 data_corruption(plaintext);
10688 tag_corruption(plaintext, reference->aad.len);
10690 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10691 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10693 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10694 RTE_CRYPTO_OP_STATUS_SUCCESS,
10695 "authentication not failed");
10697 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10699 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10706 test_authenticated_decryption_fail_when_corruption(
10707 struct crypto_testsuite_params *ts_params,
10708 struct crypto_unittest_params *ut_params,
10709 const struct test_crypto_vector *reference,
10710 unsigned int data_corrupted)
10714 uint8_t *ciphertext;
10716 /* Verify the capabilities */
10717 struct rte_cryptodev_sym_capability_idx cap_idx;
10718 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10719 cap_idx.algo.auth = reference->auth_algo;
10720 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10723 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10724 cap_idx.algo.cipher = reference->crypto_algo;
10725 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10729 /* Create session */
10730 retval = create_auth_cipher_session(ut_params,
10731 ts_params->valid_devs[0],
10733 RTE_CRYPTO_AUTH_OP_VERIFY,
10734 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10738 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10739 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10740 "Failed to allocate input buffer in mempool");
10742 /* clear mbuf payload */
10743 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10744 rte_pktmbuf_tailroom(ut_params->ibuf));
10746 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10747 reference->ciphertext.len);
10748 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10749 memcpy(ciphertext, reference->ciphertext.data,
10750 reference->ciphertext.len);
10752 /* Create operation */
10753 retval = create_cipher_auth_verify_operation(ts_params,
10760 if (data_corrupted)
10761 data_corruption(ciphertext);
10763 tag_corruption(ciphertext, reference->ciphertext.len);
10765 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10766 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10768 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10769 RTE_CRYPTO_OP_STATUS_SUCCESS,
10770 "authentication not failed");
10772 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10774 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10781 test_authenticated_encryt_with_esn(
10782 struct crypto_testsuite_params *ts_params,
10783 struct crypto_unittest_params *ut_params,
10784 const struct test_crypto_vector *reference)
10788 uint8_t *authciphertext, *plaintext, *auth_tag;
10789 uint16_t plaintext_pad_len;
10790 uint8_t cipher_key[reference->cipher_key.len + 1];
10791 uint8_t auth_key[reference->auth_key.len + 1];
10793 /* Verify the capabilities */
10794 struct rte_cryptodev_sym_capability_idx cap_idx;
10795 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10796 cap_idx.algo.auth = reference->auth_algo;
10797 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10800 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10801 cap_idx.algo.cipher = reference->crypto_algo;
10802 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10806 /* Create session */
10807 memcpy(cipher_key, reference->cipher_key.data,
10808 reference->cipher_key.len);
10809 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10811 /* Setup Cipher Parameters */
10812 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10813 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10814 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10815 ut_params->cipher_xform.cipher.key.data = cipher_key;
10816 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10817 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10818 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10820 ut_params->cipher_xform.next = &ut_params->auth_xform;
10822 /* Setup Authentication Parameters */
10823 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10824 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10825 ut_params->auth_xform.auth.algo = reference->auth_algo;
10826 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10827 ut_params->auth_xform.auth.key.data = auth_key;
10828 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10829 ut_params->auth_xform.next = NULL;
10831 /* Create Crypto session*/
10832 ut_params->sess = rte_cryptodev_sym_session_create(
10833 ts_params->session_mpool);
10835 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10837 &ut_params->cipher_xform,
10838 ts_params->session_priv_mpool);
10840 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10842 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10843 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10844 "Failed to allocate input buffer in mempool");
10846 /* clear mbuf payload */
10847 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10848 rte_pktmbuf_tailroom(ut_params->ibuf));
10850 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10851 reference->plaintext.len);
10852 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10853 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10855 /* Create operation */
10856 retval = create_cipher_auth_operation(ts_params,
10863 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10864 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10867 ut_params->op = process_crypto_request(
10868 ts_params->valid_devs[0], ut_params->op);
10870 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10872 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10873 "crypto op processing failed");
10875 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10877 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10878 ut_params->op->sym->auth.data.offset);
10879 auth_tag = authciphertext + plaintext_pad_len;
10880 debug_hexdump(stdout, "ciphertext:", authciphertext,
10881 reference->ciphertext.len);
10882 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10884 /* Validate obuf */
10885 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10887 reference->ciphertext.data,
10888 reference->ciphertext.len,
10889 "Ciphertext data not as expected");
10891 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10893 reference->digest.data,
10894 reference->digest.len,
10895 "Generated digest not as expected");
10897 return TEST_SUCCESS;
10902 test_authenticated_decrypt_with_esn(
10903 struct crypto_testsuite_params *ts_params,
10904 struct crypto_unittest_params *ut_params,
10905 const struct test_crypto_vector *reference)
10909 uint8_t *ciphertext;
10910 uint8_t cipher_key[reference->cipher_key.len + 1];
10911 uint8_t auth_key[reference->auth_key.len + 1];
10913 /* Verify the capabilities */
10914 struct rte_cryptodev_sym_capability_idx cap_idx;
10915 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10916 cap_idx.algo.auth = reference->auth_algo;
10917 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10920 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10921 cap_idx.algo.cipher = reference->crypto_algo;
10922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10926 /* Create session */
10927 memcpy(cipher_key, reference->cipher_key.data,
10928 reference->cipher_key.len);
10929 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10931 /* Setup Authentication Parameters */
10932 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10933 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10934 ut_params->auth_xform.auth.algo = reference->auth_algo;
10935 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10936 ut_params->auth_xform.auth.key.data = auth_key;
10937 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10938 ut_params->auth_xform.next = &ut_params->cipher_xform;
10940 /* Setup Cipher Parameters */
10941 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10942 ut_params->cipher_xform.next = NULL;
10943 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10944 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10945 ut_params->cipher_xform.cipher.key.data = cipher_key;
10946 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10947 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10948 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10950 /* Create Crypto session*/
10951 ut_params->sess = rte_cryptodev_sym_session_create(
10952 ts_params->session_mpool);
10954 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10956 &ut_params->auth_xform,
10957 ts_params->session_priv_mpool);
10959 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10961 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10962 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10963 "Failed to allocate input buffer in mempool");
10965 /* clear mbuf payload */
10966 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10967 rte_pktmbuf_tailroom(ut_params->ibuf));
10969 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10970 reference->ciphertext.len);
10971 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10972 memcpy(ciphertext, reference->ciphertext.data,
10973 reference->ciphertext.len);
10975 /* Create operation */
10976 retval = create_cipher_auth_verify_operation(ts_params,
10983 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10984 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10987 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10990 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10991 TEST_ASSERT_EQUAL(ut_params->op->status,
10992 RTE_CRYPTO_OP_STATUS_SUCCESS,
10993 "crypto op processing passed");
10995 ut_params->obuf = ut_params->op->sym->m_src;
10996 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11002 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11003 const struct aead_test_data *tdata,
11004 void *digest_mem, uint64_t digest_phys)
11006 struct crypto_testsuite_params *ts_params = &testsuite_params;
11007 struct crypto_unittest_params *ut_params = &unittest_params;
11009 const unsigned int auth_tag_len = tdata->auth_tag.len;
11010 const unsigned int iv_len = tdata->iv.len;
11011 unsigned int aad_len = tdata->aad.len;
11012 unsigned int aad_len_pad = 0;
11014 /* Generate Crypto op data structure */
11015 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11016 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11017 TEST_ASSERT_NOT_NULL(ut_params->op,
11018 "Failed to allocate symmetric crypto operation struct");
11020 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11022 sym_op->aead.digest.data = digest_mem;
11024 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11025 "no room to append digest");
11027 sym_op->aead.digest.phys_addr = digest_phys;
11029 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11030 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11032 debug_hexdump(stdout, "digest:",
11033 sym_op->aead.digest.data,
11037 /* Append aad data */
11038 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11039 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11040 uint8_t *, IV_OFFSET);
11042 /* Copy IV 1 byte after the IV pointer, according to the API */
11043 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11045 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11047 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11048 ut_params->ibuf, aad_len);
11049 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11050 "no room to prepend aad");
11051 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11054 memset(sym_op->aead.aad.data, 0, aad_len);
11055 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11056 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11058 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11059 debug_hexdump(stdout, "aad:",
11060 sym_op->aead.aad.data, aad_len);
11062 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11063 uint8_t *, IV_OFFSET);
11065 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11067 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11069 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11070 ut_params->ibuf, aad_len_pad);
11071 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11072 "no room to prepend aad");
11073 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11076 memset(sym_op->aead.aad.data, 0, aad_len);
11077 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11079 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11080 debug_hexdump(stdout, "aad:",
11081 sym_op->aead.aad.data, aad_len);
11084 sym_op->aead.data.length = tdata->plaintext.len;
11085 sym_op->aead.data.offset = aad_len_pad;
11090 #define SGL_MAX_NO 16
11093 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11094 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11096 struct crypto_testsuite_params *ts_params = &testsuite_params;
11097 struct crypto_unittest_params *ut_params = &unittest_params;
11098 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11101 int to_trn_tbl[SGL_MAX_NO];
11103 unsigned int trn_data = 0;
11104 uint8_t *plaintext, *ciphertext, *auth_tag;
11105 struct rte_cryptodev_info dev_info;
11107 /* Verify the capabilities */
11108 struct rte_cryptodev_sym_capability_idx cap_idx;
11109 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11110 cap_idx.algo.aead = tdata->algo;
11111 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11115 /* OOP not supported with CPU crypto */
11116 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11119 /* Detailed check for the particular SGL support flag */
11120 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11122 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11123 if (sgl_in && (!(dev_info.feature_flags &
11124 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11127 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11128 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11129 tdata->plaintext.len;
11130 if (sgl_in && !sgl_out) {
11131 if (!(dev_info.feature_flags &
11132 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11134 } else if (!sgl_in && sgl_out) {
11135 if (!(dev_info.feature_flags &
11136 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11138 } else if (sgl_in && sgl_out) {
11139 if (!(dev_info.feature_flags &
11140 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11145 if (fragsz > tdata->plaintext.len)
11146 fragsz = tdata->plaintext.len;
11148 uint16_t plaintext_len = fragsz;
11149 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11151 if (fragsz_oop > tdata->plaintext.len)
11152 frag_size_oop = tdata->plaintext.len;
11155 void *digest_mem = NULL;
11157 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11159 if (tdata->plaintext.len % fragsz != 0) {
11160 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11163 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11168 * For out-op-place we need to alloc another mbuf
11171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11172 rte_pktmbuf_append(ut_params->obuf,
11173 frag_size_oop + prepend_len);
11174 buf_oop = ut_params->obuf;
11177 /* Create AEAD session */
11178 retval = create_aead_session(ts_params->valid_devs[0],
11180 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11181 tdata->key.data, tdata->key.len,
11182 tdata->aad.len, tdata->auth_tag.len,
11187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11189 /* clear mbuf payload */
11190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11191 rte_pktmbuf_tailroom(ut_params->ibuf));
11193 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11196 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11198 trn_data += plaintext_len;
11200 buf = ut_params->ibuf;
11203 * Loop until no more fragments
11206 while (trn_data < tdata->plaintext.len) {
11208 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11209 (tdata->plaintext.len - trn_data) : fragsz;
11211 to_trn_tbl[ecx++] = to_trn;
11213 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11216 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11217 rte_pktmbuf_tailroom(buf));
11220 if (oop && !fragsz_oop) {
11221 buf_last_oop = buf_oop->next =
11222 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11223 buf_oop = buf_oop->next;
11224 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11225 0, rte_pktmbuf_tailroom(buf_oop));
11226 rte_pktmbuf_append(buf_oop, to_trn);
11229 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11232 memcpy(plaintext, tdata->plaintext.data + trn_data,
11234 trn_data += to_trn;
11235 if (trn_data == tdata->plaintext.len) {
11238 digest_mem = rte_pktmbuf_append(buf_oop,
11239 tdata->auth_tag.len);
11241 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11242 tdata->auth_tag.len);
11246 uint64_t digest_phys = 0;
11248 ut_params->ibuf->nb_segs = segs;
11251 if (fragsz_oop && oop) {
11255 if (frag_size_oop == tdata->plaintext.len) {
11256 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11257 tdata->auth_tag.len);
11259 digest_phys = rte_pktmbuf_iova_offset(
11261 tdata->plaintext.len + prepend_len);
11264 trn_data = frag_size_oop;
11265 while (trn_data < tdata->plaintext.len) {
11268 (tdata->plaintext.len - trn_data <
11270 (tdata->plaintext.len - trn_data) :
11273 to_trn_tbl[ecx++] = to_trn;
11275 buf_last_oop = buf_oop->next =
11276 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11277 buf_oop = buf_oop->next;
11278 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11279 0, rte_pktmbuf_tailroom(buf_oop));
11280 rte_pktmbuf_append(buf_oop, to_trn);
11282 trn_data += to_trn;
11284 if (trn_data == tdata->plaintext.len) {
11285 digest_mem = rte_pktmbuf_append(buf_oop,
11286 tdata->auth_tag.len);
11290 ut_params->obuf->nb_segs = segs;
11294 * Place digest at the end of the last buffer
11297 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11298 if (oop && buf_last_oop)
11299 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11301 if (!digest_mem && !oop) {
11302 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11303 + tdata->auth_tag.len);
11304 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11305 tdata->plaintext.len);
11308 /* Create AEAD operation */
11309 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11310 tdata, digest_mem, digest_phys);
11315 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11317 ut_params->op->sym->m_src = ut_params->ibuf;
11319 ut_params->op->sym->m_dst = ut_params->obuf;
11321 /* Process crypto operation */
11322 if (oop == IN_PLACE &&
11323 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11324 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11326 TEST_ASSERT_NOT_NULL(
11327 process_crypto_request(ts_params->valid_devs[0],
11328 ut_params->op), "failed to process sym crypto op");
11330 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11331 "crypto op processing failed");
11334 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11335 uint8_t *, prepend_len);
11337 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11338 uint8_t *, prepend_len);
11342 fragsz = fragsz_oop;
11344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11346 tdata->ciphertext.data,
11348 "Ciphertext data not as expected");
11350 buf = ut_params->op->sym->m_src->next;
11352 buf = ut_params->op->sym->m_dst->next;
11354 unsigned int off = fragsz;
11358 ciphertext = rte_pktmbuf_mtod(buf,
11361 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11363 tdata->ciphertext.data + off,
11365 "Ciphertext data not as expected");
11367 off += to_trn_tbl[ecx++];
11371 auth_tag = digest_mem;
11372 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11374 tdata->auth_tag.data,
11375 tdata->auth_tag.len,
11376 "Generated auth tag not as expected");
11382 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11384 return test_authenticated_encryption_SGL(
11385 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11389 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11391 return test_authenticated_encryption_SGL(
11392 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11396 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11398 return test_authenticated_encryption_SGL(
11399 &gcm_test_case_8, OUT_OF_PLACE, 400,
11400 gcm_test_case_8.plaintext.len);
11404 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11406 /* This test is not for OPENSSL PMD */
11407 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11408 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11411 return test_authenticated_encryption_SGL(
11412 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11416 test_authentication_verify_fail_when_data_corrupted(
11417 struct crypto_testsuite_params *ts_params,
11418 struct crypto_unittest_params *ut_params,
11419 const struct test_crypto_vector *reference)
11421 return test_authentication_verify_fail_when_data_corruption(
11422 ts_params, ut_params, reference, 1);
11426 test_authentication_verify_fail_when_tag_corrupted(
11427 struct crypto_testsuite_params *ts_params,
11428 struct crypto_unittest_params *ut_params,
11429 const struct test_crypto_vector *reference)
11431 return test_authentication_verify_fail_when_data_corruption(
11432 ts_params, ut_params, reference, 0);
11436 test_authentication_verify_GMAC_fail_when_data_corrupted(
11437 struct crypto_testsuite_params *ts_params,
11438 struct crypto_unittest_params *ut_params,
11439 const struct test_crypto_vector *reference)
11441 return test_authentication_verify_GMAC_fail_when_corruption(
11442 ts_params, ut_params, reference, 1);
11446 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11447 struct crypto_testsuite_params *ts_params,
11448 struct crypto_unittest_params *ut_params,
11449 const struct test_crypto_vector *reference)
11451 return test_authentication_verify_GMAC_fail_when_corruption(
11452 ts_params, ut_params, reference, 0);
11456 test_authenticated_decryption_fail_when_data_corrupted(
11457 struct crypto_testsuite_params *ts_params,
11458 struct crypto_unittest_params *ut_params,
11459 const struct test_crypto_vector *reference)
11461 return test_authenticated_decryption_fail_when_corruption(
11462 ts_params, ut_params, reference, 1);
11466 test_authenticated_decryption_fail_when_tag_corrupted(
11467 struct crypto_testsuite_params *ts_params,
11468 struct crypto_unittest_params *ut_params,
11469 const struct test_crypto_vector *reference)
11471 return test_authenticated_decryption_fail_when_corruption(
11472 ts_params, ut_params, reference, 0);
11476 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11478 return test_authentication_verify_fail_when_data_corrupted(
11479 &testsuite_params, &unittest_params,
11480 &hmac_sha1_test_crypto_vector);
11484 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11486 return test_authentication_verify_fail_when_tag_corrupted(
11487 &testsuite_params, &unittest_params,
11488 &hmac_sha1_test_crypto_vector);
11492 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11494 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11495 &testsuite_params, &unittest_params,
11496 &aes128_gmac_test_vector);
11500 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11502 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11503 &testsuite_params, &unittest_params,
11504 &aes128_gmac_test_vector);
11508 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11510 return test_authenticated_decryption_fail_when_data_corrupted(
11513 &aes128cbc_hmac_sha1_test_vector);
11517 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11519 return test_authenticated_decryption_fail_when_tag_corrupted(
11522 &aes128cbc_hmac_sha1_test_vector);
11526 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11528 return test_authenticated_encryt_with_esn(
11531 &aes128cbc_hmac_sha1_aad_test_vector);
11535 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11537 return test_authenticated_decrypt_with_esn(
11540 &aes128cbc_hmac_sha1_aad_test_vector);
11543 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11545 /* global AESNI slave IDs for the scheduler test */
11546 uint8_t aesni_ids[2];
11549 test_scheduler_attach_slave_op(void)
11551 struct crypto_testsuite_params *ts_params = &testsuite_params;
11552 uint8_t sched_id = ts_params->valid_devs[0];
11553 uint32_t nb_devs, i, nb_devs_attached = 0;
11555 char vdev_name[32];
11557 /* create 2 AESNI_MB if necessary */
11558 nb_devs = rte_cryptodev_device_count_by_driver(
11559 rte_cryptodev_driver_id_get(
11560 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11562 for (i = nb_devs; i < 2; i++) {
11563 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11564 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11566 ret = rte_vdev_init(vdev_name, NULL);
11568 TEST_ASSERT(ret == 0,
11569 "Failed to create instance %u of"
11571 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11575 /* attach 2 AESNI_MB cdevs */
11576 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11578 struct rte_cryptodev_info info;
11579 unsigned int session_size;
11581 rte_cryptodev_info_get(i, &info);
11582 if (info.driver_id != rte_cryptodev_driver_id_get(
11583 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11586 session_size = rte_cryptodev_sym_get_private_session_size(i);
11588 * Create the session mempool again, since now there are new devices
11589 * to use the mempool.
11591 if (ts_params->session_mpool) {
11592 rte_mempool_free(ts_params->session_mpool);
11593 ts_params->session_mpool = NULL;
11595 if (ts_params->session_priv_mpool) {
11596 rte_mempool_free(ts_params->session_priv_mpool);
11597 ts_params->session_priv_mpool = NULL;
11600 if (info.sym.max_nb_sessions != 0 &&
11601 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11602 RTE_LOG(ERR, USER1,
11603 "Device does not support "
11604 "at least %u sessions\n",
11606 return TEST_FAILED;
11609 * Create mempool with maximum number of sessions,
11610 * to include the session headers
11612 if (ts_params->session_mpool == NULL) {
11613 ts_params->session_mpool =
11614 rte_cryptodev_sym_session_pool_create(
11616 MAX_NB_SESSIONS, 0, 0, 0,
11618 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11619 "session mempool allocation failed");
11623 * Create mempool with maximum number of sessions,
11624 * to include device specific session private data
11626 if (ts_params->session_priv_mpool == NULL) {
11627 ts_params->session_priv_mpool = rte_mempool_create(
11628 "test_sess_mp_priv",
11631 0, 0, NULL, NULL, NULL,
11632 NULL, SOCKET_ID_ANY,
11635 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11636 "session mempool allocation failed");
11639 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11640 ts_params->qp_conf.mp_session_private =
11641 ts_params->session_priv_mpool;
11643 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11646 TEST_ASSERT(ret == 0,
11647 "Failed to attach device %u of pmd : %s", i,
11648 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11650 aesni_ids[nb_devs_attached] = (uint8_t)i;
11652 nb_devs_attached++;
11659 test_scheduler_detach_slave_op(void)
11661 struct crypto_testsuite_params *ts_params = &testsuite_params;
11662 uint8_t sched_id = ts_params->valid_devs[0];
11666 for (i = 0; i < 2; i++) {
11667 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11669 TEST_ASSERT(ret == 0,
11670 "Failed to detach device %u", aesni_ids[i]);
11677 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11679 struct crypto_testsuite_params *ts_params = &testsuite_params;
11680 uint8_t sched_id = ts_params->valid_devs[0];
11682 return rte_cryptodev_scheduler_mode_set(sched_id,
11687 test_scheduler_mode_roundrobin_op(void)
11689 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11690 0, "Failed to set roundrobin mode");
11696 test_scheduler_mode_multicore_op(void)
11698 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11699 0, "Failed to set multicore mode");
11705 test_scheduler_mode_failover_op(void)
11707 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11708 0, "Failed to set failover mode");
11714 test_scheduler_mode_pkt_size_distr_op(void)
11716 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11717 0, "Failed to set pktsize mode");
11722 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11723 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11724 .setup = testsuite_setup,
11725 .teardown = testsuite_teardown,
11726 .unit_test_cases = {
11728 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11729 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11730 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11731 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11732 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11733 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11736 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11737 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11738 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11739 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11740 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11741 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11744 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11745 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11746 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11747 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11748 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11749 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11752 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11753 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11754 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11755 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11757 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11759 TEST_CASES_END() /**< NULL terminate unit test array */
11763 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11765 static struct unit_test_suite cryptodev_testsuite = {
11766 .suite_name = "Crypto Unit Test Suite",
11767 .setup = testsuite_setup,
11768 .teardown = testsuite_teardown,
11769 .unit_test_cases = {
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_device_configure_invalid_dev_id),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_device_configure_invalid_queue_pair_ids),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_queue_pair_descriptor_setup),
11777 TEST_CASE_ST(ut_setup, ut_teardown,
11778 test_multi_session),
11779 TEST_CASE_ST(ut_setup, ut_teardown,
11780 test_multi_session_random_usage),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_null_invalid_operation),
11784 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11786 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11787 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11788 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11789 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11790 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11791 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11792 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11793 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11794 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11796 /** AES CCM Authenticated Encryption 128 bits key */
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_AES_CCM_authenticated_encryption_test_case_128_1),
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_AES_CCM_authenticated_encryption_test_case_128_2),
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_AES_CCM_authenticated_encryption_test_case_128_3),
11804 /** AES CCM Authenticated Decryption 128 bits key*/
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_AES_CCM_authenticated_decryption_test_case_128_1),
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_AES_CCM_authenticated_decryption_test_case_128_2),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_AES_CCM_authenticated_decryption_test_case_128_3),
11812 /** AES CCM Authenticated Encryption 192 bits key */
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_AES_CCM_authenticated_encryption_test_case_192_1),
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_AES_CCM_authenticated_encryption_test_case_192_2),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_CCM_authenticated_encryption_test_case_192_3),
11820 /** AES CCM Authenticated Decryption 192 bits key*/
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_CCM_authenticated_decryption_test_case_192_1),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_AES_CCM_authenticated_decryption_test_case_192_2),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_CCM_authenticated_decryption_test_case_192_3),
11828 /** AES CCM Authenticated Encryption 256 bits key */
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_CCM_authenticated_encryption_test_case_256_1),
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_CCM_authenticated_encryption_test_case_256_2),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_CCM_authenticated_encryption_test_case_256_3),
11836 /** AES CCM Authenticated Decryption 256 bits key*/
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_CCM_authenticated_decryption_test_case_256_1),
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_CCM_authenticated_decryption_test_case_256_2),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_CCM_authenticated_decryption_test_case_256_3),
11844 /** AES GCM Authenticated Encryption */
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_GCM_authenticated_encryption_test_case_1),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_GCM_authenticated_encryption_test_case_2),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_AES_GCM_authenticated_encryption_test_case_3),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_authenticated_encryption_test_case_4),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_authenticated_encryption_test_case_5),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_authenticated_encryption_test_case_6),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_authenticated_encryption_test_case_7),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_authenticated_encryption_test_case_8),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11872 /** AES GCM Authenticated Decryption */
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_AES_GCM_authenticated_decryption_test_case_1),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_authenticated_decryption_test_case_2),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_authenticated_decryption_test_case_3),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_authenticated_decryption_test_case_4),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_authenticated_decryption_test_case_5),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_authenticated_decryption_test_case_6),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_authenticated_decryption_test_case_7),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_authenticated_decryption_test_case_8),
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11892 /** AES GCM Authenticated Encryption 192 bits key */
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_auth_encryption_test_case_192_1),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_auth_encryption_test_case_192_2),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_auth_encryption_test_case_192_3),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_auth_encryption_test_case_192_4),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_auth_encryption_test_case_192_5),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_auth_encryption_test_case_192_6),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_auth_encryption_test_case_192_7),
11908 /** AES GCM Authenticated Decryption 192 bits key */
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_decryption_test_case_192_1),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_decryption_test_case_192_2),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_decryption_test_case_192_3),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_decryption_test_case_192_4),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_decryption_test_case_192_5),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_auth_decryption_test_case_192_6),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_auth_decryption_test_case_192_7),
11924 /** AES GCM Authenticated Encryption 256 bits key */
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_encryption_test_case_256_1),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_encryption_test_case_256_2),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_encryption_test_case_256_3),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_encryption_test_case_256_4),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_encryption_test_case_256_5),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_auth_encryption_test_case_256_6),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_auth_encryption_test_case_256_7),
11940 /** AES GCM Authenticated Decryption 256 bits key */
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_auth_decryption_test_case_256_1),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_decryption_test_case_256_2),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_decryption_test_case_256_3),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_decryption_test_case_256_4),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_decryption_test_case_256_5),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GCM_auth_decryption_test_case_256_6),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_decryption_test_case_256_7),
11956 /** AES GCM Authenticated Encryption big aad size */
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GCM_auth_encryption_test_case_aad_1),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_encryption_test_case_aad_2),
11962 /** AES GCM Authenticated Decryption big aad size */
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_AES_GCM_auth_decryption_test_case_aad_1),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_decryption_test_case_aad_2),
11968 /** Out of place tests */
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11974 /** Session-less tests */
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11980 /** AES GMAC Authentication */
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GMAC_authentication_test_case_1),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GMAC_authentication_verify_test_case_1),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_GMAC_authentication_test_case_2),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GMAC_authentication_verify_test_case_2),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GMAC_authentication_test_case_3),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_GMAC_authentication_verify_test_case_3),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_GMAC_authentication_test_case_4),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_AES_GMAC_authentication_verify_test_case_4),
11998 /** SNOW 3G encrypt only (UEA2) */
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_encryption_test_case_1),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_encryption_test_case_2),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_encryption_test_case_3),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_snow3g_encryption_test_case_4),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_encryption_test_case_5),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_snow3g_encryption_test_case_1_oop),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_snow3g_encryption_test_case_1_oop_sgl),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_snow3g_encryption_test_case_1_offset_oop),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_snow3g_decryption_test_case_1_oop),
12019 /** SNOW 3G generate auth, then encrypt (UEA2) */
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_snow3g_auth_cipher_test_case_1),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_snow3g_auth_cipher_test_case_2),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_snow3g_auth_cipher_test_case_2_oop),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_auth_cipher_part_digest_enc),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_auth_cipher_part_digest_enc_oop),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_snow3g_auth_cipher_test_case_3_sgl),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_snow3g_auth_cipher_part_digest_enc_sgl),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12039 /** SNOW 3G decrypt (UEA2), then verify auth */
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_auth_cipher_verify_test_case_1),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_verify_test_case_2),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_verify_test_case_2_oop),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_verify_part_digest_enc),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12059 /** SNOW 3G decrypt only (UEA2) */
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_decryption_test_case_1),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_decryption_test_case_2),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_decryption_test_case_3),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_decryption_test_case_4),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_decryption_test_case_5),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_decryption_with_digest_test_case_1),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_hash_generate_test_case_1),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_snow3g_hash_generate_test_case_2),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_hash_generate_test_case_3),
12078 /* Tests with buffers which length is not byte-aligned */
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_snow3g_hash_generate_test_case_4),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_hash_generate_test_case_5),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_hash_generate_test_case_6),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_snow3g_hash_verify_test_case_1),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_snow3g_hash_verify_test_case_2),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_snow3g_hash_verify_test_case_3),
12091 /* Tests with buffers which length is not byte-aligned */
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_snow3g_hash_verify_test_case_4),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_snow3g_hash_verify_test_case_5),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_snow3g_hash_verify_test_case_6),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_snow3g_cipher_auth_test_case_1),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_snow3g_auth_cipher_with_digest_test_case_1),
12103 /** ZUC encrypt only (EEA3) */
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_zuc_encryption_test_case_1),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_zuc_encryption_test_case_2),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_zuc_encryption_test_case_3),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_zuc_encryption_test_case_4),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_zuc_encryption_test_case_5),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_zuc_encryption_test_case_6_sgl),
12117 /** ZUC authenticate (EIA3) */
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_zuc_hash_generate_test_case_1),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_hash_generate_test_case_2),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_hash_generate_test_case_3),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_hash_generate_test_case_4),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_hash_generate_test_case_5),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_zuc_hash_generate_test_case_6),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_zuc_hash_generate_test_case_7),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_zuc_hash_generate_test_case_8),
12135 /** ZUC alg-chain (EEA3/EIA3) */
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_zuc_cipher_auth_test_case_1),
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_cipher_auth_test_case_2),
12141 /** ZUC generate auth, then encrypt (EEA3) */
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_auth_cipher_test_case_1),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_auth_cipher_test_case_1_oop),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_zuc_auth_cipher_test_case_1_sgl),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_auth_cipher_test_case_1_oop_sgl),
12151 /** ZUC decrypt (EEA3), then verify auth */
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_zuc_auth_cipher_verify_test_case_1),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_auth_cipher_verify_test_case_1_oop),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_zuc_auth_cipher_verify_test_case_1_sgl),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12161 /** HMAC_MD5 Authentication */
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_MD5_HMAC_generate_case_1),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_MD5_HMAC_verify_case_1),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_MD5_HMAC_generate_case_2),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_MD5_HMAC_verify_case_2),
12171 /** KASUMI hash only (UIA1) */
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_hash_generate_test_case_1),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_hash_generate_test_case_2),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_hash_generate_test_case_3),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_kasumi_hash_generate_test_case_4),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_kasumi_hash_generate_test_case_5),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_hash_generate_test_case_6),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_kasumi_hash_verify_test_case_1),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_verify_test_case_2),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_verify_test_case_3),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_kasumi_hash_verify_test_case_4),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_hash_verify_test_case_5),
12196 /** KASUMI encrypt only (UEA1) */
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_kasumi_encryption_test_case_1),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_encryption_test_case_1_sgl),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_encryption_test_case_1_oop),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_encryption_test_case_1_oop_sgl),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_encryption_test_case_2),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_encryption_test_case_3),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_kasumi_encryption_test_case_4),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_encryption_test_case_5),
12214 /** KASUMI decrypt only (UEA1) */
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_decryption_test_case_1),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_decryption_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_decryption_test_case_3),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_decryption_test_case_4),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_decryption_test_case_5),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_kasumi_decryption_test_case_1_oop),
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 test_kasumi_cipher_auth_test_case_1),
12231 /** KASUMI generate auth, then encrypt (F8) */
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_kasumi_auth_cipher_test_case_1),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_kasumi_auth_cipher_test_case_2),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_kasumi_auth_cipher_test_case_2_oop),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_kasumi_auth_cipher_test_case_2_sgl),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12243 /** KASUMI decrypt (F8), then verify auth */
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_kasumi_auth_cipher_verify_test_case_1),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_kasumi_auth_cipher_verify_test_case_2),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_kasumi_auth_cipher_verify_test_case_2_oop),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12255 /** ESN Testcase */
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12261 /** Negative tests */
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 authentication_verify_AES128_GMAC_fail_data_corrupt),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12299 /** Mixed CIPHER + HASH algorithms */
12300 /** AUTH AES CMAC + CIPHER AES CTR */
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12318 /** AUTH ZUC + CIPHER SNOW3G */
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_auth_zuc_cipher_snow_test_case_1),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_verify_auth_zuc_cipher_snow_test_case_1),
12323 /** AUTH AES CMAC + CIPHER SNOW3G */
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 test_auth_aes_cmac_cipher_snow_test_case_1),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12328 /** AUTH ZUC + CIPHER AES CTR */
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_auth_zuc_cipher_aes_ctr_test_case_1),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12333 /** AUTH SNOW3G + CIPHER AES CTR */
12334 TEST_CASE_ST(ut_setup, ut_teardown,
12335 test_auth_snow_cipher_aes_ctr_test_case_1),
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12338 /** AUTH SNOW3G + CIPHER ZUC */
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_auth_snow_cipher_zuc_test_case_1),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_verify_auth_snow_cipher_zuc_test_case_1),
12343 /** AUTH AES CMAC + CIPHER ZUC */
12344 TEST_CASE_ST(ut_setup, ut_teardown,
12345 test_auth_aes_cmac_cipher_zuc_test_case_1),
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12349 /** AUTH NULL + CIPHER SNOW3G */
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_auth_null_cipher_snow_test_case_1),
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_verify_auth_null_cipher_snow_test_case_1),
12354 /** AUTH NULL + CIPHER ZUC */
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_auth_null_cipher_zuc_test_case_1),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_verify_auth_null_cipher_zuc_test_case_1),
12359 /** AUTH SNOW3G + CIPHER NULL */
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_auth_snow_cipher_null_test_case_1),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_verify_auth_snow_cipher_null_test_case_1),
12364 /** AUTH ZUC + CIPHER NULL */
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_auth_zuc_cipher_null_test_case_1),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_verify_auth_zuc_cipher_null_test_case_1),
12369 /** AUTH NULL + CIPHER AES CTR */
12370 TEST_CASE_ST(ut_setup, ut_teardown,
12371 test_auth_null_cipher_aes_ctr_test_case_1),
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12374 /** AUTH AES CMAC + CIPHER NULL */
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_auth_aes_cmac_cipher_null_test_case_1),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12380 TEST_CASES_END() /**< NULL terminate unit test array */
12384 static struct unit_test_suite cryptodev_virtio_testsuite = {
12385 .suite_name = "Crypto VIRTIO Unit Test Suite",
12386 .setup = testsuite_setup,
12387 .teardown = testsuite_teardown,
12388 .unit_test_cases = {
12389 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12391 TEST_CASES_END() /**< NULL terminate unit test array */
12395 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12396 .suite_name = "Crypto CAAM JR Unit Test Suite",
12397 .setup = testsuite_setup,
12398 .teardown = testsuite_teardown,
12399 .unit_test_cases = {
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_device_configure_invalid_dev_id),
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_multi_session),
12405 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12406 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12407 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12408 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12409 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12411 TEST_CASES_END() /**< NULL terminate unit test array */
12415 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12416 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12417 .setup = testsuite_setup,
12418 .teardown = testsuite_teardown,
12419 .unit_test_cases = {
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_device_configure_invalid_dev_id),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_multi_session),
12425 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12426 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12427 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12428 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12429 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12431 #ifdef RTE_LIBRTE_SECURITY
12432 TEST_CASE_ST(ut_setup, ut_teardown,
12433 test_PDCP_PROTO_cplane_encap_all),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_PDCP_PROTO_cplane_decap_all),
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_PDCP_PROTO_uplane_encap_all),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_PDCP_PROTO_uplane_decap_all),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_PDCP_PROTO_SGL_in_place_32B),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_PDCP_PROTO_SGL_oop_32B_128B),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_PDCP_PROTO_SGL_oop_32B_40B),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_PDCP_PROTO_SGL_oop_128B_32B),
12453 /** AES GCM Authenticated Encryption */
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_AES_GCM_authenticated_encryption_test_case_1),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_AES_GCM_authenticated_encryption_test_case_2),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_AES_GCM_authenticated_encryption_test_case_3),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_AES_GCM_authenticated_encryption_test_case_4),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_AES_GCM_authenticated_encryption_test_case_5),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_AES_GCM_authenticated_encryption_test_case_6),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_AES_GCM_authenticated_encryption_test_case_7),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_GCM_authenticated_encryption_test_case_8),
12479 /** AES GCM Authenticated Decryption */
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_AES_GCM_authenticated_decryption_test_case_1),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_AES_GCM_authenticated_decryption_test_case_2),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_AES_GCM_authenticated_decryption_test_case_3),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_GCM_authenticated_decryption_test_case_4),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_AES_GCM_authenticated_decryption_test_case_5),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_AES_GCM_authenticated_decryption_test_case_6),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_AES_GCM_authenticated_decryption_test_case_7),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_AES_GCM_authenticated_decryption_test_case_8),
12497 /** AES GCM Authenticated Encryption 192 bits key */
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_AES_GCM_auth_encryption_test_case_192_1),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_auth_encryption_test_case_192_2),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_auth_encryption_test_case_192_3),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_auth_encryption_test_case_192_4),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_auth_encryption_test_case_192_5),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_auth_encryption_test_case_192_6),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_auth_encryption_test_case_192_7),
12513 /** AES GCM Authenticated Decryption 192 bits key */
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_AES_GCM_auth_decryption_test_case_192_1),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_auth_decryption_test_case_192_2),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_auth_decryption_test_case_192_3),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_decryption_test_case_192_4),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_decryption_test_case_192_5),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_auth_decryption_test_case_192_6),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_auth_decryption_test_case_192_7),
12529 /** AES GCM Authenticated Encryption 256 bits key */
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_auth_encryption_test_case_256_1),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_auth_encryption_test_case_256_2),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_auth_encryption_test_case_256_3),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_encryption_test_case_256_4),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_encryption_test_case_256_5),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_auth_encryption_test_case_256_6),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_encryption_test_case_256_7),
12545 /** AES GCM Authenticated Decryption 256 bits key */
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_auth_decryption_test_case_256_1),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_auth_decryption_test_case_256_2),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_auth_decryption_test_case_256_3),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_decryption_test_case_256_4),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_decryption_test_case_256_5),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_auth_decryption_test_case_256_6),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_auth_decryption_test_case_256_7),
12561 /** Out of place tests */
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12567 /** SNOW 3G encrypt only (UEA2) */
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_snow3g_encryption_test_case_1),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_snow3g_encryption_test_case_2),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_encryption_test_case_3),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_encryption_test_case_4),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_encryption_test_case_5),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_snow3g_encryption_test_case_1_oop),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_snow3g_encryption_test_case_1_oop_sgl),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_snow3g_decryption_test_case_1_oop),
12586 /** SNOW 3G decrypt only (UEA2) */
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_snow3g_decryption_test_case_1),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_snow3g_decryption_test_case_2),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_snow3g_decryption_test_case_3),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_snow3g_decryption_test_case_4),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_snow3g_decryption_test_case_5),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_snow3g_hash_generate_test_case_1),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_snow3g_hash_generate_test_case_2),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_snow3g_hash_generate_test_case_3),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_snow3g_hash_verify_test_case_1),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_snow3g_hash_verify_test_case_2),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_snow3g_hash_verify_test_case_3),
12611 /** ZUC encrypt only (EEA3) */
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_zuc_encryption_test_case_1),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_zuc_encryption_test_case_2),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_zuc_encryption_test_case_3),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_zuc_encryption_test_case_4),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_zuc_encryption_test_case_5),
12623 /** ZUC authenticate (EIA3) */
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_zuc_hash_generate_test_case_6),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_zuc_hash_generate_test_case_7),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_zuc_hash_generate_test_case_8),
12631 /** Negative tests */
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12671 TEST_CASES_END() /**< NULL terminate unit test array */
12675 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12676 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12677 .setup = testsuite_setup,
12678 .teardown = testsuite_teardown,
12679 .unit_test_cases = {
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_device_configure_invalid_dev_id),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_multi_session),
12684 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12685 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12686 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12687 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12688 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12690 #ifdef RTE_LIBRTE_SECURITY
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_PDCP_PROTO_cplane_encap_all),
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_PDCP_PROTO_cplane_decap_all),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_PDCP_PROTO_uplane_encap_all),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_PDCP_PROTO_uplane_decap_all),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_PDCP_PROTO_SGL_in_place_32B),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_PDCP_PROTO_SGL_oop_32B_128B),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_PDCP_PROTO_SGL_oop_32B_40B),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_PDCP_PROTO_SGL_oop_128B_32B),
12712 /** AES GCM Authenticated Encryption */
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_authenticated_encryption_test_case_1),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_authenticated_encryption_test_case_2),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_authenticated_encryption_test_case_3),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_authenticated_encryption_test_case_4),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_authenticated_encryption_test_case_5),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_authenticated_encryption_test_case_6),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_authenticated_encryption_test_case_7),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_authenticated_encryption_test_case_8),
12738 /** AES GCM Authenticated Decryption */
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_authenticated_decryption_test_case_1),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_authenticated_decryption_test_case_2),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_authenticated_decryption_test_case_3),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_decryption_test_case_4),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_decryption_test_case_5),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_authenticated_decryption_test_case_6),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_authenticated_decryption_test_case_7),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_authenticated_decryption_test_case_8),
12756 /** AES GCM Authenticated Encryption 192 bits key */
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_encryption_test_case_192_1),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_encryption_test_case_192_2),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_192_3),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_192_4),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_192_5),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_auth_encryption_test_case_192_6),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_auth_encryption_test_case_192_7),
12772 /** AES GCM Authenticated Decryption 192 bits key */
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_auth_decryption_test_case_192_1),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_auth_decryption_test_case_192_2),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_192_3),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_192_4),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_192_5),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_auth_decryption_test_case_192_6),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_auth_decryption_test_case_192_7),
12788 /** AES GCM Authenticated Encryption 256 bits key */
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_AES_GCM_auth_encryption_test_case_256_1),
12791 TEST_CASE_ST(ut_setup, ut_teardown,
12792 test_AES_GCM_auth_encryption_test_case_256_2),
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_auth_encryption_test_case_256_3),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_AES_GCM_auth_encryption_test_case_256_4),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_AES_GCM_auth_encryption_test_case_256_5),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_AES_GCM_auth_encryption_test_case_256_6),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GCM_auth_encryption_test_case_256_7),
12804 /** AES GCM Authenticated Decryption 256 bits key */
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_AES_GCM_auth_decryption_test_case_256_1),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_AES_GCM_auth_decryption_test_case_256_2),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_AES_GCM_auth_decryption_test_case_256_3),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_AES_GCM_auth_decryption_test_case_256_4),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_AES_GCM_auth_decryption_test_case_256_5),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_AES_GCM_auth_decryption_test_case_256_6),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_AES_GCM_auth_decryption_test_case_256_7),
12820 /** Out of place tests */
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12826 /** SNOW 3G encrypt only (UEA2) */
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_snow3g_encryption_test_case_1),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_encryption_test_case_2),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_snow3g_encryption_test_case_3),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_snow3g_encryption_test_case_4),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_snow3g_encryption_test_case_5),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_snow3g_encryption_test_case_1_oop),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_snow3g_encryption_test_case_1_oop_sgl),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_snow3g_decryption_test_case_1_oop),
12845 /** SNOW 3G decrypt only (UEA2) */
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_snow3g_decryption_test_case_1),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_snow3g_decryption_test_case_2),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_snow3g_decryption_test_case_3),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_snow3g_decryption_test_case_4),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_snow3g_decryption_test_case_5),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_snow3g_hash_generate_test_case_1),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_snow3g_hash_generate_test_case_2),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_snow3g_hash_generate_test_case_3),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_snow3g_hash_verify_test_case_1),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_snow3g_hash_verify_test_case_2),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_snow3g_hash_verify_test_case_3),
12870 /** ZUC encrypt only (EEA3) */
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_zuc_encryption_test_case_1),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_zuc_encryption_test_case_2),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_zuc_encryption_test_case_3),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_zuc_encryption_test_case_4),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_zuc_encryption_test_case_5),
12882 /** ZUC authenticate (EIA3) */
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_zuc_hash_generate_test_case_6),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_zuc_hash_generate_test_case_7),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_zuc_hash_generate_test_case_8),
12890 /** HMAC_MD5 Authentication */
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_MD5_HMAC_generate_case_1),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_MD5_HMAC_verify_case_1),
12895 TEST_CASE_ST(ut_setup, ut_teardown,
12896 test_MD5_HMAC_generate_case_2),
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_MD5_HMAC_verify_case_2),
12900 /** Negative tests */
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12929 TEST_CASE_ST(ut_setup, ut_teardown,
12930 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12938 TEST_CASE_ST(ut_setup, ut_teardown,
12939 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12941 TEST_CASES_END() /**< NULL terminate unit test array */
12945 static struct unit_test_suite cryptodev_armv8_testsuite = {
12946 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12947 .setup = testsuite_setup,
12948 .teardown = testsuite_teardown,
12949 .unit_test_cases = {
12950 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12952 /** Negative tests */
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12958 TEST_CASES_END() /**< NULL terminate unit test array */
12962 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12963 .suite_name = "Crypto Device Marvell Component Test Suite",
12964 .setup = testsuite_setup,
12965 .teardown = testsuite_teardown,
12966 .unit_test_cases = {
12967 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12968 TEST_CASE_ST(ut_setup, ut_teardown,
12969 test_multi_session_random_usage),
12970 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12971 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12972 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12973 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12974 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12976 /** Negative tests */
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12986 TEST_CASES_END() /**< NULL terminate unit test array */
12990 static struct unit_test_suite cryptodev_ccp_testsuite = {
12991 .suite_name = "Crypto Device CCP Unit Test Suite",
12992 .setup = testsuite_setup,
12993 .teardown = testsuite_teardown,
12994 .unit_test_cases = {
12995 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_multi_session_random_usage),
12998 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12999 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13000 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13001 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13002 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13004 /** Negative tests */
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13014 TEST_CASES_END() /**< NULL terminate unit test array */
13018 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13019 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13020 .setup = testsuite_setup,
13021 .teardown = testsuite_teardown,
13022 .unit_test_cases = {
13023 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13024 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13025 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13026 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13027 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13029 /** AES GCM Authenticated Encryption */
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GCM_authenticated_encryption_test_case_1),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_authenticated_encryption_test_case_2),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GCM_authenticated_encryption_test_case_3),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_authenticated_encryption_test_case_4),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GCM_authenticated_encryption_test_case_5),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_AES_GCM_authenticated_encryption_test_case_6),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_authenticated_encryption_test_case_7),
13045 /** AES GCM Authenticated Decryption */
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_AES_GCM_authenticated_decryption_test_case_1),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_authenticated_decryption_test_case_2),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_decryption_test_case_3),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_decryption_test_case_4),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_decryption_test_case_5),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GCM_authenticated_decryption_test_case_6),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_AES_GCM_authenticated_decryption_test_case_7),
13060 /** AES GMAC Authentication */
13061 TEST_CASE_ST(ut_setup, ut_teardown,
13062 test_AES_GMAC_authentication_test_case_1),
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_AES_GMAC_authentication_verify_test_case_1),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_AES_GMAC_authentication_test_case_2),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_AES_GMAC_authentication_verify_test_case_2),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_AES_GMAC_authentication_test_case_3),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_AES_GMAC_authentication_verify_test_case_3),
13074 /** SNOW 3G encrypt only (UEA2) */
13075 TEST_CASE_ST(ut_setup, ut_teardown,
13076 test_snow3g_encryption_test_case_1),
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_snow3g_encryption_test_case_2),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_encryption_test_case_3),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_snow3g_encryption_test_case_4),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_snow3g_encryption_test_case_5),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_snow3g_encryption_test_case_1_oop),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_snow3g_decryption_test_case_1_oop),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_snow3g_encryption_test_case_1_oop_sgl),
13093 /** SNOW 3G decrypt only (UEA2) */
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_snow3g_decryption_test_case_1),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_snow3g_decryption_test_case_2),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_snow3g_decryption_test_case_3),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_snow3g_decryption_test_case_4),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_snow3g_decryption_test_case_5),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_snow3g_hash_generate_test_case_1),
13107 TEST_CASE_ST(ut_setup, ut_teardown,
13108 test_snow3g_hash_generate_test_case_2),
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_snow3g_hash_generate_test_case_3),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_snow3g_hash_verify_test_case_1),
13113 TEST_CASE_ST(ut_setup, ut_teardown,
13114 test_snow3g_hash_verify_test_case_2),
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_snow3g_hash_verify_test_case_3),
13118 /** ZUC encrypt only (EEA3) */
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 test_zuc_encryption_test_case_1),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_zuc_encryption_test_case_2),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_zuc_encryption_test_case_3),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_zuc_encryption_test_case_4),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_zuc_encryption_test_case_5),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_zuc_hash_generate_test_case_1),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_zuc_hash_generate_test_case_2),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 test_zuc_hash_generate_test_case_3),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_zuc_hash_generate_test_case_4),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_zuc_hash_generate_test_case_5),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_zuc_encryption_test_case_6_sgl),
13142 /** KASUMI encrypt only (UEA1) */
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_kasumi_encryption_test_case_1),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_kasumi_encryption_test_case_2),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_kasumi_encryption_test_case_3),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_kasumi_encryption_test_case_4),
13151 TEST_CASE_ST(ut_setup, ut_teardown,
13152 test_kasumi_encryption_test_case_5),
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_kasumi_encryption_test_case_1_sgl),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_kasumi_encryption_test_case_1_oop_sgl),
13157 /** KASUMI decrypt only (UEA1) */
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_kasumi_decryption_test_case_1),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_decryption_test_case_2),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_kasumi_decryption_test_case_3),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_kasumi_decryption_test_case_4),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_kasumi_decryption_test_case_5),
13169 TEST_CASE_ST(ut_setup, ut_teardown,
13170 test_kasumi_encryption_test_case_1_oop),
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_kasumi_decryption_test_case_1_oop),
13174 /** KASUMI hash only (UIA1) */
13175 TEST_CASE_ST(ut_setup, ut_teardown,
13176 test_kasumi_hash_generate_test_case_1),
13177 TEST_CASE_ST(ut_setup, ut_teardown,
13178 test_kasumi_hash_generate_test_case_2),
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 test_kasumi_hash_generate_test_case_3),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_kasumi_hash_generate_test_case_4),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_kasumi_hash_generate_test_case_5),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 test_kasumi_hash_generate_test_case_6),
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_kasumi_hash_verify_test_case_1),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_kasumi_hash_verify_test_case_2),
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_kasumi_hash_verify_test_case_3),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_kasumi_hash_verify_test_case_4),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_kasumi_hash_verify_test_case_5),
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_null_cipher_only_operation),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_null_auth_only_operation),
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_null_cipher_auth_operation),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_null_auth_cipher_operation),
13208 /** Negative tests */
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 authentication_verify_AES128_GMAC_fail_data_corrupt),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13217 TEST_CASE_ST(ut_setup, ut_teardown,
13218 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13221 TEST_CASES_END() /**< NULL terminate unit test array */
13225 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13226 .suite_name = "Crypto NITROX Unit Test Suite",
13227 .setup = testsuite_setup,
13228 .teardown = testsuite_teardown,
13229 .unit_test_cases = {
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_device_configure_invalid_dev_id),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_device_configure_invalid_queue_pair_ids),
13234 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13235 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13237 TEST_CASES_END() /**< NULL terminate unit test array */
13241 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13242 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13243 .setup = testsuite_setup,
13244 .teardown = testsuite_teardown,
13245 .unit_test_cases = {
13246 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13247 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13248 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13249 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13250 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13252 /** AES GCM Authenticated Encryption */
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_AES_GCM_authenticated_encryption_test_case_1),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_AES_GCM_authenticated_encryption_test_case_2),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_AES_GCM_authenticated_encryption_test_case_3),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_AES_GCM_authenticated_encryption_test_case_4),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_AES_GCM_authenticated_encryption_test_case_5),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_AES_GCM_authenticated_encryption_test_case_6),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_AES_GCM_authenticated_encryption_test_case_7),
13268 /** AES GCM Authenticated Decryption */
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_AES_GCM_authenticated_decryption_test_case_1),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_AES_GCM_authenticated_decryption_test_case_2),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_AES_GCM_authenticated_decryption_test_case_3),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_AES_GCM_authenticated_decryption_test_case_4),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_AES_GCM_authenticated_decryption_test_case_5),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_AES_GCM_authenticated_decryption_test_case_6),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_AES_GCM_authenticated_decryption_test_case_7),
13283 /** AES GMAC Authentication */
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_AES_GMAC_authentication_test_case_1),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_AES_GMAC_authentication_verify_test_case_1),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_AES_GMAC_authentication_test_case_2),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_AES_GMAC_authentication_verify_test_case_2),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_AES_GMAC_authentication_test_case_3),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_AES_GMAC_authentication_verify_test_case_3),
13297 /** SNOW 3G encrypt only (UEA2) */
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_snow3g_encryption_test_case_1),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_encryption_test_case_2),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_encryption_test_case_3),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_encryption_test_case_4),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_snow3g_encryption_test_case_5),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_snow3g_encryption_test_case_1_oop),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_snow3g_decryption_test_case_1_oop),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_snow3g_encryption_test_case_1_oop_sgl),
13316 /** SNOW 3G decrypt only (UEA2) */
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_snow3g_decryption_test_case_1),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_snow3g_decryption_test_case_2),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_snow3g_decryption_test_case_3),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_snow3g_decryption_test_case_4),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_snow3g_decryption_test_case_5),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_snow3g_hash_generate_test_case_1),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_snow3g_hash_generate_test_case_2),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_snow3g_hash_generate_test_case_3),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_snow3g_hash_verify_test_case_1),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_snow3g_hash_verify_test_case_2),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_snow3g_hash_verify_test_case_3),
13341 /** ZUC encrypt only (EEA3) */
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_zuc_encryption_test_case_1),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_zuc_encryption_test_case_2),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_zuc_encryption_test_case_3),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_zuc_encryption_test_case_4),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_zuc_encryption_test_case_5),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_zuc_hash_generate_test_case_1),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_zuc_hash_generate_test_case_2),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_zuc_hash_generate_test_case_3),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_zuc_hash_generate_test_case_4),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_zuc_hash_generate_test_case_5),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_zuc_encryption_test_case_6_sgl),
13365 /** KASUMI encrypt only (UEA1) */
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_kasumi_encryption_test_case_1),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_kasumi_encryption_test_case_2),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_kasumi_encryption_test_case_3),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_encryption_test_case_4),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_kasumi_encryption_test_case_5),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_kasumi_encryption_test_case_1_sgl),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_kasumi_encryption_test_case_1_oop_sgl),
13380 /** KASUMI decrypt only (UEA1) */
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_kasumi_decryption_test_case_1),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_kasumi_decryption_test_case_2),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_kasumi_decryption_test_case_3),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_kasumi_decryption_test_case_4),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_kasumi_decryption_test_case_5),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_kasumi_encryption_test_case_1_oop),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_kasumi_decryption_test_case_1_oop),
13397 /** KASUMI hash only (UIA1) */
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_kasumi_hash_generate_test_case_1),
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_kasumi_hash_generate_test_case_2),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_kasumi_hash_generate_test_case_3),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_kasumi_hash_generate_test_case_4),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_kasumi_hash_generate_test_case_5),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_kasumi_hash_generate_test_case_6),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_kasumi_hash_verify_test_case_1),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_kasumi_hash_verify_test_case_2),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_kasumi_hash_verify_test_case_3),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_kasumi_hash_verify_test_case_4),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_kasumi_hash_verify_test_case_5),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_null_cipher_only_operation),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_null_auth_only_operation),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_null_cipher_auth_operation),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_null_auth_cipher_operation),
13431 /** Negative tests */
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 authentication_verify_AES128_GMAC_fail_data_corrupt),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13444 TEST_CASES_END() /**< NULL terminate unit test array */
13449 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13451 gbl_driver_id = rte_cryptodev_driver_id_get(
13452 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13454 if (gbl_driver_id == -1) {
13455 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13456 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13457 "are enabled in config file to run this testsuite.\n");
13458 return TEST_SKIPPED;
13461 return unit_test_suite_runner(&cryptodev_testsuite);
13465 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13467 gbl_driver_id = rte_cryptodev_driver_id_get(
13468 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13470 if (gbl_driver_id == -1) {
13471 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13472 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13473 "in config file to run this testsuite.\n");
13474 return TEST_FAILED;
13477 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13481 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13483 gbl_driver_id = rte_cryptodev_driver_id_get(
13484 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13486 if (gbl_driver_id == -1) {
13487 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13488 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13489 "in config file to run this testsuite.\n");
13490 return TEST_SKIPPED;
13493 return unit_test_suite_runner(&cryptodev_testsuite);
13497 test_cryptodev_cpu_aesni_mb(void)
13500 enum rte_security_session_action_type at;
13502 gbl_driver_id = rte_cryptodev_driver_id_get(
13503 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13505 if (gbl_driver_id == -1) {
13506 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13507 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13508 "in config file to run this testsuite.\n");
13509 return TEST_SKIPPED;
13512 at = gbl_action_type;
13513 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13514 rc = unit_test_suite_runner(&cryptodev_testsuite);
13515 gbl_action_type = at;
13520 test_cryptodev_openssl(void)
13522 gbl_driver_id = rte_cryptodev_driver_id_get(
13523 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13525 if (gbl_driver_id == -1) {
13526 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13527 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13528 "in config file to run this testsuite.\n");
13529 return TEST_SKIPPED;
13532 return unit_test_suite_runner(&cryptodev_testsuite);
13536 test_cryptodev_aesni_gcm(void)
13538 gbl_driver_id = rte_cryptodev_driver_id_get(
13539 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13541 if (gbl_driver_id == -1) {
13542 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13543 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13544 "in config file to run this testsuite.\n");
13545 return TEST_SKIPPED;
13548 return unit_test_suite_runner(&cryptodev_testsuite);
13552 test_cryptodev_cpu_aesni_gcm(void)
13555 enum rte_security_session_action_type at;
13557 gbl_driver_id = rte_cryptodev_driver_id_get(
13558 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13560 if (gbl_driver_id == -1) {
13561 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13562 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13563 "in config file to run this testsuite.\n");
13564 return TEST_SKIPPED;
13567 at = gbl_action_type;
13568 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13569 rc = unit_test_suite_runner(&cryptodev_testsuite);
13570 gbl_action_type = at;
13575 test_cryptodev_null(void)
13577 gbl_driver_id = rte_cryptodev_driver_id_get(
13578 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13580 if (gbl_driver_id == -1) {
13581 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13582 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13583 "in config file to run this testsuite.\n");
13584 return TEST_SKIPPED;
13587 return unit_test_suite_runner(&cryptodev_testsuite);
13591 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13593 gbl_driver_id = rte_cryptodev_driver_id_get(
13594 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13596 if (gbl_driver_id == -1) {
13597 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13598 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13599 "in config file to run this testsuite.\n");
13600 return TEST_SKIPPED;
13603 return unit_test_suite_runner(&cryptodev_testsuite);
13607 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13609 gbl_driver_id = rte_cryptodev_driver_id_get(
13610 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13612 if (gbl_driver_id == -1) {
13613 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13614 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13615 "in config file to run this testsuite.\n");
13616 return TEST_SKIPPED;
13619 return unit_test_suite_runner(&cryptodev_testsuite);
13623 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13625 gbl_driver_id = rte_cryptodev_driver_id_get(
13626 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13628 if (gbl_driver_id == -1) {
13629 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13630 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13631 "in config file to run this testsuite.\n");
13632 return TEST_SKIPPED;
13635 return unit_test_suite_runner(&cryptodev_testsuite);
13639 test_cryptodev_armv8(void)
13641 gbl_driver_id = rte_cryptodev_driver_id_get(
13642 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13644 if (gbl_driver_id == -1) {
13645 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13646 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13647 "in config file to run this testsuite.\n");
13648 return TEST_SKIPPED;
13651 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13655 test_cryptodev_mrvl(void)
13657 gbl_driver_id = rte_cryptodev_driver_id_get(
13658 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13660 if (gbl_driver_id == -1) {
13661 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13662 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13663 "in config file to run this testsuite.\n");
13664 return TEST_SKIPPED;
13667 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13670 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13673 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13675 gbl_driver_id = rte_cryptodev_driver_id_get(
13676 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13678 if (gbl_driver_id == -1) {
13679 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13680 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13681 "in config file to run this testsuite.\n");
13682 return TEST_SKIPPED;
13685 if (rte_cryptodev_driver_id_get(
13686 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13687 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13688 " enabled in config file to run this testsuite.\n");
13689 return TEST_SKIPPED;
13691 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13694 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13699 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13701 gbl_driver_id = rte_cryptodev_driver_id_get(
13702 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13704 if (gbl_driver_id == -1) {
13705 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13706 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13707 "in config file to run this testsuite.\n");
13708 return TEST_SKIPPED;
13711 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13715 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13717 gbl_driver_id = rte_cryptodev_driver_id_get(
13718 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13720 if (gbl_driver_id == -1) {
13721 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13722 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13723 "in config file to run this testsuite.\n");
13724 return TEST_SKIPPED;
13727 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13731 test_cryptodev_ccp(void)
13733 gbl_driver_id = rte_cryptodev_driver_id_get(
13734 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13736 if (gbl_driver_id == -1) {
13737 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13738 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13739 "in config file to run this testsuite.\n");
13740 return TEST_FAILED;
13743 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13747 test_cryptodev_octeontx(void)
13749 gbl_driver_id = rte_cryptodev_driver_id_get(
13750 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13751 if (gbl_driver_id == -1) {
13752 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13753 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13754 "enabled in config file to run this "
13756 return TEST_FAILED;
13758 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13762 test_cryptodev_octeontx2(void)
13764 gbl_driver_id = rte_cryptodev_driver_id_get(
13765 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13766 if (gbl_driver_id == -1) {
13767 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13768 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13769 "enabled in config file to run this "
13771 return TEST_FAILED;
13773 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13777 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13779 gbl_driver_id = rte_cryptodev_driver_id_get(
13780 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13782 if (gbl_driver_id == -1) {
13783 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13784 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13785 "in config file to run this testsuite.\n");
13786 return TEST_FAILED;
13789 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13793 test_cryptodev_nitrox(void)
13795 gbl_driver_id = rte_cryptodev_driver_id_get(
13796 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13798 if (gbl_driver_id == -1) {
13799 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13800 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13801 "in config file to run this testsuite.\n");
13802 return TEST_FAILED;
13805 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13808 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13809 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13810 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13811 test_cryptodev_cpu_aesni_mb);
13812 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13813 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13814 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13815 test_cryptodev_cpu_aesni_gcm);
13816 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13817 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13818 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13819 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13820 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13821 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13822 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13823 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13824 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13825 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13826 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13827 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13828 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13829 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);