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);
2053 if (status == -ENOTSUP)
2056 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2062 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2063 const struct wireless_test_data *tdata)
2065 return create_wireless_cipher_auth_session(dev_id,
2066 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2067 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2068 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2072 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2073 enum rte_crypto_cipher_operation cipher_op,
2074 enum rte_crypto_auth_operation auth_op,
2075 enum rte_crypto_auth_algorithm auth_algo,
2076 enum rte_crypto_cipher_algorithm cipher_algo,
2077 const uint8_t *key, const uint8_t key_len,
2078 uint8_t auth_iv_len, uint8_t auth_len,
2079 uint8_t cipher_iv_len)
2081 uint8_t auth_cipher_key[key_len];
2083 struct crypto_testsuite_params *ts_params = &testsuite_params;
2084 struct crypto_unittest_params *ut_params = &unittest_params;
2086 memcpy(auth_cipher_key, key, key_len);
2088 /* Setup Authentication Parameters */
2089 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2090 ut_params->auth_xform.auth.op = auth_op;
2091 ut_params->auth_xform.next = &ut_params->cipher_xform;
2092 ut_params->auth_xform.auth.algo = auth_algo;
2093 ut_params->auth_xform.auth.key.length = key_len;
2094 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2095 ut_params->auth_xform.auth.digest_length = auth_len;
2096 /* Auth IV will be after cipher IV */
2097 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2098 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2100 /* Setup Cipher Parameters */
2101 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2102 ut_params->cipher_xform.next = NULL;
2103 ut_params->cipher_xform.cipher.algo = cipher_algo;
2104 ut_params->cipher_xform.cipher.op = cipher_op;
2105 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2106 ut_params->cipher_xform.cipher.key.length = key_len;
2107 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2108 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2110 debug_hexdump(stdout, "key:", key, key_len);
2112 /* Create Crypto session*/
2113 ut_params->sess = rte_cryptodev_sym_session_create(
2114 ts_params->session_mpool);
2115 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2117 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2118 ut_params->auth_xform.next = NULL;
2119 ut_params->cipher_xform.next = &ut_params->auth_xform;
2120 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2121 &ut_params->cipher_xform,
2122 ts_params->session_priv_mpool);
2125 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2126 &ut_params->auth_xform,
2127 ts_params->session_priv_mpool);
2129 if (status == -ENOTSUP)
2132 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2138 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2139 unsigned int auth_tag_len,
2140 const uint8_t *iv, unsigned int iv_len,
2141 unsigned int data_pad_len,
2142 enum rte_crypto_auth_operation op,
2143 unsigned int auth_len, unsigned int auth_offset)
2145 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 struct crypto_unittest_params *ut_params = &unittest_params;
2149 /* Generate Crypto op data structure */
2150 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2151 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2152 TEST_ASSERT_NOT_NULL(ut_params->op,
2153 "Failed to allocate pktmbuf offload");
2155 /* Set crypto operation data parameters */
2156 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2158 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2160 /* set crypto operation source mbuf */
2161 sym_op->m_src = ut_params->ibuf;
2164 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2167 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2168 ut_params->ibuf, auth_tag_len);
2170 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2171 "no room to append auth tag");
2172 ut_params->digest = sym_op->auth.digest.data;
2173 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2174 ut_params->ibuf, data_pad_len);
2175 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2176 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2178 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2180 debug_hexdump(stdout, "digest:",
2181 sym_op->auth.digest.data,
2184 sym_op->auth.data.length = auth_len;
2185 sym_op->auth.data.offset = auth_offset;
2191 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2192 enum rte_crypto_auth_operation op)
2194 struct crypto_testsuite_params *ts_params = &testsuite_params;
2195 struct crypto_unittest_params *ut_params = &unittest_params;
2197 const uint8_t *auth_tag = tdata->digest.data;
2198 const unsigned int auth_tag_len = tdata->digest.len;
2199 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2200 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2202 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2203 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2204 const uint8_t *auth_iv = tdata->auth_iv.data;
2205 const uint8_t auth_iv_len = tdata->auth_iv.len;
2206 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2207 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2209 /* Generate Crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate pktmbuf offload");
2214 /* Set crypto operation data parameters */
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2223 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2224 ut_params->ibuf, auth_tag_len);
2226 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2227 "no room to append auth tag");
2228 ut_params->digest = sym_op->auth.digest.data;
2229 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2230 ut_params->ibuf, data_pad_len);
2231 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2232 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2234 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2236 debug_hexdump(stdout, "digest:",
2237 sym_op->auth.digest.data,
2240 /* Copy cipher and auth IVs at the end of the crypto operation */
2241 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2243 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2244 iv_ptr += cipher_iv_len;
2245 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2247 sym_op->cipher.data.length = cipher_len;
2248 sym_op->cipher.data.offset = 0;
2249 sym_op->auth.data.length = auth_len;
2250 sym_op->auth.data.offset = 0;
2256 create_zuc_cipher_hash_generate_operation(
2257 const struct wireless_test_data *tdata)
2259 return create_wireless_cipher_hash_operation(tdata,
2260 RTE_CRYPTO_AUTH_OP_GENERATE);
2264 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2265 const unsigned auth_tag_len,
2266 const uint8_t *auth_iv, uint8_t auth_iv_len,
2267 unsigned data_pad_len,
2268 enum rte_crypto_auth_operation op,
2269 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2270 const unsigned cipher_len, const unsigned cipher_offset,
2271 const unsigned auth_len, const unsigned auth_offset)
2273 struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 struct crypto_unittest_params *ut_params = &unittest_params;
2276 enum rte_crypto_cipher_algorithm cipher_algo =
2277 ut_params->cipher_xform.cipher.algo;
2278 enum rte_crypto_auth_algorithm auth_algo =
2279 ut_params->auth_xform.auth.algo;
2281 /* Generate Crypto op data structure */
2282 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2283 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2284 TEST_ASSERT_NOT_NULL(ut_params->op,
2285 "Failed to allocate pktmbuf offload");
2286 /* Set crypto operation data parameters */
2287 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2289 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2291 /* set crypto operation source mbuf */
2292 sym_op->m_src = ut_params->ibuf;
2295 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2296 ut_params->ibuf, auth_tag_len);
2298 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2299 "no room to append auth tag");
2300 ut_params->digest = sym_op->auth.digest.data;
2302 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2303 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2304 ut_params->ibuf, data_pad_len);
2306 struct rte_mbuf *m = ut_params->ibuf;
2307 unsigned int offset = data_pad_len;
2309 while (offset > m->data_len && m->next != NULL) {
2310 offset -= m->data_len;
2313 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2317 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2318 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2320 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2322 debug_hexdump(stdout, "digest:",
2323 sym_op->auth.digest.data,
2326 /* Copy cipher and auth IVs at the end of the crypto operation */
2327 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2329 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2330 iv_ptr += cipher_iv_len;
2331 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2333 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2334 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2335 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2336 sym_op->cipher.data.length = cipher_len;
2337 sym_op->cipher.data.offset = cipher_offset;
2339 sym_op->cipher.data.length = cipher_len >> 3;
2340 sym_op->cipher.data.offset = cipher_offset >> 3;
2343 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2344 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2345 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2346 sym_op->auth.data.length = auth_len;
2347 sym_op->auth.data.offset = auth_offset;
2349 sym_op->auth.data.length = auth_len >> 3;
2350 sym_op->auth.data.offset = auth_offset >> 3;
2357 create_wireless_algo_auth_cipher_operation(
2358 const uint8_t *auth_tag, unsigned int auth_tag_len,
2359 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2360 const uint8_t *auth_iv, uint8_t auth_iv_len,
2361 unsigned int data_pad_len,
2362 unsigned int cipher_len, unsigned int cipher_offset,
2363 unsigned int auth_len, unsigned int auth_offset,
2364 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2366 struct crypto_testsuite_params *ts_params = &testsuite_params;
2367 struct crypto_unittest_params *ut_params = &unittest_params;
2369 enum rte_crypto_cipher_algorithm cipher_algo =
2370 ut_params->cipher_xform.cipher.algo;
2371 enum rte_crypto_auth_algorithm auth_algo =
2372 ut_params->auth_xform.auth.algo;
2374 /* Generate Crypto op data structure */
2375 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2376 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2377 TEST_ASSERT_NOT_NULL(ut_params->op,
2378 "Failed to allocate pktmbuf offload");
2380 /* Set crypto operation data parameters */
2381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2383 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2385 /* set crypto operation mbufs */
2386 sym_op->m_src = ut_params->ibuf;
2387 if (op_mode == OUT_OF_PLACE)
2388 sym_op->m_dst = ut_params->obuf;
2392 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2393 (op_mode == IN_PLACE ?
2394 ut_params->ibuf : ut_params->obuf),
2395 uint8_t *, data_pad_len);
2396 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2397 (op_mode == IN_PLACE ?
2398 ut_params->ibuf : ut_params->obuf),
2400 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2402 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2403 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2404 sym_op->m_src : sym_op->m_dst);
2405 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2406 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2407 sgl_buf = sgl_buf->next;
2409 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2410 uint8_t *, remaining_off);
2411 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2413 memset(sym_op->auth.digest.data, 0, remaining_off);
2414 while (sgl_buf->next != NULL) {
2415 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2416 0, rte_pktmbuf_data_len(sgl_buf));
2417 sgl_buf = sgl_buf->next;
2421 /* Copy digest for the verification */
2423 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2425 /* Copy cipher and auth IVs at the end of the crypto operation */
2426 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2427 ut_params->op, uint8_t *, IV_OFFSET);
2429 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2430 iv_ptr += cipher_iv_len;
2431 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2433 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2434 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2435 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2436 sym_op->cipher.data.length = cipher_len;
2437 sym_op->cipher.data.offset = cipher_offset;
2439 sym_op->cipher.data.length = cipher_len >> 3;
2440 sym_op->cipher.data.offset = cipher_offset >> 3;
2443 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2444 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2445 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2446 sym_op->auth.data.length = auth_len;
2447 sym_op->auth.data.offset = auth_offset;
2449 sym_op->auth.data.length = auth_len >> 3;
2450 sym_op->auth.data.offset = auth_offset >> 3;
2457 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2459 struct crypto_testsuite_params *ts_params = &testsuite_params;
2460 struct crypto_unittest_params *ut_params = &unittest_params;
2463 unsigned plaintext_pad_len;
2464 unsigned plaintext_len;
2466 struct rte_cryptodev_info dev_info;
2468 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2469 uint64_t feat_flags = dev_info.feature_flags;
2471 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2472 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2473 printf("Device doesn't support NON-Byte Aligned Data.\n");
2477 /* Verify the capabilities */
2478 struct rte_cryptodev_sym_capability_idx cap_idx;
2479 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2480 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2481 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2485 /* Create SNOW 3G session */
2486 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2487 tdata->key.data, tdata->key.len,
2488 tdata->auth_iv.len, tdata->digest.len,
2489 RTE_CRYPTO_AUTH_OP_GENERATE,
2490 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2494 /* alloc mbuf and set payload */
2495 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2497 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2498 rte_pktmbuf_tailroom(ut_params->ibuf));
2500 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2501 /* Append data which is padded to a multiple of */
2502 /* the algorithms block size */
2503 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2504 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2506 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2508 /* Create SNOW 3G operation */
2509 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2510 tdata->auth_iv.data, tdata->auth_iv.len,
2511 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2512 tdata->validAuthLenInBits.len,
2517 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2519 ut_params->obuf = ut_params->op->sym->m_src;
2520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2521 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2522 + plaintext_pad_len;
2525 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2528 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2529 "SNOW 3G Generated auth tag not as expected");
2535 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2537 struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 struct crypto_unittest_params *ut_params = &unittest_params;
2541 unsigned plaintext_pad_len;
2542 unsigned plaintext_len;
2544 struct rte_cryptodev_info dev_info;
2546 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2547 uint64_t feat_flags = dev_info.feature_flags;
2549 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2550 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2551 printf("Device doesn't support NON-Byte Aligned Data.\n");
2555 /* Verify the capabilities */
2556 struct rte_cryptodev_sym_capability_idx cap_idx;
2557 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2558 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2559 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2563 /* Create SNOW 3G session */
2564 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2565 tdata->key.data, tdata->key.len,
2566 tdata->auth_iv.len, tdata->digest.len,
2567 RTE_CRYPTO_AUTH_OP_VERIFY,
2568 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2571 /* alloc mbuf and set payload */
2572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2574 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2575 rte_pktmbuf_tailroom(ut_params->ibuf));
2577 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2578 /* Append data which is padded to a multiple of */
2579 /* the algorithms block size */
2580 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2581 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2583 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2585 /* Create SNOW 3G operation */
2586 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2588 tdata->auth_iv.data, tdata->auth_iv.len,
2590 RTE_CRYPTO_AUTH_OP_VERIFY,
2591 tdata->validAuthLenInBits.len,
2596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2599 ut_params->obuf = ut_params->op->sym->m_src;
2600 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2601 + plaintext_pad_len;
2604 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2613 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2615 struct crypto_testsuite_params *ts_params = &testsuite_params;
2616 struct crypto_unittest_params *ut_params = &unittest_params;
2619 unsigned plaintext_pad_len;
2620 unsigned plaintext_len;
2623 /* Verify the capabilities */
2624 struct rte_cryptodev_sym_capability_idx cap_idx;
2625 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2626 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2627 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2631 /* Create KASUMI session */
2632 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2633 tdata->key.data, tdata->key.len,
2634 0, tdata->digest.len,
2635 RTE_CRYPTO_AUTH_OP_GENERATE,
2636 RTE_CRYPTO_AUTH_KASUMI_F9);
2640 /* alloc mbuf and set payload */
2641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2644 rte_pktmbuf_tailroom(ut_params->ibuf));
2646 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2647 /* Append data which is padded to a multiple of */
2648 /* the algorithms block size */
2649 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2650 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2652 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2654 /* Create KASUMI operation */
2655 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2657 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2658 tdata->plaintext.len,
2663 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2664 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2667 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2670 ut_params->obuf = ut_params->op->sym->m_src;
2671 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2672 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2673 + plaintext_pad_len;
2676 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2679 DIGEST_BYTE_LENGTH_KASUMI_F9,
2680 "KASUMI Generated auth tag not as expected");
2686 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2688 struct crypto_testsuite_params *ts_params = &testsuite_params;
2689 struct crypto_unittest_params *ut_params = &unittest_params;
2692 unsigned plaintext_pad_len;
2693 unsigned plaintext_len;
2696 /* Verify the capabilities */
2697 struct rte_cryptodev_sym_capability_idx cap_idx;
2698 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2699 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2700 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2704 /* Create KASUMI session */
2705 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2706 tdata->key.data, tdata->key.len,
2707 0, tdata->digest.len,
2708 RTE_CRYPTO_AUTH_OP_VERIFY,
2709 RTE_CRYPTO_AUTH_KASUMI_F9);
2712 /* alloc mbuf and set payload */
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2716 rte_pktmbuf_tailroom(ut_params->ibuf));
2718 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2719 /* Append data which is padded to a multiple */
2720 /* of the algorithms block size */
2721 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2722 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2724 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2726 /* Create KASUMI operation */
2727 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2731 RTE_CRYPTO_AUTH_OP_VERIFY,
2732 tdata->plaintext.len,
2737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2740 ut_params->obuf = ut_params->op->sym->m_src;
2741 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2742 + plaintext_pad_len;
2745 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2754 test_snow3g_hash_generate_test_case_1(void)
2756 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2760 test_snow3g_hash_generate_test_case_2(void)
2762 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2766 test_snow3g_hash_generate_test_case_3(void)
2768 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2772 test_snow3g_hash_generate_test_case_4(void)
2774 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2778 test_snow3g_hash_generate_test_case_5(void)
2780 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2784 test_snow3g_hash_generate_test_case_6(void)
2786 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2790 test_snow3g_hash_verify_test_case_1(void)
2792 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2797 test_snow3g_hash_verify_test_case_2(void)
2799 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2803 test_snow3g_hash_verify_test_case_3(void)
2805 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2809 test_snow3g_hash_verify_test_case_4(void)
2811 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2815 test_snow3g_hash_verify_test_case_5(void)
2817 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2821 test_snow3g_hash_verify_test_case_6(void)
2823 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2827 test_kasumi_hash_generate_test_case_1(void)
2829 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2833 test_kasumi_hash_generate_test_case_2(void)
2835 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2839 test_kasumi_hash_generate_test_case_3(void)
2841 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2845 test_kasumi_hash_generate_test_case_4(void)
2847 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2851 test_kasumi_hash_generate_test_case_5(void)
2853 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2857 test_kasumi_hash_generate_test_case_6(void)
2859 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2863 test_kasumi_hash_verify_test_case_1(void)
2865 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2869 test_kasumi_hash_verify_test_case_2(void)
2871 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2875 test_kasumi_hash_verify_test_case_3(void)
2877 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2881 test_kasumi_hash_verify_test_case_4(void)
2883 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2887 test_kasumi_hash_verify_test_case_5(void)
2889 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2893 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2895 struct crypto_testsuite_params *ts_params = &testsuite_params;
2896 struct crypto_unittest_params *ut_params = &unittest_params;
2899 uint8_t *plaintext, *ciphertext;
2900 unsigned plaintext_pad_len;
2901 unsigned plaintext_len;
2903 /* Verify the capabilities */
2904 struct rte_cryptodev_sym_capability_idx cap_idx;
2905 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2906 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2907 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2911 /* Create KASUMI session */
2912 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2913 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2914 RTE_CRYPTO_CIPHER_KASUMI_F8,
2915 tdata->key.data, tdata->key.len,
2916 tdata->cipher_iv.len);
2920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2922 /* Clear mbuf payload */
2923 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2924 rte_pktmbuf_tailroom(ut_params->ibuf));
2926 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2927 /* Append data which is padded to a multiple */
2928 /* of the algorithms block size */
2929 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2930 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2932 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2934 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2936 /* Create KASUMI operation */
2937 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2938 tdata->cipher_iv.len,
2939 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2940 tdata->validCipherOffsetInBits.len);
2944 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2946 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2948 ut_params->obuf = ut_params->op->sym->m_dst;
2949 if (ut_params->obuf)
2950 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2952 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2954 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2956 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2957 (tdata->validCipherOffsetInBits.len >> 3);
2959 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2961 reference_ciphertext,
2962 tdata->validCipherLenInBits.len,
2963 "KASUMI Ciphertext data not as expected");
2968 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2970 struct crypto_testsuite_params *ts_params = &testsuite_params;
2971 struct crypto_unittest_params *ut_params = &unittest_params;
2975 unsigned int plaintext_pad_len;
2976 unsigned int plaintext_len;
2978 uint8_t buffer[10000];
2979 const uint8_t *ciphertext;
2981 struct rte_cryptodev_info dev_info;
2983 /* Verify the capabilities */
2984 struct rte_cryptodev_sym_capability_idx cap_idx;
2985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2986 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2987 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2991 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2993 uint64_t feat_flags = dev_info.feature_flags;
2995 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2996 printf("Device doesn't support in-place scatter-gather. "
3001 /* Create KASUMI session */
3002 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3003 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3004 RTE_CRYPTO_CIPHER_KASUMI_F8,
3005 tdata->key.data, tdata->key.len,
3006 tdata->cipher_iv.len);
3010 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3013 /* Append data which is padded to a multiple */
3014 /* of the algorithms block size */
3015 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3017 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3018 plaintext_pad_len, 10, 0);
3020 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3022 /* Create KASUMI operation */
3023 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3024 tdata->cipher_iv.len,
3025 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3026 tdata->validCipherOffsetInBits.len);
3030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3034 ut_params->obuf = ut_params->op->sym->m_dst;
3036 if (ut_params->obuf)
3037 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3038 plaintext_len, buffer);
3040 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3041 tdata->validCipherOffsetInBits.len >> 3,
3042 plaintext_len, buffer);
3045 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3047 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3048 (tdata->validCipherOffsetInBits.len >> 3);
3050 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3052 reference_ciphertext,
3053 tdata->validCipherLenInBits.len,
3054 "KASUMI Ciphertext data not as expected");
3059 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3061 struct crypto_testsuite_params *ts_params = &testsuite_params;
3062 struct crypto_unittest_params *ut_params = &unittest_params;
3065 uint8_t *plaintext, *ciphertext;
3066 unsigned plaintext_pad_len;
3067 unsigned plaintext_len;
3069 /* Verify the capabilities */
3070 struct rte_cryptodev_sym_capability_idx cap_idx;
3071 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3072 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3073 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3077 /* Create KASUMI session */
3078 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3080 RTE_CRYPTO_CIPHER_KASUMI_F8,
3081 tdata->key.data, tdata->key.len,
3082 tdata->cipher_iv.len);
3086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3087 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3089 /* Clear mbuf payload */
3090 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3091 rte_pktmbuf_tailroom(ut_params->ibuf));
3093 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3094 /* Append data which is padded to a multiple */
3095 /* of the algorithms block size */
3096 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3097 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3099 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3100 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3102 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3104 /* Create KASUMI operation */
3105 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3106 tdata->cipher_iv.len,
3107 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3108 tdata->validCipherOffsetInBits.len);
3112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3114 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3116 ut_params->obuf = ut_params->op->sym->m_dst;
3117 if (ut_params->obuf)
3118 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3120 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3122 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3124 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3125 (tdata->validCipherOffsetInBits.len >> 3);
3127 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3129 reference_ciphertext,
3130 tdata->validCipherLenInBits.len,
3131 "KASUMI Ciphertext data not as expected");
3136 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3138 struct crypto_testsuite_params *ts_params = &testsuite_params;
3139 struct crypto_unittest_params *ut_params = &unittest_params;
3142 unsigned int plaintext_pad_len;
3143 unsigned int plaintext_len;
3145 const uint8_t *ciphertext;
3146 uint8_t buffer[2048];
3148 struct rte_cryptodev_info dev_info;
3150 /* Verify the capabilities */
3151 struct rte_cryptodev_sym_capability_idx cap_idx;
3152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3153 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3158 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3160 uint64_t feat_flags = dev_info.feature_flags;
3161 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3162 printf("Device doesn't support out-of-place scatter-gather "
3163 "in both input and output mbufs. "
3168 /* Create KASUMI session */
3169 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3170 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3171 RTE_CRYPTO_CIPHER_KASUMI_F8,
3172 tdata->key.data, tdata->key.len,
3173 tdata->cipher_iv.len);
3177 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3178 /* Append data which is padded to a multiple */
3179 /* of the algorithms block size */
3180 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3182 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3183 plaintext_pad_len, 10, 0);
3184 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3185 plaintext_pad_len, 3, 0);
3187 /* Append data which is padded to a multiple */
3188 /* of the algorithms block size */
3189 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3191 /* Create KASUMI operation */
3192 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3193 tdata->cipher_iv.len,
3194 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3195 tdata->validCipherOffsetInBits.len);
3199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3201 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3203 ut_params->obuf = ut_params->op->sym->m_dst;
3204 if (ut_params->obuf)
3205 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3206 plaintext_pad_len, buffer);
3208 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3209 tdata->validCipherOffsetInBits.len >> 3,
3210 plaintext_pad_len, buffer);
3212 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3213 (tdata->validCipherOffsetInBits.len >> 3);
3215 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3217 reference_ciphertext,
3218 tdata->validCipherLenInBits.len,
3219 "KASUMI Ciphertext data not as expected");
3225 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3227 struct crypto_testsuite_params *ts_params = &testsuite_params;
3228 struct crypto_unittest_params *ut_params = &unittest_params;
3231 uint8_t *ciphertext, *plaintext;
3232 unsigned ciphertext_pad_len;
3233 unsigned ciphertext_len;
3235 /* Verify the capabilities */
3236 struct rte_cryptodev_sym_capability_idx cap_idx;
3237 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3238 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3243 /* Create KASUMI session */
3244 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3245 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3246 RTE_CRYPTO_CIPHER_KASUMI_F8,
3247 tdata->key.data, tdata->key.len,
3248 tdata->cipher_iv.len);
3252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3253 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3255 /* Clear mbuf payload */
3256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3257 rte_pktmbuf_tailroom(ut_params->ibuf));
3259 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3260 /* Append data which is padded to a multiple */
3261 /* of the algorithms block size */
3262 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3263 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3264 ciphertext_pad_len);
3265 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3266 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3268 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3270 /* Create KASUMI operation */
3271 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3272 tdata->cipher_iv.len,
3273 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3274 tdata->validCipherOffsetInBits.len);
3278 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3282 ut_params->obuf = ut_params->op->sym->m_dst;
3283 if (ut_params->obuf)
3284 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3286 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3288 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3290 const uint8_t *reference_plaintext = tdata->plaintext.data +
3291 (tdata->validCipherOffsetInBits.len >> 3);
3293 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3295 reference_plaintext,
3296 tdata->validCipherLenInBits.len,
3297 "KASUMI Plaintext data not as expected");
3302 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3304 struct crypto_testsuite_params *ts_params = &testsuite_params;
3305 struct crypto_unittest_params *ut_params = &unittest_params;
3308 uint8_t *ciphertext, *plaintext;
3309 unsigned ciphertext_pad_len;
3310 unsigned ciphertext_len;
3312 /* Verify the capabilities */
3313 struct rte_cryptodev_sym_capability_idx cap_idx;
3314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3315 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3316 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3320 /* Create KASUMI session */
3321 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3322 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3323 RTE_CRYPTO_CIPHER_KASUMI_F8,
3324 tdata->key.data, tdata->key.len,
3325 tdata->cipher_iv.len);
3329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3331 /* Clear mbuf payload */
3332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3333 rte_pktmbuf_tailroom(ut_params->ibuf));
3335 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3336 /* Append data which is padded to a multiple */
3337 /* of the algorithms block size */
3338 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3339 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3340 ciphertext_pad_len);
3341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3343 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3345 /* Create KASUMI operation */
3346 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3347 tdata->cipher_iv.len,
3348 tdata->ciphertext.len,
3349 tdata->validCipherOffsetInBits.len);
3353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3357 ut_params->obuf = ut_params->op->sym->m_dst;
3358 if (ut_params->obuf)
3359 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3361 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3363 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3365 const uint8_t *reference_plaintext = tdata->plaintext.data +
3366 (tdata->validCipherOffsetInBits.len >> 3);
3368 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3370 reference_plaintext,
3371 tdata->validCipherLenInBits.len,
3372 "KASUMI Plaintext data not as expected");
3377 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3379 struct crypto_testsuite_params *ts_params = &testsuite_params;
3380 struct crypto_unittest_params *ut_params = &unittest_params;
3383 uint8_t *plaintext, *ciphertext;
3384 unsigned plaintext_pad_len;
3385 unsigned plaintext_len;
3387 /* Verify the capabilities */
3388 struct rte_cryptodev_sym_capability_idx cap_idx;
3389 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3390 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3391 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3395 /* Create SNOW 3G session */
3396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3397 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3399 tdata->key.data, tdata->key.len,
3400 tdata->cipher_iv.len);
3404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3406 /* Clear mbuf payload */
3407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3408 rte_pktmbuf_tailroom(ut_params->ibuf));
3410 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3411 /* Append data which is padded to a multiple of */
3412 /* the algorithms block size */
3413 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3418 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3420 /* Create SNOW 3G operation */
3421 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3422 tdata->cipher_iv.len,
3423 tdata->validCipherLenInBits.len,
3428 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3430 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3432 ut_params->obuf = ut_params->op->sym->m_dst;
3433 if (ut_params->obuf)
3434 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3436 ciphertext = plaintext;
3438 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3441 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3443 tdata->ciphertext.data,
3444 tdata->validDataLenInBits.len,
3445 "SNOW 3G Ciphertext data not as expected");
3451 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3453 struct crypto_testsuite_params *ts_params = &testsuite_params;
3454 struct crypto_unittest_params *ut_params = &unittest_params;
3455 uint8_t *plaintext, *ciphertext;
3458 unsigned plaintext_pad_len;
3459 unsigned plaintext_len;
3461 /* Verify the capabilities */
3462 struct rte_cryptodev_sym_capability_idx cap_idx;
3463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3464 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3469 /* Create SNOW 3G session */
3470 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3472 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3473 tdata->key.data, tdata->key.len,
3474 tdata->cipher_iv.len);
3478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3481 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3482 "Failed to allocate input buffer in mempool");
3483 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3484 "Failed to allocate output buffer in mempool");
3486 /* Clear mbuf payload */
3487 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3488 rte_pktmbuf_tailroom(ut_params->ibuf));
3490 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3491 /* Append data which is padded to a multiple of */
3492 /* the algorithms block size */
3493 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3494 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3496 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3497 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3499 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3501 /* Create SNOW 3G operation */
3502 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3503 tdata->cipher_iv.len,
3504 tdata->validCipherLenInBits.len,
3509 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3511 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3513 ut_params->obuf = ut_params->op->sym->m_dst;
3514 if (ut_params->obuf)
3515 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3517 ciphertext = plaintext;
3519 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3524 tdata->ciphertext.data,
3525 tdata->validDataLenInBits.len,
3526 "SNOW 3G Ciphertext data not as expected");
3531 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3533 struct crypto_testsuite_params *ts_params = &testsuite_params;
3534 struct crypto_unittest_params *ut_params = &unittest_params;
3537 unsigned int plaintext_pad_len;
3538 unsigned int plaintext_len;
3539 uint8_t buffer[10000];
3540 const uint8_t *ciphertext;
3542 struct rte_cryptodev_info dev_info;
3544 /* Verify the capabilities */
3545 struct rte_cryptodev_sym_capability_idx cap_idx;
3546 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3547 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3548 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3554 uint64_t feat_flags = dev_info.feature_flags;
3556 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3557 printf("Device doesn't support out-of-place scatter-gather "
3558 "in both input and output mbufs. "
3563 /* Create SNOW 3G session */
3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3567 tdata->key.data, tdata->key.len,
3568 tdata->cipher_iv.len);
3572 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 /* Append data which is padded to a multiple of */
3574 /* the algorithms block size */
3575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3577 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 10, 0);
3579 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3580 plaintext_pad_len, 3, 0);
3582 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3583 "Failed to allocate input buffer in mempool");
3584 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3585 "Failed to allocate output buffer in mempool");
3587 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3589 /* Create SNOW 3G operation */
3590 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3591 tdata->cipher_iv.len,
3592 tdata->validCipherLenInBits.len,
3597 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3601 ut_params->obuf = ut_params->op->sym->m_dst;
3602 if (ut_params->obuf)
3603 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3604 plaintext_len, buffer);
3606 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3607 plaintext_len, buffer);
3609 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3614 tdata->ciphertext.data,
3615 tdata->validDataLenInBits.len,
3616 "SNOW 3G Ciphertext data not as expected");
3621 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3623 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3625 uint8_t curr_byte, prev_byte;
3626 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3627 uint8_t lower_byte_mask = (1 << offset) - 1;
3630 prev_byte = buffer[0];
3631 buffer[0] >>= offset;
3633 for (i = 1; i < length_in_bytes; i++) {
3634 curr_byte = buffer[i];
3635 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3636 (curr_byte >> offset);
3637 prev_byte = curr_byte;
3642 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3644 struct crypto_testsuite_params *ts_params = &testsuite_params;
3645 struct crypto_unittest_params *ut_params = &unittest_params;
3646 uint8_t *plaintext, *ciphertext;
3648 uint32_t plaintext_len;
3649 uint32_t plaintext_pad_len;
3650 uint8_t extra_offset = 4;
3651 uint8_t *expected_ciphertext_shifted;
3652 struct rte_cryptodev_info dev_info;
3654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3655 uint64_t feat_flags = dev_info.feature_flags;
3657 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3658 ((tdata->validDataLenInBits.len % 8) != 0)) {
3659 printf("Device doesn't support NON-Byte Aligned Data.\n");
3663 /* Verify the capabilities */
3664 struct rte_cryptodev_sym_capability_idx cap_idx;
3665 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3666 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3667 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3671 /* Create SNOW 3G session */
3672 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3673 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3674 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3675 tdata->key.data, tdata->key.len,
3676 tdata->cipher_iv.len);
3680 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3681 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3683 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3684 "Failed to allocate input buffer in mempool");
3685 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3686 "Failed to allocate output buffer in mempool");
3688 /* Clear mbuf payload */
3689 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3690 rte_pktmbuf_tailroom(ut_params->ibuf));
3692 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3694 * Append data which is padded to a
3695 * multiple of the algorithms block size
3697 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3699 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3702 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3704 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3705 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3707 #ifdef RTE_APP_TEST_DEBUG
3708 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3710 /* Create SNOW 3G operation */
3711 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3712 tdata->cipher_iv.len,
3713 tdata->validCipherLenInBits.len,
3718 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3720 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3722 ut_params->obuf = ut_params->op->sym->m_dst;
3723 if (ut_params->obuf)
3724 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3726 ciphertext = plaintext;
3728 #ifdef RTE_APP_TEST_DEBUG
3729 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3732 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3734 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3735 "failed to reserve memory for ciphertext shifted\n");
3737 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3738 ceil_byte_length(tdata->ciphertext.len));
3739 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3742 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3744 expected_ciphertext_shifted,
3745 tdata->validDataLenInBits.len,
3747 "SNOW 3G Ciphertext data not as expected");
3751 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3753 struct crypto_testsuite_params *ts_params = &testsuite_params;
3754 struct crypto_unittest_params *ut_params = &unittest_params;
3758 uint8_t *plaintext, *ciphertext;
3759 unsigned ciphertext_pad_len;
3760 unsigned ciphertext_len;
3762 /* Verify the capabilities */
3763 struct rte_cryptodev_sym_capability_idx cap_idx;
3764 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3765 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3766 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3770 /* Create SNOW 3G session */
3771 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3772 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3773 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3774 tdata->key.data, tdata->key.len,
3775 tdata->cipher_iv.len);
3779 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3781 /* Clear mbuf payload */
3782 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3783 rte_pktmbuf_tailroom(ut_params->ibuf));
3785 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3786 /* Append data which is padded to a multiple of */
3787 /* the algorithms block size */
3788 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3789 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3790 ciphertext_pad_len);
3791 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3793 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3795 /* Create SNOW 3G operation */
3796 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3797 tdata->cipher_iv.len,
3798 tdata->validCipherLenInBits.len,
3799 tdata->cipher.offset_bits);
3803 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3805 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3806 ut_params->obuf = ut_params->op->sym->m_dst;
3807 if (ut_params->obuf)
3808 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3810 plaintext = ciphertext;
3812 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3815 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3816 tdata->plaintext.data,
3817 tdata->validDataLenInBits.len,
3818 "SNOW 3G Plaintext data not as expected");
3822 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3824 struct crypto_testsuite_params *ts_params = &testsuite_params;
3825 struct crypto_unittest_params *ut_params = &unittest_params;
3829 uint8_t *plaintext, *ciphertext;
3830 unsigned ciphertext_pad_len;
3831 unsigned ciphertext_len;
3833 /* Verify the capabilities */
3834 struct rte_cryptodev_sym_capability_idx cap_idx;
3835 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3836 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3837 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3841 /* Create SNOW 3G session */
3842 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3843 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3844 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3845 tdata->key.data, tdata->key.len,
3846 tdata->cipher_iv.len);
3850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3853 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3854 "Failed to allocate input buffer");
3855 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3856 "Failed to allocate output buffer");
3858 /* Clear mbuf payload */
3859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3860 rte_pktmbuf_tailroom(ut_params->ibuf));
3862 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3863 rte_pktmbuf_tailroom(ut_params->obuf));
3865 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3866 /* Append data which is padded to a multiple of */
3867 /* the algorithms block size */
3868 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3869 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3870 ciphertext_pad_len);
3871 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3872 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3874 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3876 /* Create SNOW 3G operation */
3877 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3878 tdata->cipher_iv.len,
3879 tdata->validCipherLenInBits.len,
3884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3886 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3887 ut_params->obuf = ut_params->op->sym->m_dst;
3888 if (ut_params->obuf)
3889 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3891 plaintext = ciphertext;
3893 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3897 tdata->plaintext.data,
3898 tdata->validDataLenInBits.len,
3899 "SNOW 3G Plaintext data not as expected");
3904 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3906 struct crypto_testsuite_params *ts_params = &testsuite_params;
3907 struct crypto_unittest_params *ut_params = &unittest_params;
3911 uint8_t *plaintext, *ciphertext;
3912 unsigned int plaintext_pad_len;
3913 unsigned int plaintext_len;
3915 struct rte_cryptodev_info dev_info;
3916 struct rte_cryptodev_sym_capability_idx cap_idx;
3918 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3919 uint64_t feat_flags = dev_info.feature_flags;
3921 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3922 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3923 (tdata->validDataLenInBits.len % 8 != 0))) {
3924 printf("Device doesn't support NON-Byte Aligned Data.\n");
3928 /* Check if device supports ZUC EEA3 */
3929 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3930 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3932 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3936 /* Check if device supports ZUC EIA3 */
3937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3938 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3944 /* Create ZUC session */
3945 retval = create_zuc_cipher_auth_encrypt_generate_session(
3946 ts_params->valid_devs[0],
3950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3952 /* clear mbuf payload */
3953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 rte_pktmbuf_tailroom(ut_params->ibuf));
3956 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3957 /* Append data which is padded to a multiple of */
3958 /* the algorithms block size */
3959 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3960 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3964 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3966 /* Create ZUC operation */
3967 retval = create_zuc_cipher_hash_generate_operation(tdata);
3971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3974 ut_params->obuf = ut_params->op->sym->m_src;
3975 if (ut_params->obuf)
3976 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3978 ciphertext = plaintext;
3980 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3982 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3984 tdata->ciphertext.data,
3985 tdata->validDataLenInBits.len,
3986 "ZUC Ciphertext data not as expected");
3988 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3989 + plaintext_pad_len;
3992 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3996 "ZUC Generated auth tag not as expected");
4001 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4003 struct crypto_testsuite_params *ts_params = &testsuite_params;
4004 struct crypto_unittest_params *ut_params = &unittest_params;
4008 uint8_t *plaintext, *ciphertext;
4009 unsigned plaintext_pad_len;
4010 unsigned plaintext_len;
4012 /* Verify the capabilities */
4013 struct rte_cryptodev_sym_capability_idx cap_idx;
4014 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4015 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4016 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4020 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4025 /* Create SNOW 3G session */
4026 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4027 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4028 RTE_CRYPTO_AUTH_OP_GENERATE,
4029 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4030 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4031 tdata->key.data, tdata->key.len,
4032 tdata->auth_iv.len, tdata->digest.len,
4033 tdata->cipher_iv.len);
4036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4038 /* clear mbuf payload */
4039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4040 rte_pktmbuf_tailroom(ut_params->ibuf));
4042 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4043 /* Append data which is padded to a multiple of */
4044 /* the algorithms block size */
4045 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4046 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4048 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4050 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4052 /* Create SNOW 3G operation */
4053 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4054 tdata->digest.len, tdata->auth_iv.data,
4056 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4057 tdata->cipher_iv.data, tdata->cipher_iv.len,
4058 tdata->validCipherLenInBits.len,
4060 tdata->validAuthLenInBits.len,
4066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4069 ut_params->obuf = ut_params->op->sym->m_src;
4070 if (ut_params->obuf)
4071 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4073 ciphertext = plaintext;
4075 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4077 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4079 tdata->ciphertext.data,
4080 tdata->validDataLenInBits.len,
4081 "SNOW 3G Ciphertext data not as expected");
4083 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4084 + plaintext_pad_len;
4087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4090 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4091 "SNOW 3G Generated auth tag not as expected");
4096 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4097 uint8_t op_mode, uint8_t verify)
4099 struct crypto_testsuite_params *ts_params = &testsuite_params;
4100 struct crypto_unittest_params *ut_params = &unittest_params;
4104 uint8_t *plaintext = NULL, *ciphertext = NULL;
4105 unsigned int plaintext_pad_len;
4106 unsigned int plaintext_len;
4107 unsigned int ciphertext_pad_len;
4108 unsigned int ciphertext_len;
4110 struct rte_cryptodev_info dev_info;
4112 /* Verify the capabilities */
4113 struct rte_cryptodev_sym_capability_idx cap_idx;
4114 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4115 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4116 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4120 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4125 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4127 uint64_t feat_flags = dev_info.feature_flags;
4129 if (op_mode == OUT_OF_PLACE) {
4130 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4131 printf("Device doesn't support digest encrypted.\n");
4136 /* Create SNOW 3G session */
4137 retval = create_wireless_algo_auth_cipher_session(
4138 ts_params->valid_devs[0],
4139 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4140 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4141 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4142 : RTE_CRYPTO_AUTH_OP_GENERATE),
4143 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4144 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4145 tdata->key.data, tdata->key.len,
4146 tdata->auth_iv.len, tdata->digest.len,
4147 tdata->cipher_iv.len);
4152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4153 if (op_mode == OUT_OF_PLACE)
4154 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4156 /* clear mbuf payload */
4157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4158 rte_pktmbuf_tailroom(ut_params->ibuf));
4159 if (op_mode == OUT_OF_PLACE)
4160 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4161 rte_pktmbuf_tailroom(ut_params->obuf));
4163 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4164 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4165 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4166 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4169 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4170 ciphertext_pad_len);
4171 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4172 if (op_mode == OUT_OF_PLACE)
4173 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4174 debug_hexdump(stdout, "ciphertext:", ciphertext,
4177 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4179 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4180 if (op_mode == OUT_OF_PLACE)
4181 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4182 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4185 /* Create SNOW 3G operation */
4186 retval = create_wireless_algo_auth_cipher_operation(
4187 tdata->digest.data, tdata->digest.len,
4188 tdata->cipher_iv.data, tdata->cipher_iv.len,
4189 tdata->auth_iv.data, tdata->auth_iv.len,
4190 (tdata->digest.offset_bytes == 0 ?
4191 (verify ? ciphertext_pad_len : plaintext_pad_len)
4192 : tdata->digest.offset_bytes),
4193 tdata->validCipherLenInBits.len,
4194 tdata->cipher.offset_bits,
4195 tdata->validAuthLenInBits.len,
4196 tdata->auth.offset_bits,
4197 op_mode, 0, verify);
4202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4207 ut_params->obuf = (op_mode == IN_PLACE ?
4208 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4211 if (ut_params->obuf)
4212 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4215 plaintext = ciphertext +
4216 (tdata->cipher.offset_bits >> 3);
4218 debug_hexdump(stdout, "plaintext:", plaintext,
4219 (tdata->plaintext.len >> 3) - tdata->digest.len);
4220 debug_hexdump(stdout, "plaintext expected:",
4221 tdata->plaintext.data,
4222 (tdata->plaintext.len >> 3) - tdata->digest.len);
4224 if (ut_params->obuf)
4225 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4228 ciphertext = plaintext;
4230 debug_hexdump(stdout, "ciphertext:", ciphertext,
4232 debug_hexdump(stdout, "ciphertext expected:",
4233 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4235 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4236 + (tdata->digest.offset_bytes == 0 ?
4237 plaintext_pad_len : tdata->digest.offset_bytes);
4239 debug_hexdump(stdout, "digest:", ut_params->digest,
4241 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4247 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4249 tdata->plaintext.data,
4250 tdata->plaintext.len >> 3,
4251 "SNOW 3G Plaintext data not as expected");
4253 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4255 tdata->ciphertext.data,
4256 tdata->validDataLenInBits.len,
4257 "SNOW 3G Ciphertext data not as expected");
4259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4262 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4263 "SNOW 3G Generated auth tag not as expected");
4269 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4270 uint8_t op_mode, uint8_t verify)
4272 struct crypto_testsuite_params *ts_params = &testsuite_params;
4273 struct crypto_unittest_params *ut_params = &unittest_params;
4277 const uint8_t *plaintext = NULL;
4278 const uint8_t *ciphertext = NULL;
4279 const uint8_t *digest = NULL;
4280 unsigned int plaintext_pad_len;
4281 unsigned int plaintext_len;
4282 unsigned int ciphertext_pad_len;
4283 unsigned int ciphertext_len;
4284 uint8_t buffer[10000];
4285 uint8_t digest_buffer[10000];
4287 struct rte_cryptodev_info dev_info;
4289 /* Verify the capabilities */
4290 struct rte_cryptodev_sym_capability_idx cap_idx;
4291 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4292 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4293 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4297 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4302 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4304 uint64_t feat_flags = dev_info.feature_flags;
4306 if (op_mode == IN_PLACE) {
4307 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4308 printf("Device doesn't support in-place scatter-gather "
4309 "in both input and output mbufs.\n");
4313 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4314 printf("Device doesn't support out-of-place scatter-gather "
4315 "in both input and output mbufs.\n");
4318 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4319 printf("Device doesn't support digest encrypted.\n");
4324 /* Create SNOW 3G session */
4325 retval = create_wireless_algo_auth_cipher_session(
4326 ts_params->valid_devs[0],
4327 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4328 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4329 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4330 : RTE_CRYPTO_AUTH_OP_GENERATE),
4331 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4332 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4333 tdata->key.data, tdata->key.len,
4334 tdata->auth_iv.len, tdata->digest.len,
4335 tdata->cipher_iv.len);
4340 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4341 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4342 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4345 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4346 plaintext_pad_len, 15, 0);
4347 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4348 "Failed to allocate input buffer in mempool");
4350 if (op_mode == OUT_OF_PLACE) {
4351 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4352 plaintext_pad_len, 15, 0);
4353 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4354 "Failed to allocate output buffer in mempool");
4358 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4359 tdata->ciphertext.data);
4360 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4361 ciphertext_len, buffer);
4362 debug_hexdump(stdout, "ciphertext:", ciphertext,
4365 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4366 tdata->plaintext.data);
4367 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4368 plaintext_len, buffer);
4369 debug_hexdump(stdout, "plaintext:", plaintext,
4372 memset(buffer, 0, sizeof(buffer));
4374 /* Create SNOW 3G operation */
4375 retval = create_wireless_algo_auth_cipher_operation(
4376 tdata->digest.data, tdata->digest.len,
4377 tdata->cipher_iv.data, tdata->cipher_iv.len,
4378 tdata->auth_iv.data, tdata->auth_iv.len,
4379 (tdata->digest.offset_bytes == 0 ?
4380 (verify ? ciphertext_pad_len : plaintext_pad_len)
4381 : tdata->digest.offset_bytes),
4382 tdata->validCipherLenInBits.len,
4383 tdata->cipher.offset_bits,
4384 tdata->validAuthLenInBits.len,
4385 tdata->auth.offset_bits,
4386 op_mode, 1, verify);
4391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4394 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4396 ut_params->obuf = (op_mode == IN_PLACE ?
4397 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4400 if (ut_params->obuf)
4401 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4402 plaintext_len, buffer);
4404 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4405 plaintext_len, buffer);
4407 debug_hexdump(stdout, "plaintext:", plaintext,
4408 (tdata->plaintext.len >> 3) - tdata->digest.len);
4409 debug_hexdump(stdout, "plaintext expected:",
4410 tdata->plaintext.data,
4411 (tdata->plaintext.len >> 3) - tdata->digest.len);
4413 if (ut_params->obuf)
4414 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4415 ciphertext_len, buffer);
4417 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4418 ciphertext_len, buffer);
4420 debug_hexdump(stdout, "ciphertext:", ciphertext,
4422 debug_hexdump(stdout, "ciphertext expected:",
4423 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4425 if (ut_params->obuf)
4426 digest = rte_pktmbuf_read(ut_params->obuf,
4427 (tdata->digest.offset_bytes == 0 ?
4428 plaintext_pad_len : tdata->digest.offset_bytes),
4429 tdata->digest.len, digest_buffer);
4431 digest = rte_pktmbuf_read(ut_params->ibuf,
4432 (tdata->digest.offset_bytes == 0 ?
4433 plaintext_pad_len : tdata->digest.offset_bytes),
4434 tdata->digest.len, digest_buffer);
4436 debug_hexdump(stdout, "digest:", digest,
4438 debug_hexdump(stdout, "digest expected:",
4439 tdata->digest.data, tdata->digest.len);
4444 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4446 tdata->plaintext.data,
4447 tdata->plaintext.len >> 3,
4448 "SNOW 3G Plaintext data not as expected");
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4452 tdata->ciphertext.data,
4453 tdata->validDataLenInBits.len,
4454 "SNOW 3G Ciphertext data not as expected");
4456 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4459 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4460 "SNOW 3G Generated auth tag not as expected");
4466 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4467 uint8_t op_mode, uint8_t verify)
4469 struct crypto_testsuite_params *ts_params = &testsuite_params;
4470 struct crypto_unittest_params *ut_params = &unittest_params;
4474 uint8_t *plaintext = NULL, *ciphertext = NULL;
4475 unsigned int plaintext_pad_len;
4476 unsigned int plaintext_len;
4477 unsigned int ciphertext_pad_len;
4478 unsigned int ciphertext_len;
4480 struct rte_cryptodev_info dev_info;
4482 /* Verify the capabilities */
4483 struct rte_cryptodev_sym_capability_idx cap_idx;
4484 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4485 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4486 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4489 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4490 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4491 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4495 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4497 uint64_t feat_flags = dev_info.feature_flags;
4499 if (op_mode == OUT_OF_PLACE) {
4500 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4501 printf("Device doesn't support digest encrypted.\n");
4506 /* Create KASUMI session */
4507 retval = create_wireless_algo_auth_cipher_session(
4508 ts_params->valid_devs[0],
4509 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4510 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4511 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4512 : RTE_CRYPTO_AUTH_OP_GENERATE),
4513 RTE_CRYPTO_AUTH_KASUMI_F9,
4514 RTE_CRYPTO_CIPHER_KASUMI_F8,
4515 tdata->key.data, tdata->key.len,
4516 0, tdata->digest.len,
4517 tdata->cipher_iv.len);
4522 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4523 if (op_mode == OUT_OF_PLACE)
4524 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4526 /* clear mbuf payload */
4527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4528 rte_pktmbuf_tailroom(ut_params->ibuf));
4529 if (op_mode == OUT_OF_PLACE)
4530 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4531 rte_pktmbuf_tailroom(ut_params->obuf));
4533 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4534 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4535 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4539 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4540 ciphertext_pad_len);
4541 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4542 if (op_mode == OUT_OF_PLACE)
4543 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4544 debug_hexdump(stdout, "ciphertext:", ciphertext,
4547 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4549 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4550 if (op_mode == OUT_OF_PLACE)
4551 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4552 debug_hexdump(stdout, "plaintext:", plaintext,
4556 /* Create KASUMI operation */
4557 retval = create_wireless_algo_auth_cipher_operation(
4558 tdata->digest.data, tdata->digest.len,
4559 tdata->cipher_iv.data, tdata->cipher_iv.len,
4561 (tdata->digest.offset_bytes == 0 ?
4562 (verify ? ciphertext_pad_len : plaintext_pad_len)
4563 : tdata->digest.offset_bytes),
4564 tdata->validCipherLenInBits.len,
4565 tdata->validCipherOffsetInBits.len,
4566 tdata->validAuthLenInBits.len,
4568 op_mode, 0, verify);
4573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4578 ut_params->obuf = (op_mode == IN_PLACE ?
4579 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4583 if (ut_params->obuf)
4584 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4587 plaintext = ciphertext;
4589 debug_hexdump(stdout, "plaintext:", plaintext,
4590 (tdata->plaintext.len >> 3) - tdata->digest.len);
4591 debug_hexdump(stdout, "plaintext expected:",
4592 tdata->plaintext.data,
4593 (tdata->plaintext.len >> 3) - tdata->digest.len);
4595 if (ut_params->obuf)
4596 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4599 ciphertext = plaintext;
4601 debug_hexdump(stdout, "ciphertext:", ciphertext,
4603 debug_hexdump(stdout, "ciphertext expected:",
4604 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4606 ut_params->digest = rte_pktmbuf_mtod(
4607 ut_params->obuf, uint8_t *) +
4608 (tdata->digest.offset_bytes == 0 ?
4609 plaintext_pad_len : tdata->digest.offset_bytes);
4611 debug_hexdump(stdout, "digest:", ut_params->digest,
4613 debug_hexdump(stdout, "digest expected:",
4614 tdata->digest.data, tdata->digest.len);
4619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4621 tdata->plaintext.data,
4622 tdata->plaintext.len >> 3,
4623 "KASUMI Plaintext data not as expected");
4625 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4627 tdata->ciphertext.data,
4628 tdata->ciphertext.len >> 3,
4629 "KASUMI Ciphertext data not as expected");
4631 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4634 DIGEST_BYTE_LENGTH_KASUMI_F9,
4635 "KASUMI Generated auth tag not as expected");
4641 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4642 uint8_t op_mode, uint8_t verify)
4644 struct crypto_testsuite_params *ts_params = &testsuite_params;
4645 struct crypto_unittest_params *ut_params = &unittest_params;
4649 const uint8_t *plaintext = NULL;
4650 const uint8_t *ciphertext = NULL;
4651 const uint8_t *digest = NULL;
4652 unsigned int plaintext_pad_len;
4653 unsigned int plaintext_len;
4654 unsigned int ciphertext_pad_len;
4655 unsigned int ciphertext_len;
4656 uint8_t buffer[10000];
4657 uint8_t digest_buffer[10000];
4659 struct rte_cryptodev_info dev_info;
4661 /* Verify the capabilities */
4662 struct rte_cryptodev_sym_capability_idx cap_idx;
4663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4664 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4669 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4670 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4674 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4676 uint64_t feat_flags = dev_info.feature_flags;
4678 if (op_mode == IN_PLACE) {
4679 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4680 printf("Device doesn't support in-place scatter-gather "
4681 "in both input and output mbufs.\n");
4685 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4686 printf("Device doesn't support out-of-place scatter-gather "
4687 "in both input and output mbufs.\n");
4690 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4691 printf("Device doesn't support digest encrypted.\n");
4696 /* Create KASUMI session */
4697 retval = create_wireless_algo_auth_cipher_session(
4698 ts_params->valid_devs[0],
4699 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4700 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4701 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4702 : RTE_CRYPTO_AUTH_OP_GENERATE),
4703 RTE_CRYPTO_AUTH_KASUMI_F9,
4704 RTE_CRYPTO_CIPHER_KASUMI_F8,
4705 tdata->key.data, tdata->key.len,
4706 0, tdata->digest.len,
4707 tdata->cipher_iv.len);
4712 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4714 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4715 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4717 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4718 plaintext_pad_len, 15, 0);
4719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4720 "Failed to allocate input buffer in mempool");
4722 if (op_mode == OUT_OF_PLACE) {
4723 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4724 plaintext_pad_len, 15, 0);
4725 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4726 "Failed to allocate output buffer in mempool");
4730 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4731 tdata->ciphertext.data);
4732 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4733 ciphertext_len, buffer);
4734 debug_hexdump(stdout, "ciphertext:", ciphertext,
4737 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4738 tdata->plaintext.data);
4739 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4740 plaintext_len, buffer);
4741 debug_hexdump(stdout, "plaintext:", plaintext,
4744 memset(buffer, 0, sizeof(buffer));
4746 /* Create KASUMI operation */
4747 retval = create_wireless_algo_auth_cipher_operation(
4748 tdata->digest.data, tdata->digest.len,
4749 tdata->cipher_iv.data, tdata->cipher_iv.len,
4751 (tdata->digest.offset_bytes == 0 ?
4752 (verify ? ciphertext_pad_len : plaintext_pad_len)
4753 : tdata->digest.offset_bytes),
4754 tdata->validCipherLenInBits.len,
4755 tdata->validCipherOffsetInBits.len,
4756 tdata->validAuthLenInBits.len,
4758 op_mode, 1, verify);
4763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4766 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4768 ut_params->obuf = (op_mode == IN_PLACE ?
4769 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4772 if (ut_params->obuf)
4773 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4774 plaintext_len, buffer);
4776 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4777 plaintext_len, buffer);
4779 debug_hexdump(stdout, "plaintext:", plaintext,
4780 (tdata->plaintext.len >> 3) - tdata->digest.len);
4781 debug_hexdump(stdout, "plaintext expected:",
4782 tdata->plaintext.data,
4783 (tdata->plaintext.len >> 3) - tdata->digest.len);
4785 if (ut_params->obuf)
4786 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4787 ciphertext_len, buffer);
4789 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4790 ciphertext_len, buffer);
4792 debug_hexdump(stdout, "ciphertext:", ciphertext,
4794 debug_hexdump(stdout, "ciphertext expected:",
4795 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4797 if (ut_params->obuf)
4798 digest = rte_pktmbuf_read(ut_params->obuf,
4799 (tdata->digest.offset_bytes == 0 ?
4800 plaintext_pad_len : tdata->digest.offset_bytes),
4801 tdata->digest.len, digest_buffer);
4803 digest = rte_pktmbuf_read(ut_params->ibuf,
4804 (tdata->digest.offset_bytes == 0 ?
4805 plaintext_pad_len : tdata->digest.offset_bytes),
4806 tdata->digest.len, digest_buffer);
4808 debug_hexdump(stdout, "digest:", digest,
4810 debug_hexdump(stdout, "digest expected:",
4811 tdata->digest.data, tdata->digest.len);
4816 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4818 tdata->plaintext.data,
4819 tdata->plaintext.len >> 3,
4820 "KASUMI Plaintext data not as expected");
4822 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4824 tdata->ciphertext.data,
4825 tdata->validDataLenInBits.len,
4826 "KASUMI Ciphertext data not as expected");
4828 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4831 DIGEST_BYTE_LENGTH_KASUMI_F9,
4832 "KASUMI Generated auth tag not as expected");
4838 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4840 struct crypto_testsuite_params *ts_params = &testsuite_params;
4841 struct crypto_unittest_params *ut_params = &unittest_params;
4845 uint8_t *plaintext, *ciphertext;
4846 unsigned plaintext_pad_len;
4847 unsigned plaintext_len;
4849 /* Verify the capabilities */
4850 struct rte_cryptodev_sym_capability_idx cap_idx;
4851 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4852 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4853 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4857 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4862 /* Create KASUMI session */
4863 retval = create_wireless_algo_cipher_auth_session(
4864 ts_params->valid_devs[0],
4865 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4866 RTE_CRYPTO_AUTH_OP_GENERATE,
4867 RTE_CRYPTO_AUTH_KASUMI_F9,
4868 RTE_CRYPTO_CIPHER_KASUMI_F8,
4869 tdata->key.data, tdata->key.len,
4870 0, tdata->digest.len,
4871 tdata->cipher_iv.len);
4875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4877 /* clear mbuf payload */
4878 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4879 rte_pktmbuf_tailroom(ut_params->ibuf));
4881 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4882 /* Append data which is padded to a multiple of */
4883 /* the algorithms block size */
4884 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4885 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4887 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4889 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4891 /* Create KASUMI operation */
4892 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4893 tdata->digest.len, NULL, 0,
4894 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4895 tdata->cipher_iv.data, tdata->cipher_iv.len,
4896 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4897 tdata->validCipherOffsetInBits.len,
4898 tdata->validAuthLenInBits.len,
4904 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4906 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4908 if (ut_params->op->sym->m_dst)
4909 ut_params->obuf = ut_params->op->sym->m_dst;
4911 ut_params->obuf = ut_params->op->sym->m_src;
4913 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4914 tdata->validCipherOffsetInBits.len >> 3);
4916 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4917 + plaintext_pad_len;
4919 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4920 (tdata->validCipherOffsetInBits.len >> 3);
4922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4924 reference_ciphertext,
4925 tdata->validCipherLenInBits.len,
4926 "KASUMI Ciphertext data not as expected");
4929 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4932 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4933 "KASUMI Generated auth tag not as expected");
4938 test_zuc_encryption(const struct wireless_test_data *tdata)
4940 struct crypto_testsuite_params *ts_params = &testsuite_params;
4941 struct crypto_unittest_params *ut_params = &unittest_params;
4944 uint8_t *plaintext, *ciphertext;
4945 unsigned plaintext_pad_len;
4946 unsigned plaintext_len;
4948 struct rte_cryptodev_sym_capability_idx cap_idx;
4950 /* Check if device supports ZUC EEA3 */
4951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4952 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4958 /* Create ZUC session */
4959 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4960 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4961 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4962 tdata->key.data, tdata->key.len,
4963 tdata->cipher_iv.len);
4967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4969 /* Clear mbuf payload */
4970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4971 rte_pktmbuf_tailroom(ut_params->ibuf));
4973 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4974 /* Append data which is padded to a multiple */
4975 /* of the algorithms block size */
4976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4977 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4979 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4981 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4983 /* Create ZUC operation */
4984 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4985 tdata->cipher_iv.len,
4986 tdata->plaintext.len,
4991 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4993 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4995 ut_params->obuf = ut_params->op->sym->m_dst;
4996 if (ut_params->obuf)
4997 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4999 ciphertext = plaintext;
5001 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5006 tdata->ciphertext.data,
5007 tdata->validCipherLenInBits.len,
5008 "ZUC Ciphertext data not as expected");
5013 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5015 struct crypto_testsuite_params *ts_params = &testsuite_params;
5016 struct crypto_unittest_params *ut_params = &unittest_params;
5020 unsigned int plaintext_pad_len;
5021 unsigned int plaintext_len;
5022 const uint8_t *ciphertext;
5023 uint8_t ciphertext_buffer[2048];
5024 struct rte_cryptodev_info dev_info;
5026 struct rte_cryptodev_sym_capability_idx cap_idx;
5028 /* Check if device supports ZUC EEA3 */
5029 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5030 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5032 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5036 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5038 uint64_t feat_flags = dev_info.feature_flags;
5040 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5041 printf("Device doesn't support in-place scatter-gather. "
5046 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5048 /* Append data which is padded to a multiple */
5049 /* of the algorithms block size */
5050 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5052 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5053 plaintext_pad_len, 10, 0);
5055 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5056 tdata->plaintext.data);
5058 /* Create ZUC session */
5059 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5060 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5061 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5062 tdata->key.data, tdata->key.len,
5063 tdata->cipher_iv.len);
5067 /* Clear mbuf payload */
5069 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5071 /* Create ZUC operation */
5072 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5073 tdata->cipher_iv.len, tdata->plaintext.len,
5078 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5080 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5082 ut_params->obuf = ut_params->op->sym->m_dst;
5083 if (ut_params->obuf)
5084 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5085 0, plaintext_len, ciphertext_buffer);
5087 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5088 0, plaintext_len, ciphertext_buffer);
5091 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5094 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5096 tdata->ciphertext.data,
5097 tdata->validCipherLenInBits.len,
5098 "ZUC Ciphertext data not as expected");
5104 test_zuc_authentication(const struct wireless_test_data *tdata)
5106 struct crypto_testsuite_params *ts_params = &testsuite_params;
5107 struct crypto_unittest_params *ut_params = &unittest_params;
5110 unsigned plaintext_pad_len;
5111 unsigned plaintext_len;
5114 struct rte_cryptodev_sym_capability_idx cap_idx;
5115 struct rte_cryptodev_info dev_info;
5117 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5118 uint64_t feat_flags = dev_info.feature_flags;
5120 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5121 (tdata->validAuthLenInBits.len % 8 != 0)) {
5122 printf("Device doesn't support NON-Byte Aligned Data.\n");
5126 /* Check if device supports ZUC EIA3 */
5127 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5128 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5130 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5134 /* Create ZUC session */
5135 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5136 tdata->key.data, tdata->key.len,
5137 tdata->auth_iv.len, tdata->digest.len,
5138 RTE_CRYPTO_AUTH_OP_GENERATE,
5139 RTE_CRYPTO_AUTH_ZUC_EIA3);
5143 /* alloc mbuf and set payload */
5144 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5147 rte_pktmbuf_tailroom(ut_params->ibuf));
5149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5150 /* Append data which is padded to a multiple of */
5151 /* the algorithms block size */
5152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5157 /* Create ZUC operation */
5158 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5159 tdata->auth_iv.data, tdata->auth_iv.len,
5160 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5161 tdata->validAuthLenInBits.len,
5166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5168 ut_params->obuf = ut_params->op->sym->m_src;
5169 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5170 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5171 + plaintext_pad_len;
5174 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5178 "ZUC Generated auth tag not as expected");
5184 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5185 uint8_t op_mode, uint8_t verify)
5187 struct crypto_testsuite_params *ts_params = &testsuite_params;
5188 struct crypto_unittest_params *ut_params = &unittest_params;
5192 uint8_t *plaintext = NULL, *ciphertext = NULL;
5193 unsigned int plaintext_pad_len;
5194 unsigned int plaintext_len;
5195 unsigned int ciphertext_pad_len;
5196 unsigned int ciphertext_len;
5198 struct rte_cryptodev_info dev_info;
5199 struct rte_cryptodev_sym_capability_idx cap_idx;
5201 /* Check if device supports ZUC EIA3 */
5202 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5203 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5209 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5211 uint64_t feat_flags = dev_info.feature_flags;
5213 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5214 printf("Device doesn't support digest encrypted.\n");
5217 if (op_mode == IN_PLACE) {
5218 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5219 printf("Device doesn't support in-place scatter-gather "
5220 "in both input and output mbufs.\n");
5224 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5225 printf("Device doesn't support out-of-place scatter-gather "
5226 "in both input and output mbufs.\n");
5231 /* Create ZUC session */
5232 retval = create_wireless_algo_auth_cipher_session(
5233 ts_params->valid_devs[0],
5234 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5235 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5236 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5237 : RTE_CRYPTO_AUTH_OP_GENERATE),
5238 RTE_CRYPTO_AUTH_ZUC_EIA3,
5239 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5240 tdata->key.data, tdata->key.len,
5241 tdata->auth_iv.len, tdata->digest.len,
5242 tdata->cipher_iv.len);
5247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5248 if (op_mode == OUT_OF_PLACE)
5249 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5251 /* clear mbuf payload */
5252 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5253 rte_pktmbuf_tailroom(ut_params->ibuf));
5254 if (op_mode == OUT_OF_PLACE)
5255 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5256 rte_pktmbuf_tailroom(ut_params->obuf));
5258 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5259 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5260 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5264 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5265 ciphertext_pad_len);
5266 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5267 if (op_mode == OUT_OF_PLACE)
5268 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5269 debug_hexdump(stdout, "ciphertext:", ciphertext,
5272 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5274 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5275 if (op_mode == OUT_OF_PLACE)
5276 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5277 debug_hexdump(stdout, "plaintext:", plaintext,
5281 /* Create ZUC operation */
5282 retval = create_wireless_algo_auth_cipher_operation(
5283 tdata->digest.data, tdata->digest.len,
5284 tdata->cipher_iv.data, tdata->cipher_iv.len,
5285 tdata->auth_iv.data, tdata->auth_iv.len,
5286 (tdata->digest.offset_bytes == 0 ?
5287 (verify ? ciphertext_pad_len : plaintext_pad_len)
5288 : tdata->digest.offset_bytes),
5289 tdata->validCipherLenInBits.len,
5290 tdata->validCipherOffsetInBits.len,
5291 tdata->validAuthLenInBits.len,
5293 op_mode, 0, verify);
5298 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5301 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5303 ut_params->obuf = (op_mode == IN_PLACE ?
5304 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5308 if (ut_params->obuf)
5309 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5312 plaintext = ciphertext;
5314 debug_hexdump(stdout, "plaintext:", plaintext,
5315 (tdata->plaintext.len >> 3) - tdata->digest.len);
5316 debug_hexdump(stdout, "plaintext expected:",
5317 tdata->plaintext.data,
5318 (tdata->plaintext.len >> 3) - tdata->digest.len);
5320 if (ut_params->obuf)
5321 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5324 ciphertext = plaintext;
5326 debug_hexdump(stdout, "ciphertext:", ciphertext,
5328 debug_hexdump(stdout, "ciphertext expected:",
5329 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5331 ut_params->digest = rte_pktmbuf_mtod(
5332 ut_params->obuf, uint8_t *) +
5333 (tdata->digest.offset_bytes == 0 ?
5334 plaintext_pad_len : tdata->digest.offset_bytes);
5336 debug_hexdump(stdout, "digest:", ut_params->digest,
5338 debug_hexdump(stdout, "digest expected:",
5339 tdata->digest.data, tdata->digest.len);
5344 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5346 tdata->plaintext.data,
5347 tdata->plaintext.len >> 3,
5348 "ZUC Plaintext data not as expected");
5350 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5352 tdata->ciphertext.data,
5353 tdata->ciphertext.len >> 3,
5354 "ZUC Ciphertext data not as expected");
5356 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5359 DIGEST_BYTE_LENGTH_KASUMI_F9,
5360 "ZUC Generated auth tag not as expected");
5366 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5367 uint8_t op_mode, uint8_t verify)
5369 struct crypto_testsuite_params *ts_params = &testsuite_params;
5370 struct crypto_unittest_params *ut_params = &unittest_params;
5374 const uint8_t *plaintext = NULL;
5375 const uint8_t *ciphertext = NULL;
5376 const uint8_t *digest = NULL;
5377 unsigned int plaintext_pad_len;
5378 unsigned int plaintext_len;
5379 unsigned int ciphertext_pad_len;
5380 unsigned int ciphertext_len;
5381 uint8_t buffer[10000];
5382 uint8_t digest_buffer[10000];
5384 struct rte_cryptodev_info dev_info;
5385 struct rte_cryptodev_sym_capability_idx cap_idx;
5387 /* Check if device supports ZUC EIA3 */
5388 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5389 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5391 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5395 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5397 uint64_t feat_flags = dev_info.feature_flags;
5399 if (op_mode == IN_PLACE) {
5400 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5401 printf("Device doesn't support in-place scatter-gather "
5402 "in both input and output mbufs.\n");
5406 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5407 printf("Device doesn't support out-of-place scatter-gather "
5408 "in both input and output mbufs.\n");
5411 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5412 printf("Device doesn't support digest encrypted.\n");
5417 /* Create ZUC session */
5418 retval = create_wireless_algo_auth_cipher_session(
5419 ts_params->valid_devs[0],
5420 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5421 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5422 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5423 : RTE_CRYPTO_AUTH_OP_GENERATE),
5424 RTE_CRYPTO_AUTH_ZUC_EIA3,
5425 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5426 tdata->key.data, tdata->key.len,
5427 tdata->auth_iv.len, tdata->digest.len,
5428 tdata->cipher_iv.len);
5433 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5434 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5435 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5436 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5438 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5439 plaintext_pad_len, 15, 0);
5440 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5441 "Failed to allocate input buffer in mempool");
5443 if (op_mode == OUT_OF_PLACE) {
5444 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5445 plaintext_pad_len, 15, 0);
5446 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5447 "Failed to allocate output buffer in mempool");
5451 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5452 tdata->ciphertext.data);
5453 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5454 ciphertext_len, buffer);
5455 debug_hexdump(stdout, "ciphertext:", ciphertext,
5458 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5459 tdata->plaintext.data);
5460 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5461 plaintext_len, buffer);
5462 debug_hexdump(stdout, "plaintext:", plaintext,
5465 memset(buffer, 0, sizeof(buffer));
5467 /* Create ZUC operation */
5468 retval = create_wireless_algo_auth_cipher_operation(
5469 tdata->digest.data, tdata->digest.len,
5470 tdata->cipher_iv.data, tdata->cipher_iv.len,
5472 (tdata->digest.offset_bytes == 0 ?
5473 (verify ? ciphertext_pad_len : plaintext_pad_len)
5474 : tdata->digest.offset_bytes),
5475 tdata->validCipherLenInBits.len,
5476 tdata->validCipherOffsetInBits.len,
5477 tdata->validAuthLenInBits.len,
5479 op_mode, 1, verify);
5484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5489 ut_params->obuf = (op_mode == IN_PLACE ?
5490 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5493 if (ut_params->obuf)
5494 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5495 plaintext_len, buffer);
5497 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5498 plaintext_len, buffer);
5500 debug_hexdump(stdout, "plaintext:", plaintext,
5501 (tdata->plaintext.len >> 3) - tdata->digest.len);
5502 debug_hexdump(stdout, "plaintext expected:",
5503 tdata->plaintext.data,
5504 (tdata->plaintext.len >> 3) - tdata->digest.len);
5506 if (ut_params->obuf)
5507 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5508 ciphertext_len, buffer);
5510 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5511 ciphertext_len, buffer);
5513 debug_hexdump(stdout, "ciphertext:", ciphertext,
5515 debug_hexdump(stdout, "ciphertext expected:",
5516 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5518 if (ut_params->obuf)
5519 digest = rte_pktmbuf_read(ut_params->obuf,
5520 (tdata->digest.offset_bytes == 0 ?
5521 plaintext_pad_len : tdata->digest.offset_bytes),
5522 tdata->digest.len, digest_buffer);
5524 digest = rte_pktmbuf_read(ut_params->ibuf,
5525 (tdata->digest.offset_bytes == 0 ?
5526 plaintext_pad_len : tdata->digest.offset_bytes),
5527 tdata->digest.len, digest_buffer);
5529 debug_hexdump(stdout, "digest:", digest,
5531 debug_hexdump(stdout, "digest expected:",
5532 tdata->digest.data, tdata->digest.len);
5537 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5539 tdata->plaintext.data,
5540 tdata->plaintext.len >> 3,
5541 "ZUC Plaintext data not as expected");
5543 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5545 tdata->ciphertext.data,
5546 tdata->validDataLenInBits.len,
5547 "ZUC Ciphertext data not as expected");
5549 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5552 DIGEST_BYTE_LENGTH_KASUMI_F9,
5553 "ZUC Generated auth tag not as expected");
5559 test_kasumi_encryption_test_case_1(void)
5561 return test_kasumi_encryption(&kasumi_test_case_1);
5565 test_kasumi_encryption_test_case_1_sgl(void)
5567 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5571 test_kasumi_encryption_test_case_1_oop(void)
5573 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5577 test_kasumi_encryption_test_case_1_oop_sgl(void)
5579 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5583 test_kasumi_encryption_test_case_2(void)
5585 return test_kasumi_encryption(&kasumi_test_case_2);
5589 test_kasumi_encryption_test_case_3(void)
5591 return test_kasumi_encryption(&kasumi_test_case_3);
5595 test_kasumi_encryption_test_case_4(void)
5597 return test_kasumi_encryption(&kasumi_test_case_4);
5601 test_kasumi_encryption_test_case_5(void)
5603 return test_kasumi_encryption(&kasumi_test_case_5);
5607 test_kasumi_decryption_test_case_1(void)
5609 return test_kasumi_decryption(&kasumi_test_case_1);
5613 test_kasumi_decryption_test_case_1_oop(void)
5615 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5619 test_kasumi_decryption_test_case_2(void)
5621 return test_kasumi_decryption(&kasumi_test_case_2);
5625 test_kasumi_decryption_test_case_3(void)
5627 return test_kasumi_decryption(&kasumi_test_case_3);
5631 test_kasumi_decryption_test_case_4(void)
5633 return test_kasumi_decryption(&kasumi_test_case_4);
5637 test_kasumi_decryption_test_case_5(void)
5639 return test_kasumi_decryption(&kasumi_test_case_5);
5642 test_snow3g_encryption_test_case_1(void)
5644 return test_snow3g_encryption(&snow3g_test_case_1);
5648 test_snow3g_encryption_test_case_1_oop(void)
5650 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5654 test_snow3g_encryption_test_case_1_oop_sgl(void)
5656 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5661 test_snow3g_encryption_test_case_1_offset_oop(void)
5663 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5667 test_snow3g_encryption_test_case_2(void)
5669 return test_snow3g_encryption(&snow3g_test_case_2);
5673 test_snow3g_encryption_test_case_3(void)
5675 return test_snow3g_encryption(&snow3g_test_case_3);
5679 test_snow3g_encryption_test_case_4(void)
5681 return test_snow3g_encryption(&snow3g_test_case_4);
5685 test_snow3g_encryption_test_case_5(void)
5687 return test_snow3g_encryption(&snow3g_test_case_5);
5691 test_snow3g_decryption_test_case_1(void)
5693 return test_snow3g_decryption(&snow3g_test_case_1);
5697 test_snow3g_decryption_test_case_1_oop(void)
5699 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5703 test_snow3g_decryption_test_case_2(void)
5705 return test_snow3g_decryption(&snow3g_test_case_2);
5709 test_snow3g_decryption_test_case_3(void)
5711 return test_snow3g_decryption(&snow3g_test_case_3);
5715 test_snow3g_decryption_test_case_4(void)
5717 return test_snow3g_decryption(&snow3g_test_case_4);
5721 test_snow3g_decryption_test_case_5(void)
5723 return test_snow3g_decryption(&snow3g_test_case_5);
5727 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5728 * Pattern digest from snow3g_test_data must be allocated as
5729 * 4 last bytes in plaintext.
5732 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5733 struct snow3g_hash_test_data *output)
5735 if ((pattern != NULL) && (output != NULL)) {
5736 output->key.len = pattern->key.len;
5738 memcpy(output->key.data,
5739 pattern->key.data, pattern->key.len);
5741 output->auth_iv.len = pattern->auth_iv.len;
5743 memcpy(output->auth_iv.data,
5744 pattern->auth_iv.data, pattern->auth_iv.len);
5746 output->plaintext.len = pattern->plaintext.len;
5748 memcpy(output->plaintext.data,
5749 pattern->plaintext.data, pattern->plaintext.len >> 3);
5751 output->digest.len = pattern->digest.len;
5753 memcpy(output->digest.data,
5754 &pattern->plaintext.data[pattern->digest.offset_bytes],
5755 pattern->digest.len);
5757 output->validAuthLenInBits.len =
5758 pattern->validAuthLenInBits.len;
5763 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5766 test_snow3g_decryption_with_digest_test_case_1(void)
5768 struct snow3g_hash_test_data snow3g_hash_data;
5771 * Function prepare data for hash veryfication test case.
5772 * Digest is allocated in 4 last bytes in plaintext, pattern.
5774 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5776 return test_snow3g_decryption(&snow3g_test_case_7) &
5777 test_snow3g_authentication_verify(&snow3g_hash_data);
5781 test_snow3g_cipher_auth_test_case_1(void)
5783 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5787 test_snow3g_auth_cipher_test_case_1(void)
5789 return test_snow3g_auth_cipher(
5790 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5794 test_snow3g_auth_cipher_test_case_2(void)
5796 return test_snow3g_auth_cipher(
5797 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5801 test_snow3g_auth_cipher_test_case_2_oop(void)
5803 return test_snow3g_auth_cipher(
5804 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5808 test_snow3g_auth_cipher_part_digest_enc(void)
5810 return test_snow3g_auth_cipher(
5811 &snow3g_auth_cipher_partial_digest_encryption,
5816 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5818 return test_snow3g_auth_cipher(
5819 &snow3g_auth_cipher_partial_digest_encryption,
5824 test_snow3g_auth_cipher_test_case_3_sgl(void)
5826 return test_snow3g_auth_cipher_sgl(
5827 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5831 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5833 return test_snow3g_auth_cipher_sgl(
5834 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5838 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5840 return test_snow3g_auth_cipher_sgl(
5841 &snow3g_auth_cipher_partial_digest_encryption,
5846 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5848 return test_snow3g_auth_cipher_sgl(
5849 &snow3g_auth_cipher_partial_digest_encryption,
5854 test_snow3g_auth_cipher_verify_test_case_1(void)
5856 return test_snow3g_auth_cipher(
5857 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5861 test_snow3g_auth_cipher_verify_test_case_2(void)
5863 return test_snow3g_auth_cipher(
5864 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5868 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5870 return test_snow3g_auth_cipher(
5871 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5875 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5877 return test_snow3g_auth_cipher(
5878 &snow3g_auth_cipher_partial_digest_encryption,
5883 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5885 return test_snow3g_auth_cipher(
5886 &snow3g_auth_cipher_partial_digest_encryption,
5891 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5893 return test_snow3g_auth_cipher_sgl(
5894 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5898 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5900 return test_snow3g_auth_cipher_sgl(
5901 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5905 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5907 return test_snow3g_auth_cipher_sgl(
5908 &snow3g_auth_cipher_partial_digest_encryption,
5913 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5915 return test_snow3g_auth_cipher_sgl(
5916 &snow3g_auth_cipher_partial_digest_encryption,
5921 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5923 return test_snow3g_auth_cipher(
5924 &snow3g_test_case_7, IN_PLACE, 0);
5928 test_kasumi_auth_cipher_test_case_1(void)
5930 return test_kasumi_auth_cipher(
5931 &kasumi_test_case_3, IN_PLACE, 0);
5935 test_kasumi_auth_cipher_test_case_2(void)
5937 return test_kasumi_auth_cipher(
5938 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5942 test_kasumi_auth_cipher_test_case_2_oop(void)
5944 return test_kasumi_auth_cipher(
5945 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5949 test_kasumi_auth_cipher_test_case_2_sgl(void)
5951 return test_kasumi_auth_cipher_sgl(
5952 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5956 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5958 return test_kasumi_auth_cipher_sgl(
5959 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5963 test_kasumi_auth_cipher_verify_test_case_1(void)
5965 return test_kasumi_auth_cipher(
5966 &kasumi_test_case_3, IN_PLACE, 1);
5970 test_kasumi_auth_cipher_verify_test_case_2(void)
5972 return test_kasumi_auth_cipher(
5973 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5977 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5979 return test_kasumi_auth_cipher(
5980 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5984 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5986 return test_kasumi_auth_cipher_sgl(
5987 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5991 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5993 return test_kasumi_auth_cipher_sgl(
5994 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5998 test_kasumi_cipher_auth_test_case_1(void)
6000 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6004 test_zuc_encryption_test_case_1(void)
6006 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6010 test_zuc_encryption_test_case_2(void)
6012 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6016 test_zuc_encryption_test_case_3(void)
6018 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6022 test_zuc_encryption_test_case_4(void)
6024 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6028 test_zuc_encryption_test_case_5(void)
6030 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6034 test_zuc_encryption_test_case_6_sgl(void)
6036 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6040 test_zuc_hash_generate_test_case_1(void)
6042 return test_zuc_authentication(&zuc_test_case_auth_1b);
6046 test_zuc_hash_generate_test_case_2(void)
6048 return test_zuc_authentication(&zuc_test_case_auth_90b);
6052 test_zuc_hash_generate_test_case_3(void)
6054 return test_zuc_authentication(&zuc_test_case_auth_577b);
6058 test_zuc_hash_generate_test_case_4(void)
6060 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6064 test_zuc_hash_generate_test_case_5(void)
6066 return test_zuc_authentication(&zuc_test_auth_5670b);
6070 test_zuc_hash_generate_test_case_6(void)
6072 return test_zuc_authentication(&zuc_test_case_auth_128b);
6076 test_zuc_hash_generate_test_case_7(void)
6078 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6082 test_zuc_hash_generate_test_case_8(void)
6084 return test_zuc_authentication(&zuc_test_case_auth_584b);
6088 test_zuc_cipher_auth_test_case_1(void)
6090 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6094 test_zuc_cipher_auth_test_case_2(void)
6096 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6100 test_zuc_auth_cipher_test_case_1(void)
6102 return test_zuc_auth_cipher(
6103 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6107 test_zuc_auth_cipher_test_case_1_oop(void)
6109 return test_zuc_auth_cipher(
6110 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6114 test_zuc_auth_cipher_test_case_1_sgl(void)
6116 return test_zuc_auth_cipher_sgl(
6117 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6121 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6123 return test_zuc_auth_cipher_sgl(
6124 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6128 test_zuc_auth_cipher_verify_test_case_1(void)
6130 return test_zuc_auth_cipher(
6131 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6135 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6137 return test_zuc_auth_cipher(
6138 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6142 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6144 return test_zuc_auth_cipher_sgl(
6145 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6149 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6151 return test_zuc_auth_cipher_sgl(
6152 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6156 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6158 uint8_t dev_id = testsuite_params.valid_devs[0];
6160 struct rte_cryptodev_sym_capability_idx cap_idx;
6162 /* Check if device supports particular cipher algorithm */
6163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6164 cap_idx.algo.cipher = tdata->cipher_algo;
6165 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6168 /* Check if device supports particular hash algorithm */
6169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6170 cap_idx.algo.auth = tdata->auth_algo;
6171 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6178 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6179 uint8_t op_mode, uint8_t verify)
6181 struct crypto_testsuite_params *ts_params = &testsuite_params;
6182 struct crypto_unittest_params *ut_params = &unittest_params;
6186 uint8_t *plaintext = NULL, *ciphertext = NULL;
6187 unsigned int plaintext_pad_len;
6188 unsigned int plaintext_len;
6189 unsigned int ciphertext_pad_len;
6190 unsigned int ciphertext_len;
6192 struct rte_cryptodev_info dev_info;
6193 struct rte_crypto_op *op;
6195 /* Check if device supports particular algorithms separately */
6196 if (test_mixed_check_if_unsupported(tdata))
6199 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6201 uint64_t feat_flags = dev_info.feature_flags;
6203 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6204 printf("Device doesn't support digest encrypted.\n");
6208 /* Create the session */
6210 retval = create_wireless_algo_cipher_auth_session(
6211 ts_params->valid_devs[0],
6212 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6213 RTE_CRYPTO_AUTH_OP_VERIFY,
6216 tdata->auth_key.data, tdata->auth_key.len,
6217 tdata->auth_iv.len, tdata->digest_enc.len,
6218 tdata->cipher_iv.len);
6220 retval = create_wireless_algo_auth_cipher_session(
6221 ts_params->valid_devs[0],
6222 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6223 RTE_CRYPTO_AUTH_OP_GENERATE,
6226 tdata->auth_key.data, tdata->auth_key.len,
6227 tdata->auth_iv.len, tdata->digest_enc.len,
6228 tdata->cipher_iv.len);
6232 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6233 if (op_mode == OUT_OF_PLACE)
6234 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6236 /* clear mbuf payload */
6237 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6238 rte_pktmbuf_tailroom(ut_params->ibuf));
6239 if (op_mode == OUT_OF_PLACE)
6240 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6241 rte_pktmbuf_tailroom(ut_params->obuf));
6243 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6244 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6245 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6246 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6249 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6250 ciphertext_pad_len);
6251 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6252 if (op_mode == OUT_OF_PLACE)
6253 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6254 debug_hexdump(stdout, "ciphertext:", ciphertext,
6257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6260 if (op_mode == OUT_OF_PLACE)
6261 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6262 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6265 /* Create the operation */
6266 retval = create_wireless_algo_auth_cipher_operation(
6267 tdata->digest_enc.data, tdata->digest_enc.len,
6268 tdata->cipher_iv.data, tdata->cipher_iv.len,
6269 tdata->auth_iv.data, tdata->auth_iv.len,
6270 (tdata->digest_enc.offset == 0 ?
6272 : tdata->digest_enc.offset),
6273 tdata->validCipherLen.len_bits,
6274 tdata->cipher.offset_bits,
6275 tdata->validAuthLen.len_bits,
6276 tdata->auth.offset_bits,
6277 op_mode, 0, verify);
6282 op = process_crypto_request(ts_params->valid_devs[0],
6285 /* Check if the op failed because the device doesn't */
6286 /* support this particular combination of algorithms */
6287 if (op == NULL && ut_params->op->status ==
6288 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6289 printf("Device doesn't support this mixed combination. "
6295 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6297 ut_params->obuf = (op_mode == IN_PLACE ?
6298 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6301 if (ut_params->obuf)
6302 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6305 plaintext = ciphertext +
6306 (tdata->cipher.offset_bits >> 3);
6308 debug_hexdump(stdout, "plaintext:", plaintext,
6309 tdata->plaintext.len_bits >> 3);
6310 debug_hexdump(stdout, "plaintext expected:",
6311 tdata->plaintext.data,
6312 tdata->plaintext.len_bits >> 3);
6314 if (ut_params->obuf)
6315 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6318 ciphertext = plaintext;
6320 debug_hexdump(stdout, "ciphertext:", ciphertext,
6322 debug_hexdump(stdout, "ciphertext expected:",
6323 tdata->ciphertext.data,
6324 tdata->ciphertext.len_bits >> 3);
6326 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6327 + (tdata->digest_enc.offset == 0 ?
6328 plaintext_pad_len : tdata->digest_enc.offset);
6330 debug_hexdump(stdout, "digest:", ut_params->digest,
6331 tdata->digest_enc.len);
6332 debug_hexdump(stdout, "digest expected:",
6333 tdata->digest_enc.data,
6334 tdata->digest_enc.len);
6339 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6341 tdata->plaintext.data,
6342 tdata->plaintext.len_bits >> 3,
6343 "Plaintext data not as expected");
6345 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6347 tdata->ciphertext.data,
6348 tdata->validDataLen.len_bits,
6349 "Ciphertext data not as expected");
6351 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6353 tdata->digest_enc.data,
6354 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6355 "Generated auth tag not as expected");
6358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6359 "crypto op processing failed");
6365 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6366 uint8_t op_mode, uint8_t verify)
6368 struct crypto_testsuite_params *ts_params = &testsuite_params;
6369 struct crypto_unittest_params *ut_params = &unittest_params;
6373 const uint8_t *plaintext = NULL;
6374 const uint8_t *ciphertext = NULL;
6375 const uint8_t *digest = NULL;
6376 unsigned int plaintext_pad_len;
6377 unsigned int plaintext_len;
6378 unsigned int ciphertext_pad_len;
6379 unsigned int ciphertext_len;
6380 uint8_t buffer[10000];
6381 uint8_t digest_buffer[10000];
6383 struct rte_cryptodev_info dev_info;
6384 struct rte_crypto_op *op;
6386 /* Check if device supports particular algorithms */
6387 if (test_mixed_check_if_unsupported(tdata))
6390 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6392 uint64_t feat_flags = dev_info.feature_flags;
6394 if (op_mode == IN_PLACE) {
6395 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6396 printf("Device doesn't support in-place scatter-gather "
6397 "in both input and output mbufs.\n");
6401 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6402 printf("Device doesn't support out-of-place scatter-gather "
6403 "in both input and output mbufs.\n");
6406 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6407 printf("Device doesn't support digest encrypted.\n");
6412 /* Create the session */
6414 retval = create_wireless_algo_cipher_auth_session(
6415 ts_params->valid_devs[0],
6416 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6417 RTE_CRYPTO_AUTH_OP_VERIFY,
6420 tdata->auth_key.data, tdata->auth_key.len,
6421 tdata->auth_iv.len, tdata->digest_enc.len,
6422 tdata->cipher_iv.len);
6424 retval = create_wireless_algo_auth_cipher_session(
6425 ts_params->valid_devs[0],
6426 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6427 RTE_CRYPTO_AUTH_OP_GENERATE,
6430 tdata->auth_key.data, tdata->auth_key.len,
6431 tdata->auth_iv.len, tdata->digest_enc.len,
6432 tdata->cipher_iv.len);
6436 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6437 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6438 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6439 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6441 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6442 ciphertext_pad_len, 15, 0);
6443 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6444 "Failed to allocate input buffer in mempool");
6446 if (op_mode == OUT_OF_PLACE) {
6447 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6448 plaintext_pad_len, 15, 0);
6449 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6450 "Failed to allocate output buffer in mempool");
6454 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6455 tdata->ciphertext.data);
6456 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6457 ciphertext_len, buffer);
6458 debug_hexdump(stdout, "ciphertext:", ciphertext,
6461 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6462 tdata->plaintext.data);
6463 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6464 plaintext_len, buffer);
6465 debug_hexdump(stdout, "plaintext:", plaintext,
6468 memset(buffer, 0, sizeof(buffer));
6470 /* Create the operation */
6471 retval = create_wireless_algo_auth_cipher_operation(
6472 tdata->digest_enc.data, tdata->digest_enc.len,
6473 tdata->cipher_iv.data, tdata->cipher_iv.len,
6474 tdata->auth_iv.data, tdata->auth_iv.len,
6475 (tdata->digest_enc.offset == 0 ?
6477 : tdata->digest_enc.offset),
6478 tdata->validCipherLen.len_bits,
6479 tdata->cipher.offset_bits,
6480 tdata->validAuthLen.len_bits,
6481 tdata->auth.offset_bits,
6482 op_mode, 1, verify);
6487 op = process_crypto_request(ts_params->valid_devs[0],
6490 /* Check if the op failed because the device doesn't */
6491 /* support this particular combination of algorithms */
6492 if (op == NULL && ut_params->op->status ==
6493 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6494 printf("Device doesn't support this mixed combination. "
6501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6503 ut_params->obuf = (op_mode == IN_PLACE ?
6504 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6507 if (ut_params->obuf)
6508 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6509 plaintext_len, buffer);
6511 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6512 plaintext_len, buffer);
6514 debug_hexdump(stdout, "plaintext:", plaintext,
6515 (tdata->plaintext.len_bits >> 3) -
6516 tdata->digest_enc.len);
6517 debug_hexdump(stdout, "plaintext expected:",
6518 tdata->plaintext.data,
6519 (tdata->plaintext.len_bits >> 3) -
6520 tdata->digest_enc.len);
6522 if (ut_params->obuf)
6523 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6524 ciphertext_len, buffer);
6526 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6527 ciphertext_len, buffer);
6529 debug_hexdump(stdout, "ciphertext:", ciphertext,
6531 debug_hexdump(stdout, "ciphertext expected:",
6532 tdata->ciphertext.data,
6533 tdata->ciphertext.len_bits >> 3);
6535 if (ut_params->obuf)
6536 digest = rte_pktmbuf_read(ut_params->obuf,
6537 (tdata->digest_enc.offset == 0 ?
6539 tdata->digest_enc.offset),
6540 tdata->digest_enc.len, digest_buffer);
6542 digest = rte_pktmbuf_read(ut_params->ibuf,
6543 (tdata->digest_enc.offset == 0 ?
6545 tdata->digest_enc.offset),
6546 tdata->digest_enc.len, digest_buffer);
6548 debug_hexdump(stdout, "digest:", digest,
6549 tdata->digest_enc.len);
6550 debug_hexdump(stdout, "digest expected:",
6551 tdata->digest_enc.data, tdata->digest_enc.len);
6556 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6558 tdata->plaintext.data,
6559 tdata->plaintext.len_bits >> 3,
6560 "Plaintext data not as expected");
6562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6564 tdata->ciphertext.data,
6565 tdata->validDataLen.len_bits,
6566 "Ciphertext data not as expected");
6567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6569 tdata->digest_enc.data,
6570 tdata->digest_enc.len,
6571 "Generated auth tag not as expected");
6574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6575 "crypto op processing failed");
6580 /** AUTH AES CMAC + CIPHER AES CTR */
6583 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6585 return test_mixed_auth_cipher(
6586 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6590 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6592 return test_mixed_auth_cipher(
6593 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6597 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6599 return test_mixed_auth_cipher_sgl(
6600 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6604 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6606 return test_mixed_auth_cipher_sgl(
6607 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6611 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6618 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6620 return test_mixed_auth_cipher(
6621 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6625 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6627 return test_mixed_auth_cipher_sgl(
6628 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6632 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6634 return test_mixed_auth_cipher_sgl(
6635 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6638 /** MIXED AUTH + CIPHER */
6641 test_auth_zuc_cipher_snow_test_case_1(void)
6643 return test_mixed_auth_cipher(
6644 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6648 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6650 return test_mixed_auth_cipher(
6651 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6655 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6657 return test_mixed_auth_cipher(
6658 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6662 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6664 return test_mixed_auth_cipher(
6665 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6669 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6671 return test_mixed_auth_cipher(
6672 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6676 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6678 return test_mixed_auth_cipher(
6679 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6683 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6685 return test_mixed_auth_cipher(
6686 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6690 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6692 return test_mixed_auth_cipher(
6693 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6697 test_auth_snow_cipher_zuc_test_case_1(void)
6699 return test_mixed_auth_cipher(
6700 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6704 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6706 return test_mixed_auth_cipher(
6707 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6711 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6713 return test_mixed_auth_cipher(
6714 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6718 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6720 return test_mixed_auth_cipher(
6721 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6725 test_auth_null_cipher_snow_test_case_1(void)
6727 return test_mixed_auth_cipher(
6728 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6732 test_verify_auth_null_cipher_snow_test_case_1(void)
6734 return test_mixed_auth_cipher(
6735 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6739 test_auth_null_cipher_zuc_test_case_1(void)
6741 return test_mixed_auth_cipher(
6742 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6746 test_verify_auth_null_cipher_zuc_test_case_1(void)
6748 return test_mixed_auth_cipher(
6749 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6753 test_auth_snow_cipher_null_test_case_1(void)
6755 return test_mixed_auth_cipher(
6756 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6760 test_verify_auth_snow_cipher_null_test_case_1(void)
6762 return test_mixed_auth_cipher(
6763 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6767 test_auth_zuc_cipher_null_test_case_1(void)
6769 return test_mixed_auth_cipher(
6770 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6774 test_verify_auth_zuc_cipher_null_test_case_1(void)
6776 return test_mixed_auth_cipher(
6777 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6781 test_auth_null_cipher_aes_ctr_test_case_1(void)
6783 return test_mixed_auth_cipher(
6784 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6788 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6790 return test_mixed_auth_cipher(
6791 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6795 test_auth_aes_cmac_cipher_null_test_case_1(void)
6797 return test_mixed_auth_cipher(
6798 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6802 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6804 return test_mixed_auth_cipher(
6805 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6808 /* ***** AEAD algorithm Tests ***** */
6811 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6812 enum rte_crypto_aead_operation op,
6813 const uint8_t *key, const uint8_t key_len,
6814 const uint16_t aad_len, const uint8_t auth_len,
6817 uint8_t aead_key[key_len];
6819 struct crypto_testsuite_params *ts_params = &testsuite_params;
6820 struct crypto_unittest_params *ut_params = &unittest_params;
6822 memcpy(aead_key, key, key_len);
6824 /* Setup AEAD Parameters */
6825 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6826 ut_params->aead_xform.next = NULL;
6827 ut_params->aead_xform.aead.algo = algo;
6828 ut_params->aead_xform.aead.op = op;
6829 ut_params->aead_xform.aead.key.data = aead_key;
6830 ut_params->aead_xform.aead.key.length = key_len;
6831 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6832 ut_params->aead_xform.aead.iv.length = iv_len;
6833 ut_params->aead_xform.aead.digest_length = auth_len;
6834 ut_params->aead_xform.aead.aad_length = aad_len;
6836 debug_hexdump(stdout, "key:", key, key_len);
6838 /* Create Crypto session*/
6839 ut_params->sess = rte_cryptodev_sym_session_create(
6840 ts_params->session_mpool);
6842 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6843 &ut_params->aead_xform,
6844 ts_params->session_priv_mpool);
6846 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6852 create_aead_xform(struct rte_crypto_op *op,
6853 enum rte_crypto_aead_algorithm algo,
6854 enum rte_crypto_aead_operation aead_op,
6855 uint8_t *key, const uint8_t key_len,
6856 const uint8_t aad_len, const uint8_t auth_len,
6859 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6860 "failed to allocate space for crypto transform");
6862 struct rte_crypto_sym_op *sym_op = op->sym;
6864 /* Setup AEAD Parameters */
6865 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6866 sym_op->xform->next = NULL;
6867 sym_op->xform->aead.algo = algo;
6868 sym_op->xform->aead.op = aead_op;
6869 sym_op->xform->aead.key.data = key;
6870 sym_op->xform->aead.key.length = key_len;
6871 sym_op->xform->aead.iv.offset = IV_OFFSET;
6872 sym_op->xform->aead.iv.length = iv_len;
6873 sym_op->xform->aead.digest_length = auth_len;
6874 sym_op->xform->aead.aad_length = aad_len;
6876 debug_hexdump(stdout, "key:", key, key_len);
6882 create_aead_operation(enum rte_crypto_aead_operation op,
6883 const struct aead_test_data *tdata)
6885 struct crypto_testsuite_params *ts_params = &testsuite_params;
6886 struct crypto_unittest_params *ut_params = &unittest_params;
6888 uint8_t *plaintext, *ciphertext;
6889 unsigned int aad_pad_len, plaintext_pad_len;
6891 /* Generate Crypto op data structure */
6892 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6893 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6894 TEST_ASSERT_NOT_NULL(ut_params->op,
6895 "Failed to allocate symmetric crypto operation struct");
6897 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6899 /* Append aad data */
6900 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6901 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6902 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6904 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6905 "no room to append aad");
6907 sym_op->aead.aad.phys_addr =
6908 rte_pktmbuf_iova(ut_params->ibuf);
6909 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6910 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6911 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6914 /* Append IV at the end of the crypto operation*/
6915 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6916 uint8_t *, IV_OFFSET);
6918 /* Copy IV 1 byte after the IV pointer, according to the API */
6919 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6920 debug_hexdump(stdout, "iv:", iv_ptr,
6923 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6924 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6926 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6927 "no room to append aad");
6929 sym_op->aead.aad.phys_addr =
6930 rte_pktmbuf_iova(ut_params->ibuf);
6931 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6932 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6935 /* Append IV at the end of the crypto operation*/
6936 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6937 uint8_t *, IV_OFFSET);
6939 if (tdata->iv.len == 0) {
6940 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6941 debug_hexdump(stdout, "iv:", iv_ptr,
6944 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6945 debug_hexdump(stdout, "iv:", iv_ptr,
6950 /* Append plaintext/ciphertext */
6951 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6952 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6955 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6957 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6958 debug_hexdump(stdout, "plaintext:", plaintext,
6959 tdata->plaintext.len);
6961 if (ut_params->obuf) {
6962 ciphertext = (uint8_t *)rte_pktmbuf_append(
6964 plaintext_pad_len + aad_pad_len);
6965 TEST_ASSERT_NOT_NULL(ciphertext,
6966 "no room to append ciphertext");
6968 memset(ciphertext + aad_pad_len, 0,
6969 tdata->ciphertext.len);
6972 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6973 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6975 TEST_ASSERT_NOT_NULL(ciphertext,
6976 "no room to append ciphertext");
6978 memcpy(ciphertext, tdata->ciphertext.data,
6979 tdata->ciphertext.len);
6980 debug_hexdump(stdout, "ciphertext:", ciphertext,
6981 tdata->ciphertext.len);
6983 if (ut_params->obuf) {
6984 plaintext = (uint8_t *)rte_pktmbuf_append(
6986 plaintext_pad_len + aad_pad_len);
6987 TEST_ASSERT_NOT_NULL(plaintext,
6988 "no room to append plaintext");
6990 memset(plaintext + aad_pad_len, 0,
6991 tdata->plaintext.len);
6995 /* Append digest data */
6996 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6997 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6998 ut_params->obuf ? ut_params->obuf :
7000 tdata->auth_tag.len);
7001 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7002 "no room to append digest");
7003 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7004 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7005 ut_params->obuf ? ut_params->obuf :
7010 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7011 ut_params->ibuf, tdata->auth_tag.len);
7012 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7013 "no room to append digest");
7014 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7016 plaintext_pad_len + aad_pad_len);
7018 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7019 tdata->auth_tag.len);
7020 debug_hexdump(stdout, "digest:",
7021 sym_op->aead.digest.data,
7022 tdata->auth_tag.len);
7025 sym_op->aead.data.length = tdata->plaintext.len;
7026 sym_op->aead.data.offset = aad_pad_len;
7032 test_authenticated_encryption(const struct aead_test_data *tdata)
7034 struct crypto_testsuite_params *ts_params = &testsuite_params;
7035 struct crypto_unittest_params *ut_params = &unittest_params;
7038 uint8_t *ciphertext, *auth_tag;
7039 uint16_t plaintext_pad_len;
7042 /* Verify the capabilities */
7043 struct rte_cryptodev_sym_capability_idx cap_idx;
7044 const struct rte_cryptodev_symmetric_capability *capability;
7045 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7046 cap_idx.algo.aead = tdata->algo;
7047 capability = rte_cryptodev_sym_capability_get(
7048 ts_params->valid_devs[0], &cap_idx);
7049 if (capability == NULL)
7051 if (rte_cryptodev_sym_capability_check_aead(
7052 capability, tdata->key.len, tdata->auth_tag.len,
7053 tdata->aad.len, tdata->iv.len))
7056 /* Create AEAD session */
7057 retval = create_aead_session(ts_params->valid_devs[0],
7059 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7060 tdata->key.data, tdata->key.len,
7061 tdata->aad.len, tdata->auth_tag.len,
7066 if (tdata->aad.len > MBUF_SIZE) {
7067 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7068 /* Populate full size of add data */
7069 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7070 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7074 /* clear mbuf payload */
7075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7076 rte_pktmbuf_tailroom(ut_params->ibuf));
7078 /* Create AEAD operation */
7079 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7083 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7085 ut_params->op->sym->m_src = ut_params->ibuf;
7087 /* Process crypto operation */
7088 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7089 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7091 TEST_ASSERT_NOT_NULL(
7092 process_crypto_request(ts_params->valid_devs[0],
7093 ut_params->op), "failed to process sym crypto op");
7095 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7096 "crypto op processing failed");
7098 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7100 if (ut_params->op->sym->m_dst) {
7101 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7103 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7104 uint8_t *, plaintext_pad_len);
7106 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7108 ut_params->op->sym->cipher.data.offset);
7109 auth_tag = ciphertext + plaintext_pad_len;
7112 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7113 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7118 tdata->ciphertext.data,
7119 tdata->ciphertext.len,
7120 "Ciphertext data not as expected");
7122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7124 tdata->auth_tag.data,
7125 tdata->auth_tag.len,
7126 "Generated auth tag not as expected");
7132 #ifdef RTE_LIBRTE_SECURITY
7133 /* Basic algorithm run function for async inplace mode.
7134 * Creates a session from input parameters and runs one operation
7135 * on input_vec. Checks the output of the crypto operation against
7139 test_pdcp_proto(int i, int oop,
7140 enum rte_crypto_cipher_operation opc,
7141 enum rte_crypto_auth_operation opa,
7143 unsigned int input_vec_len,
7144 uint8_t *output_vec,
7145 unsigned int output_vec_len)
7147 struct crypto_testsuite_params *ts_params = &testsuite_params;
7148 struct crypto_unittest_params *ut_params = &unittest_params;
7150 int ret = TEST_SUCCESS;
7151 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7152 rte_cryptodev_get_sec_ctx(
7153 ts_params->valid_devs[0]);
7155 /* Verify the capabilities */
7156 struct rte_security_capability_idx sec_cap_idx;
7158 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7159 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7160 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7161 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7164 /* Generate test mbuf data */
7165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7167 /* clear mbuf payload */
7168 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7169 rte_pktmbuf_tailroom(ut_params->ibuf));
7171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7173 memcpy(plaintext, input_vec, input_vec_len);
7175 /* Out of place support */
7178 * For out-op-place we need to alloc another mbuf
7180 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7181 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7184 /* Set crypto type as IPSEC */
7185 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7187 /* Setup Cipher Parameters */
7188 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7189 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7190 ut_params->cipher_xform.cipher.op = opc;
7191 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7192 ut_params->cipher_xform.cipher.key.length =
7193 pdcp_test_params[i].cipher_key_len;
7194 ut_params->cipher_xform.cipher.iv.length = 0;
7196 /* Setup HMAC Parameters if ICV header is required */
7197 if (pdcp_test_params[i].auth_alg != 0) {
7198 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7199 ut_params->auth_xform.next = NULL;
7200 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7201 ut_params->auth_xform.auth.op = opa;
7202 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7203 ut_params->auth_xform.auth.key.length =
7204 pdcp_test_params[i].auth_key_len;
7206 ut_params->cipher_xform.next = &ut_params->auth_xform;
7208 ut_params->cipher_xform.next = NULL;
7211 struct rte_security_session_conf sess_conf = {
7212 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7213 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7215 .bearer = pdcp_test_bearer[i],
7216 .domain = pdcp_test_params[i].domain,
7217 .pkt_dir = pdcp_test_packet_direction[i],
7218 .sn_size = pdcp_test_data_sn_size[i],
7219 .hfn = pdcp_test_hfn[i],
7220 .hfn_threshold = pdcp_test_hfn_threshold[i],
7222 .crypto_xform = &ut_params->cipher_xform
7225 /* Create security session */
7226 ut_params->sec_session = rte_security_session_create(ctx,
7227 &sess_conf, ts_params->session_priv_mpool);
7229 if (!ut_params->sec_session) {
7230 printf("TestCase %s()-%d line %d failed %s: ",
7231 __func__, i, __LINE__, "Failed to allocate session");
7236 /* Generate crypto op data structure */
7237 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7238 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7239 if (!ut_params->op) {
7240 printf("TestCase %s()-%d line %d failed %s: ",
7241 __func__, i, __LINE__,
7242 "Failed to allocate symmetric crypto operation struct");
7247 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7249 /* set crypto operation source mbuf */
7250 ut_params->op->sym->m_src = ut_params->ibuf;
7252 ut_params->op->sym->m_dst = ut_params->obuf;
7254 /* Process crypto operation */
7255 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7257 printf("TestCase %s()-%d line %d failed %s: ",
7258 __func__, i, __LINE__,
7259 "failed to process sym crypto op");
7264 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7265 printf("TestCase %s()-%d line %d failed %s: ",
7266 __func__, i, __LINE__, "crypto op processing failed");
7272 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7275 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7279 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7280 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7281 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7282 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7288 rte_crypto_op_free(ut_params->op);
7289 ut_params->op = NULL;
7291 if (ut_params->sec_session)
7292 rte_security_session_destroy(ctx, ut_params->sec_session);
7293 ut_params->sec_session = NULL;
7295 rte_pktmbuf_free(ut_params->ibuf);
7296 ut_params->ibuf = NULL;
7298 rte_pktmbuf_free(ut_params->obuf);
7299 ut_params->obuf = NULL;
7306 test_pdcp_proto_SGL(int i, int oop,
7307 enum rte_crypto_cipher_operation opc,
7308 enum rte_crypto_auth_operation opa,
7310 unsigned int input_vec_len,
7311 uint8_t *output_vec,
7312 unsigned int output_vec_len,
7314 uint32_t fragsz_oop)
7316 struct crypto_testsuite_params *ts_params = &testsuite_params;
7317 struct crypto_unittest_params *ut_params = &unittest_params;
7319 struct rte_mbuf *buf, *buf_oop = NULL;
7320 int ret = TEST_SUCCESS;
7324 unsigned int trn_data = 0;
7325 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7326 rte_cryptodev_get_sec_ctx(
7327 ts_params->valid_devs[0]);
7329 /* Verify the capabilities */
7330 struct rte_security_capability_idx sec_cap_idx;
7332 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7333 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7334 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7335 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7338 if (fragsz > input_vec_len)
7339 fragsz = input_vec_len;
7341 uint16_t plaintext_len = fragsz;
7342 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7344 if (fragsz_oop > output_vec_len)
7345 frag_size_oop = output_vec_len;
7348 if (input_vec_len % fragsz != 0) {
7349 if (input_vec_len / fragsz + 1 > 16)
7351 } else if (input_vec_len / fragsz > 16)
7354 /* Out of place support */
7357 * For out-op-place we need to alloc another mbuf
7359 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7360 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7361 buf_oop = ut_params->obuf;
7364 /* Generate test mbuf data */
7365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7367 /* clear mbuf payload */
7368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7369 rte_pktmbuf_tailroom(ut_params->ibuf));
7371 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7373 memcpy(plaintext, input_vec, plaintext_len);
7374 trn_data += plaintext_len;
7376 buf = ut_params->ibuf;
7379 * Loop until no more fragments
7382 while (trn_data < input_vec_len) {
7384 to_trn = (input_vec_len - trn_data < fragsz) ?
7385 (input_vec_len - trn_data) : fragsz;
7387 to_trn_tbl[ecx++] = to_trn;
7389 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7392 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7393 rte_pktmbuf_tailroom(buf));
7396 if (oop && !fragsz_oop) {
7398 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7399 buf_oop = buf_oop->next;
7400 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7401 0, rte_pktmbuf_tailroom(buf_oop));
7402 rte_pktmbuf_append(buf_oop, to_trn);
7405 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7408 memcpy(plaintext, input_vec + trn_data, to_trn);
7412 ut_params->ibuf->nb_segs = segs;
7415 if (fragsz_oop && oop) {
7419 trn_data = frag_size_oop;
7420 while (trn_data < output_vec_len) {
7423 (output_vec_len - trn_data <
7425 (output_vec_len - trn_data) :
7428 to_trn_tbl[ecx++] = to_trn;
7431 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7432 buf_oop = buf_oop->next;
7433 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7434 0, rte_pktmbuf_tailroom(buf_oop));
7435 rte_pktmbuf_append(buf_oop, to_trn);
7439 ut_params->obuf->nb_segs = segs;
7442 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7444 /* Setup Cipher Parameters */
7445 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7446 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7447 ut_params->cipher_xform.cipher.op = opc;
7448 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7449 ut_params->cipher_xform.cipher.key.length =
7450 pdcp_test_params[i].cipher_key_len;
7451 ut_params->cipher_xform.cipher.iv.length = 0;
7453 /* Setup HMAC Parameters if ICV header is required */
7454 if (pdcp_test_params[i].auth_alg != 0) {
7455 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7456 ut_params->auth_xform.next = NULL;
7457 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7458 ut_params->auth_xform.auth.op = opa;
7459 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7460 ut_params->auth_xform.auth.key.length =
7461 pdcp_test_params[i].auth_key_len;
7463 ut_params->cipher_xform.next = &ut_params->auth_xform;
7465 ut_params->cipher_xform.next = NULL;
7468 struct rte_security_session_conf sess_conf = {
7469 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7470 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7472 .bearer = pdcp_test_bearer[i],
7473 .domain = pdcp_test_params[i].domain,
7474 .pkt_dir = pdcp_test_packet_direction[i],
7475 .sn_size = pdcp_test_data_sn_size[i],
7476 .hfn = pdcp_test_hfn[i],
7477 .hfn_threshold = pdcp_test_hfn_threshold[i],
7479 .crypto_xform = &ut_params->cipher_xform
7482 /* Create security session */
7483 ut_params->sec_session = rte_security_session_create(ctx,
7484 &sess_conf, ts_params->session_priv_mpool);
7486 if (!ut_params->sec_session) {
7487 printf("TestCase %s()-%d line %d failed %s: ",
7488 __func__, i, __LINE__, "Failed to allocate session");
7493 /* Generate crypto op data structure */
7494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7496 if (!ut_params->op) {
7497 printf("TestCase %s()-%d line %d failed %s: ",
7498 __func__, i, __LINE__,
7499 "Failed to allocate symmetric crypto operation struct");
7504 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7506 /* set crypto operation source mbuf */
7507 ut_params->op->sym->m_src = ut_params->ibuf;
7509 ut_params->op->sym->m_dst = ut_params->obuf;
7511 /* Process crypto operation */
7512 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7514 printf("TestCase %s()-%d line %d failed %s: ",
7515 __func__, i, __LINE__,
7516 "failed to process sym crypto op");
7521 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7522 printf("TestCase %s()-%d line %d failed %s: ",
7523 __func__, i, __LINE__, "crypto op processing failed");
7529 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7532 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7536 fragsz = frag_size_oop;
7537 if (memcmp(ciphertext, output_vec, fragsz)) {
7538 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7539 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7540 rte_hexdump(stdout, "reference", output_vec, fragsz);
7545 buf = ut_params->op->sym->m_src->next;
7547 buf = ut_params->op->sym->m_dst->next;
7549 unsigned int off = fragsz;
7553 ciphertext = rte_pktmbuf_mtod(buf,
7555 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7556 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7557 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7558 rte_hexdump(stdout, "reference", output_vec + off,
7563 off += to_trn_tbl[ecx++];
7567 rte_crypto_op_free(ut_params->op);
7568 ut_params->op = NULL;
7570 if (ut_params->sec_session)
7571 rte_security_session_destroy(ctx, ut_params->sec_session);
7572 ut_params->sec_session = NULL;
7574 rte_pktmbuf_free(ut_params->ibuf);
7575 ut_params->ibuf = NULL;
7577 rte_pktmbuf_free(ut_params->obuf);
7578 ut_params->obuf = NULL;
7585 test_pdcp_proto_cplane_encap(int i)
7587 return test_pdcp_proto(i, 0,
7588 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7589 RTE_CRYPTO_AUTH_OP_GENERATE,
7590 pdcp_test_data_in[i],
7591 pdcp_test_data_in_len[i],
7592 pdcp_test_data_out[i],
7593 pdcp_test_data_in_len[i]+4);
7597 test_pdcp_proto_uplane_encap(int i)
7599 return test_pdcp_proto(i, 0,
7600 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7601 RTE_CRYPTO_AUTH_OP_GENERATE,
7602 pdcp_test_data_in[i],
7603 pdcp_test_data_in_len[i],
7604 pdcp_test_data_out[i],
7605 pdcp_test_data_in_len[i]);
7610 test_pdcp_proto_uplane_encap_with_int(int i)
7612 return test_pdcp_proto(i, 0,
7613 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7614 RTE_CRYPTO_AUTH_OP_GENERATE,
7615 pdcp_test_data_in[i],
7616 pdcp_test_data_in_len[i],
7617 pdcp_test_data_out[i],
7618 pdcp_test_data_in_len[i] + 4);
7622 test_pdcp_proto_cplane_decap(int i)
7624 return test_pdcp_proto(i, 0,
7625 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7626 RTE_CRYPTO_AUTH_OP_VERIFY,
7627 pdcp_test_data_out[i],
7628 pdcp_test_data_in_len[i] + 4,
7629 pdcp_test_data_in[i],
7630 pdcp_test_data_in_len[i]);
7634 test_pdcp_proto_uplane_decap(int i)
7636 return test_pdcp_proto(i, 0,
7637 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7638 RTE_CRYPTO_AUTH_OP_VERIFY,
7639 pdcp_test_data_out[i],
7640 pdcp_test_data_in_len[i],
7641 pdcp_test_data_in[i],
7642 pdcp_test_data_in_len[i]);
7646 test_pdcp_proto_uplane_decap_with_int(int i)
7648 return test_pdcp_proto(i, 0,
7649 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7650 RTE_CRYPTO_AUTH_OP_VERIFY,
7651 pdcp_test_data_out[i],
7652 pdcp_test_data_in_len[i] + 4,
7653 pdcp_test_data_in[i],
7654 pdcp_test_data_in_len[i]);
7658 test_PDCP_PROTO_SGL_in_place_32B(void)
7660 /* i can be used for running any PDCP case
7661 * In this case it is uplane 12-bit AES-SNOW DL encap
7663 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7664 return test_pdcp_proto_SGL(i, IN_PLACE,
7665 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7666 RTE_CRYPTO_AUTH_OP_GENERATE,
7667 pdcp_test_data_in[i],
7668 pdcp_test_data_in_len[i],
7669 pdcp_test_data_out[i],
7670 pdcp_test_data_in_len[i]+4,
7674 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7676 /* i can be used for running any PDCP case
7677 * In this case it is uplane 18-bit NULL-NULL DL encap
7679 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7680 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7681 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7682 RTE_CRYPTO_AUTH_OP_GENERATE,
7683 pdcp_test_data_in[i],
7684 pdcp_test_data_in_len[i],
7685 pdcp_test_data_out[i],
7686 pdcp_test_data_in_len[i]+4,
7690 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7692 /* i can be used for running any PDCP case
7693 * In this case it is uplane 18-bit AES DL encap
7695 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7697 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7698 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7699 RTE_CRYPTO_AUTH_OP_GENERATE,
7700 pdcp_test_data_in[i],
7701 pdcp_test_data_in_len[i],
7702 pdcp_test_data_out[i],
7703 pdcp_test_data_in_len[i],
7707 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7709 /* i can be used for running any PDCP case
7710 * In this case it is cplane 12-bit AES-ZUC DL encap
7712 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7713 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7714 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7715 RTE_CRYPTO_AUTH_OP_GENERATE,
7716 pdcp_test_data_in[i],
7717 pdcp_test_data_in_len[i],
7718 pdcp_test_data_out[i],
7719 pdcp_test_data_in_len[i]+4,
7725 test_AES_GCM_authenticated_encryption_test_case_1(void)
7727 return test_authenticated_encryption(&gcm_test_case_1);
7731 test_AES_GCM_authenticated_encryption_test_case_2(void)
7733 return test_authenticated_encryption(&gcm_test_case_2);
7737 test_AES_GCM_authenticated_encryption_test_case_3(void)
7739 return test_authenticated_encryption(&gcm_test_case_3);
7743 test_AES_GCM_authenticated_encryption_test_case_4(void)
7745 return test_authenticated_encryption(&gcm_test_case_4);
7749 test_AES_GCM_authenticated_encryption_test_case_5(void)
7751 return test_authenticated_encryption(&gcm_test_case_5);
7755 test_AES_GCM_authenticated_encryption_test_case_6(void)
7757 return test_authenticated_encryption(&gcm_test_case_6);
7761 test_AES_GCM_authenticated_encryption_test_case_7(void)
7763 return test_authenticated_encryption(&gcm_test_case_7);
7767 test_AES_GCM_authenticated_encryption_test_case_8(void)
7769 return test_authenticated_encryption(&gcm_test_case_8);
7773 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7775 return test_authenticated_encryption(&gcm_J0_test_case_1);
7779 test_AES_GCM_auth_encryption_test_case_192_1(void)
7781 return test_authenticated_encryption(&gcm_test_case_192_1);
7785 test_AES_GCM_auth_encryption_test_case_192_2(void)
7787 return test_authenticated_encryption(&gcm_test_case_192_2);
7791 test_AES_GCM_auth_encryption_test_case_192_3(void)
7793 return test_authenticated_encryption(&gcm_test_case_192_3);
7797 test_AES_GCM_auth_encryption_test_case_192_4(void)
7799 return test_authenticated_encryption(&gcm_test_case_192_4);
7803 test_AES_GCM_auth_encryption_test_case_192_5(void)
7805 return test_authenticated_encryption(&gcm_test_case_192_5);
7809 test_AES_GCM_auth_encryption_test_case_192_6(void)
7811 return test_authenticated_encryption(&gcm_test_case_192_6);
7815 test_AES_GCM_auth_encryption_test_case_192_7(void)
7817 return test_authenticated_encryption(&gcm_test_case_192_7);
7821 test_AES_GCM_auth_encryption_test_case_256_1(void)
7823 return test_authenticated_encryption(&gcm_test_case_256_1);
7827 test_AES_GCM_auth_encryption_test_case_256_2(void)
7829 return test_authenticated_encryption(&gcm_test_case_256_2);
7833 test_AES_GCM_auth_encryption_test_case_256_3(void)
7835 return test_authenticated_encryption(&gcm_test_case_256_3);
7839 test_AES_GCM_auth_encryption_test_case_256_4(void)
7841 return test_authenticated_encryption(&gcm_test_case_256_4);
7845 test_AES_GCM_auth_encryption_test_case_256_5(void)
7847 return test_authenticated_encryption(&gcm_test_case_256_5);
7851 test_AES_GCM_auth_encryption_test_case_256_6(void)
7853 return test_authenticated_encryption(&gcm_test_case_256_6);
7857 test_AES_GCM_auth_encryption_test_case_256_7(void)
7859 return test_authenticated_encryption(&gcm_test_case_256_7);
7863 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7865 return test_authenticated_encryption(&gcm_test_case_aad_1);
7869 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7871 return test_authenticated_encryption(&gcm_test_case_aad_2);
7875 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7877 struct aead_test_data tdata;
7880 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7881 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7882 tdata.iv.data[0] += 1;
7883 res = test_authenticated_encryption(&tdata);
7884 if (res == -ENOTSUP)
7886 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7887 return TEST_SUCCESS;
7891 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7893 struct aead_test_data tdata;
7896 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7897 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7898 tdata.plaintext.data[0] += 1;
7899 res = test_authenticated_encryption(&tdata);
7900 if (res == -ENOTSUP)
7902 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7903 return TEST_SUCCESS;
7907 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7909 struct aead_test_data tdata;
7912 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7913 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7914 tdata.ciphertext.data[0] += 1;
7915 res = test_authenticated_encryption(&tdata);
7916 if (res == -ENOTSUP)
7918 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7919 return TEST_SUCCESS;
7923 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7925 struct aead_test_data tdata;
7928 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7929 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7931 res = test_authenticated_encryption(&tdata);
7932 if (res == -ENOTSUP)
7934 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7935 return TEST_SUCCESS;
7939 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7941 struct aead_test_data tdata;
7942 uint8_t aad[gcm_test_case_7.aad.len];
7945 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7946 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7947 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7949 tdata.aad.data = aad;
7950 res = test_authenticated_encryption(&tdata);
7951 if (res == -ENOTSUP)
7953 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7954 return TEST_SUCCESS;
7958 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7960 struct aead_test_data tdata;
7963 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7964 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7965 tdata.auth_tag.data[0] += 1;
7966 res = test_authenticated_encryption(&tdata);
7967 if (res == -ENOTSUP)
7969 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7970 return TEST_SUCCESS;
7974 test_authenticated_decryption(const struct aead_test_data *tdata)
7976 struct crypto_testsuite_params *ts_params = &testsuite_params;
7977 struct crypto_unittest_params *ut_params = &unittest_params;
7983 /* Verify the capabilities */
7984 struct rte_cryptodev_sym_capability_idx cap_idx;
7985 const struct rte_cryptodev_symmetric_capability *capability;
7986 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7987 cap_idx.algo.aead = tdata->algo;
7988 capability = rte_cryptodev_sym_capability_get(
7989 ts_params->valid_devs[0], &cap_idx);
7990 if (capability == NULL)
7992 if (rte_cryptodev_sym_capability_check_aead(
7993 capability, tdata->key.len, tdata->auth_tag.len,
7994 tdata->aad.len, tdata->iv.len))
7997 /* Create AEAD session */
7998 retval = create_aead_session(ts_params->valid_devs[0],
8000 RTE_CRYPTO_AEAD_OP_DECRYPT,
8001 tdata->key.data, tdata->key.len,
8002 tdata->aad.len, tdata->auth_tag.len,
8007 /* alloc mbuf and set payload */
8008 if (tdata->aad.len > MBUF_SIZE) {
8009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8010 /* Populate full size of add data */
8011 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8012 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8014 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8016 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8017 rte_pktmbuf_tailroom(ut_params->ibuf));
8019 /* Create AEAD operation */
8020 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8024 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8026 ut_params->op->sym->m_src = ut_params->ibuf;
8028 /* Process crypto operation */
8029 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8030 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8032 TEST_ASSERT_NOT_NULL(
8033 process_crypto_request(ts_params->valid_devs[0],
8034 ut_params->op), "failed to process sym crypto op");
8036 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8037 "crypto op processing failed");
8039 if (ut_params->op->sym->m_dst)
8040 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8043 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8045 ut_params->op->sym->cipher.data.offset);
8047 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8050 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8052 tdata->plaintext.data,
8053 tdata->plaintext.len,
8054 "Plaintext data not as expected");
8056 TEST_ASSERT_EQUAL(ut_params->op->status,
8057 RTE_CRYPTO_OP_STATUS_SUCCESS,
8058 "Authentication failed");
8064 test_AES_GCM_authenticated_decryption_test_case_1(void)
8066 return test_authenticated_decryption(&gcm_test_case_1);
8070 test_AES_GCM_authenticated_decryption_test_case_2(void)
8072 return test_authenticated_decryption(&gcm_test_case_2);
8076 test_AES_GCM_authenticated_decryption_test_case_3(void)
8078 return test_authenticated_decryption(&gcm_test_case_3);
8082 test_AES_GCM_authenticated_decryption_test_case_4(void)
8084 return test_authenticated_decryption(&gcm_test_case_4);
8088 test_AES_GCM_authenticated_decryption_test_case_5(void)
8090 return test_authenticated_decryption(&gcm_test_case_5);
8094 test_AES_GCM_authenticated_decryption_test_case_6(void)
8096 return test_authenticated_decryption(&gcm_test_case_6);
8100 test_AES_GCM_authenticated_decryption_test_case_7(void)
8102 return test_authenticated_decryption(&gcm_test_case_7);
8106 test_AES_GCM_authenticated_decryption_test_case_8(void)
8108 return test_authenticated_decryption(&gcm_test_case_8);
8112 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8114 return test_authenticated_decryption(&gcm_J0_test_case_1);
8118 test_AES_GCM_auth_decryption_test_case_192_1(void)
8120 return test_authenticated_decryption(&gcm_test_case_192_1);
8124 test_AES_GCM_auth_decryption_test_case_192_2(void)
8126 return test_authenticated_decryption(&gcm_test_case_192_2);
8130 test_AES_GCM_auth_decryption_test_case_192_3(void)
8132 return test_authenticated_decryption(&gcm_test_case_192_3);
8136 test_AES_GCM_auth_decryption_test_case_192_4(void)
8138 return test_authenticated_decryption(&gcm_test_case_192_4);
8142 test_AES_GCM_auth_decryption_test_case_192_5(void)
8144 return test_authenticated_decryption(&gcm_test_case_192_5);
8148 test_AES_GCM_auth_decryption_test_case_192_6(void)
8150 return test_authenticated_decryption(&gcm_test_case_192_6);
8154 test_AES_GCM_auth_decryption_test_case_192_7(void)
8156 return test_authenticated_decryption(&gcm_test_case_192_7);
8160 test_AES_GCM_auth_decryption_test_case_256_1(void)
8162 return test_authenticated_decryption(&gcm_test_case_256_1);
8166 test_AES_GCM_auth_decryption_test_case_256_2(void)
8168 return test_authenticated_decryption(&gcm_test_case_256_2);
8172 test_AES_GCM_auth_decryption_test_case_256_3(void)
8174 return test_authenticated_decryption(&gcm_test_case_256_3);
8178 test_AES_GCM_auth_decryption_test_case_256_4(void)
8180 return test_authenticated_decryption(&gcm_test_case_256_4);
8184 test_AES_GCM_auth_decryption_test_case_256_5(void)
8186 return test_authenticated_decryption(&gcm_test_case_256_5);
8190 test_AES_GCM_auth_decryption_test_case_256_6(void)
8192 return test_authenticated_decryption(&gcm_test_case_256_6);
8196 test_AES_GCM_auth_decryption_test_case_256_7(void)
8198 return test_authenticated_decryption(&gcm_test_case_256_7);
8202 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8204 return test_authenticated_decryption(&gcm_test_case_aad_1);
8208 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8210 return test_authenticated_decryption(&gcm_test_case_aad_2);
8214 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8216 struct aead_test_data tdata;
8219 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8220 tdata.iv.data[0] += 1;
8221 res = test_authenticated_decryption(&tdata);
8222 if (res == -ENOTSUP)
8224 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8225 return TEST_SUCCESS;
8229 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8231 struct aead_test_data tdata;
8234 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8235 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8236 tdata.plaintext.data[0] += 1;
8237 res = test_authenticated_decryption(&tdata);
8238 if (res == -ENOTSUP)
8240 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8241 return TEST_SUCCESS;
8245 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8247 struct aead_test_data tdata;
8250 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8251 tdata.ciphertext.data[0] += 1;
8252 res = test_authenticated_decryption(&tdata);
8253 if (res == -ENOTSUP)
8255 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8256 return TEST_SUCCESS;
8260 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8262 struct aead_test_data tdata;
8265 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8267 res = test_authenticated_decryption(&tdata);
8268 if (res == -ENOTSUP)
8270 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8271 return TEST_SUCCESS;
8275 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8277 struct aead_test_data tdata;
8278 uint8_t aad[gcm_test_case_7.aad.len];
8281 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8282 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8284 tdata.aad.data = aad;
8285 res = test_authenticated_decryption(&tdata);
8286 if (res == -ENOTSUP)
8288 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8289 return TEST_SUCCESS;
8293 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8295 struct aead_test_data tdata;
8298 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8299 tdata.auth_tag.data[0] += 1;
8300 res = test_authenticated_decryption(&tdata);
8301 if (res == -ENOTSUP)
8303 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8304 return TEST_SUCCESS;
8308 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8310 struct crypto_testsuite_params *ts_params = &testsuite_params;
8311 struct crypto_unittest_params *ut_params = &unittest_params;
8314 uint8_t *ciphertext, *auth_tag;
8315 uint16_t plaintext_pad_len;
8317 /* Verify the capabilities */
8318 struct rte_cryptodev_sym_capability_idx cap_idx;
8319 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8320 cap_idx.algo.aead = tdata->algo;
8321 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8325 /* not supported with CPU crypto */
8326 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8329 /* Create AEAD session */
8330 retval = create_aead_session(ts_params->valid_devs[0],
8332 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8333 tdata->key.data, tdata->key.len,
8334 tdata->aad.len, tdata->auth_tag.len,
8339 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8340 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8342 /* clear mbuf payload */
8343 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8344 rte_pktmbuf_tailroom(ut_params->ibuf));
8345 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8346 rte_pktmbuf_tailroom(ut_params->obuf));
8348 /* Create AEAD operation */
8349 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8353 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8355 ut_params->op->sym->m_src = ut_params->ibuf;
8356 ut_params->op->sym->m_dst = ut_params->obuf;
8358 /* Process crypto operation */
8359 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8360 ut_params->op), "failed to process sym crypto op");
8362 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8363 "crypto op processing failed");
8365 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8367 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8368 ut_params->op->sym->cipher.data.offset);
8369 auth_tag = ciphertext + plaintext_pad_len;
8371 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8372 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8375 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8377 tdata->ciphertext.data,
8378 tdata->ciphertext.len,
8379 "Ciphertext data not as expected");
8381 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8383 tdata->auth_tag.data,
8384 tdata->auth_tag.len,
8385 "Generated auth tag not as expected");
8392 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8394 return test_authenticated_encryption_oop(&gcm_test_case_5);
8398 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8400 struct crypto_testsuite_params *ts_params = &testsuite_params;
8401 struct crypto_unittest_params *ut_params = &unittest_params;
8406 /* Verify the capabilities */
8407 struct rte_cryptodev_sym_capability_idx cap_idx;
8408 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8409 cap_idx.algo.aead = tdata->algo;
8410 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8414 /* not supported with CPU crypto */
8415 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8418 /* Create AEAD session */
8419 retval = create_aead_session(ts_params->valid_devs[0],
8421 RTE_CRYPTO_AEAD_OP_DECRYPT,
8422 tdata->key.data, tdata->key.len,
8423 tdata->aad.len, tdata->auth_tag.len,
8428 /* alloc mbuf and set payload */
8429 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8430 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8432 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8433 rte_pktmbuf_tailroom(ut_params->ibuf));
8434 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8435 rte_pktmbuf_tailroom(ut_params->obuf));
8437 /* Create AEAD operation */
8438 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8442 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8444 ut_params->op->sym->m_src = ut_params->ibuf;
8445 ut_params->op->sym->m_dst = ut_params->obuf;
8447 /* Process crypto operation */
8448 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8449 ut_params->op), "failed to process sym crypto op");
8451 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8452 "crypto op processing failed");
8454 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8455 ut_params->op->sym->cipher.data.offset);
8457 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8460 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8462 tdata->plaintext.data,
8463 tdata->plaintext.len,
8464 "Plaintext data not as expected");
8466 TEST_ASSERT_EQUAL(ut_params->op->status,
8467 RTE_CRYPTO_OP_STATUS_SUCCESS,
8468 "Authentication failed");
8473 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8475 return test_authenticated_decryption_oop(&gcm_test_case_5);
8479 test_authenticated_encryption_sessionless(
8480 const struct aead_test_data *tdata)
8482 struct crypto_testsuite_params *ts_params = &testsuite_params;
8483 struct crypto_unittest_params *ut_params = &unittest_params;
8486 uint8_t *ciphertext, *auth_tag;
8487 uint16_t plaintext_pad_len;
8488 uint8_t key[tdata->key.len + 1];
8489 struct rte_cryptodev_info dev_info;
8491 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8492 uint64_t feat_flags = dev_info.feature_flags;
8494 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8495 printf("Device doesn't support Sessionless ops.\n");
8499 /* not supported with CPU crypto */
8500 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8503 /* Verify the capabilities */
8504 struct rte_cryptodev_sym_capability_idx cap_idx;
8505 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8506 cap_idx.algo.aead = tdata->algo;
8507 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8513 /* clear mbuf payload */
8514 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8515 rte_pktmbuf_tailroom(ut_params->ibuf));
8517 /* Create AEAD operation */
8518 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8522 /* Create GCM xform */
8523 memcpy(key, tdata->key.data, tdata->key.len);
8524 retval = create_aead_xform(ut_params->op,
8526 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8527 key, tdata->key.len,
8528 tdata->aad.len, tdata->auth_tag.len,
8533 ut_params->op->sym->m_src = ut_params->ibuf;
8535 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8536 RTE_CRYPTO_OP_SESSIONLESS,
8537 "crypto op session type not sessionless");
8539 /* Process crypto operation */
8540 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8541 ut_params->op), "failed to process sym crypto op");
8543 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8545 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8546 "crypto op status not success");
8548 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8550 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8551 ut_params->op->sym->cipher.data.offset);
8552 auth_tag = ciphertext + plaintext_pad_len;
8554 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8555 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8558 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8560 tdata->ciphertext.data,
8561 tdata->ciphertext.len,
8562 "Ciphertext data not as expected");
8564 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8566 tdata->auth_tag.data,
8567 tdata->auth_tag.len,
8568 "Generated auth tag not as expected");
8575 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8577 return test_authenticated_encryption_sessionless(
8582 test_authenticated_decryption_sessionless(
8583 const struct aead_test_data *tdata)
8585 struct crypto_testsuite_params *ts_params = &testsuite_params;
8586 struct crypto_unittest_params *ut_params = &unittest_params;
8590 uint8_t key[tdata->key.len + 1];
8591 struct rte_cryptodev_info dev_info;
8593 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8594 uint64_t feat_flags = dev_info.feature_flags;
8596 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8597 printf("Device doesn't support Sessionless ops.\n");
8601 /* not supported with CPU crypto */
8602 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8605 /* Verify the capabilities */
8606 struct rte_cryptodev_sym_capability_idx cap_idx;
8607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8608 cap_idx.algo.aead = tdata->algo;
8609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8613 /* alloc mbuf and set payload */
8614 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8616 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8617 rte_pktmbuf_tailroom(ut_params->ibuf));
8619 /* Create AEAD operation */
8620 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8624 /* Create AEAD xform */
8625 memcpy(key, tdata->key.data, tdata->key.len);
8626 retval = create_aead_xform(ut_params->op,
8628 RTE_CRYPTO_AEAD_OP_DECRYPT,
8629 key, tdata->key.len,
8630 tdata->aad.len, tdata->auth_tag.len,
8635 ut_params->op->sym->m_src = ut_params->ibuf;
8637 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8638 RTE_CRYPTO_OP_SESSIONLESS,
8639 "crypto op session type not sessionless");
8641 /* Process crypto operation */
8642 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8643 ut_params->op), "failed to process sym crypto op");
8645 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8647 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8648 "crypto op status not success");
8650 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8651 ut_params->op->sym->cipher.data.offset);
8653 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8656 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8658 tdata->plaintext.data,
8659 tdata->plaintext.len,
8660 "Plaintext data not as expected");
8662 TEST_ASSERT_EQUAL(ut_params->op->status,
8663 RTE_CRYPTO_OP_STATUS_SUCCESS,
8664 "Authentication failed");
8669 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8671 return test_authenticated_decryption_sessionless(
8676 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8678 return test_authenticated_encryption(&ccm_test_case_128_1);
8682 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8684 return test_authenticated_encryption(&ccm_test_case_128_2);
8688 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8690 return test_authenticated_encryption(&ccm_test_case_128_3);
8694 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8696 return test_authenticated_decryption(&ccm_test_case_128_1);
8700 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8702 return test_authenticated_decryption(&ccm_test_case_128_2);
8706 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8708 return test_authenticated_decryption(&ccm_test_case_128_3);
8712 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8714 return test_authenticated_encryption(&ccm_test_case_192_1);
8718 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8720 return test_authenticated_encryption(&ccm_test_case_192_2);
8724 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8726 return test_authenticated_encryption(&ccm_test_case_192_3);
8730 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8732 return test_authenticated_decryption(&ccm_test_case_192_1);
8736 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8738 return test_authenticated_decryption(&ccm_test_case_192_2);
8742 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8744 return test_authenticated_decryption(&ccm_test_case_192_3);
8748 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8750 return test_authenticated_encryption(&ccm_test_case_256_1);
8754 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8756 return test_authenticated_encryption(&ccm_test_case_256_2);
8760 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8762 return test_authenticated_encryption(&ccm_test_case_256_3);
8766 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8768 return test_authenticated_decryption(&ccm_test_case_256_1);
8772 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8774 return test_authenticated_decryption(&ccm_test_case_256_2);
8778 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8780 return test_authenticated_decryption(&ccm_test_case_256_3);
8786 struct crypto_testsuite_params *ts_params = &testsuite_params;
8787 struct rte_cryptodev_stats stats;
8788 struct rte_cryptodev *dev;
8789 cryptodev_stats_get_t temp_pfn;
8791 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8794 /* Verify the capabilities */
8795 struct rte_cryptodev_sym_capability_idx cap_idx;
8796 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8797 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8798 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8801 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8802 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8803 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8807 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8808 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8809 &stats) == -ENODEV),
8810 "rte_cryptodev_stats_get invalid dev failed");
8811 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8812 "rte_cryptodev_stats_get invalid Param failed");
8813 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8814 temp_pfn = dev->dev_ops->stats_get;
8815 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8816 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8818 "rte_cryptodev_stats_get invalid Param failed");
8819 dev->dev_ops->stats_get = temp_pfn;
8821 /* Test expected values */
8823 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8825 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8827 "rte_cryptodev_stats_get failed");
8828 TEST_ASSERT((stats.enqueued_count == 1),
8829 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8830 TEST_ASSERT((stats.dequeued_count == 1),
8831 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8832 TEST_ASSERT((stats.enqueue_err_count == 0),
8833 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8834 TEST_ASSERT((stats.dequeue_err_count == 0),
8835 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8837 /* invalid device but should ignore and not reset device stats*/
8838 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8839 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8841 "rte_cryptodev_stats_get failed");
8842 TEST_ASSERT((stats.enqueued_count == 1),
8843 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8845 /* check that a valid reset clears stats */
8846 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8847 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8849 "rte_cryptodev_stats_get failed");
8850 TEST_ASSERT((stats.enqueued_count == 0),
8851 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8852 TEST_ASSERT((stats.dequeued_count == 0),
8853 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8855 return TEST_SUCCESS;
8858 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8859 struct crypto_unittest_params *ut_params,
8860 enum rte_crypto_auth_operation op,
8861 const struct HMAC_MD5_vector *test_case)
8865 memcpy(key, test_case->key.data, test_case->key.len);
8867 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8868 ut_params->auth_xform.next = NULL;
8869 ut_params->auth_xform.auth.op = op;
8871 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8873 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8874 ut_params->auth_xform.auth.key.length = test_case->key.len;
8875 ut_params->auth_xform.auth.key.data = key;
8877 ut_params->sess = rte_cryptodev_sym_session_create(
8878 ts_params->session_mpool);
8880 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8881 ut_params->sess, &ut_params->auth_xform,
8882 ts_params->session_priv_mpool);
8884 if (ut_params->sess == NULL)
8887 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8889 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8890 rte_pktmbuf_tailroom(ut_params->ibuf));
8895 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8896 const struct HMAC_MD5_vector *test_case,
8897 uint8_t **plaintext)
8899 uint16_t plaintext_pad_len;
8901 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8903 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8906 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8908 memcpy(*plaintext, test_case->plaintext.data,
8909 test_case->plaintext.len);
8911 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8912 ut_params->ibuf, MD5_DIGEST_LEN);
8913 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8914 "no room to append digest");
8915 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8916 ut_params->ibuf, plaintext_pad_len);
8918 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8919 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8920 test_case->auth_tag.len);
8923 sym_op->auth.data.offset = 0;
8924 sym_op->auth.data.length = test_case->plaintext.len;
8926 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8927 ut_params->op->sym->m_src = ut_params->ibuf;
8933 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8935 uint16_t plaintext_pad_len;
8936 uint8_t *plaintext, *auth_tag;
8938 struct crypto_testsuite_params *ts_params = &testsuite_params;
8939 struct crypto_unittest_params *ut_params = &unittest_params;
8941 /* Verify the capabilities */
8942 struct rte_cryptodev_sym_capability_idx cap_idx;
8943 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8944 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8945 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8949 if (MD5_HMAC_create_session(ts_params, ut_params,
8950 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8953 /* Generate Crypto op data structure */
8954 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8955 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8956 TEST_ASSERT_NOT_NULL(ut_params->op,
8957 "Failed to allocate symmetric crypto operation struct");
8959 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8962 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8965 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8966 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8969 TEST_ASSERT_NOT_NULL(
8970 process_crypto_request(ts_params->valid_devs[0],
8972 "failed to process sym crypto op");
8974 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8975 "crypto op processing failed");
8977 if (ut_params->op->sym->m_dst) {
8978 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8979 uint8_t *, plaintext_pad_len);
8981 auth_tag = plaintext + plaintext_pad_len;
8984 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8986 test_case->auth_tag.data,
8987 test_case->auth_tag.len,
8988 "HMAC_MD5 generated tag not as expected");
8990 return TEST_SUCCESS;
8994 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8998 struct crypto_testsuite_params *ts_params = &testsuite_params;
8999 struct crypto_unittest_params *ut_params = &unittest_params;
9001 /* Verify the capabilities */
9002 struct rte_cryptodev_sym_capability_idx cap_idx;
9003 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9004 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9005 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9009 if (MD5_HMAC_create_session(ts_params, ut_params,
9010 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9014 /* Generate Crypto op data structure */
9015 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9016 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9017 TEST_ASSERT_NOT_NULL(ut_params->op,
9018 "Failed to allocate symmetric crypto operation struct");
9020 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9023 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9024 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9027 TEST_ASSERT_NOT_NULL(
9028 process_crypto_request(ts_params->valid_devs[0],
9030 "failed to process sym crypto op");
9032 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9033 "HMAC_MD5 crypto op processing failed");
9035 return TEST_SUCCESS;
9039 test_MD5_HMAC_generate_case_1(void)
9041 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9045 test_MD5_HMAC_verify_case_1(void)
9047 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9051 test_MD5_HMAC_generate_case_2(void)
9053 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9057 test_MD5_HMAC_verify_case_2(void)
9059 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9063 test_multi_session(void)
9065 struct crypto_testsuite_params *ts_params = &testsuite_params;
9066 struct crypto_unittest_params *ut_params = &unittest_params;
9068 struct rte_cryptodev_info dev_info;
9069 struct rte_cryptodev_sym_session **sessions;
9073 /* Verify the capabilities */
9074 struct rte_cryptodev_sym_capability_idx cap_idx;
9075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9076 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9080 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9081 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9082 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9086 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9087 aes_cbc_key, hmac_sha512_key);
9090 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9092 sessions = rte_malloc(NULL,
9093 (sizeof(struct rte_cryptodev_sym_session *) *
9094 MAX_NB_SESSIONS) + 1, 0);
9096 /* Create multiple crypto sessions*/
9097 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9099 sessions[i] = rte_cryptodev_sym_session_create(
9100 ts_params->session_mpool);
9102 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9103 sessions[i], &ut_params->auth_xform,
9104 ts_params->session_priv_mpool);
9105 TEST_ASSERT_NOT_NULL(sessions[i],
9106 "Session creation failed at session number %u",
9109 /* Attempt to send a request on each session */
9110 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9114 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9115 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9117 "Failed to perform decrypt on request number %u.", i);
9118 /* free crypto operation structure */
9120 rte_crypto_op_free(ut_params->op);
9123 * free mbuf - both obuf and ibuf are usually the same,
9124 * so check if they point at the same address is necessary,
9125 * to avoid freeing the mbuf twice.
9127 if (ut_params->obuf) {
9128 rte_pktmbuf_free(ut_params->obuf);
9129 if (ut_params->ibuf == ut_params->obuf)
9130 ut_params->ibuf = 0;
9131 ut_params->obuf = 0;
9133 if (ut_params->ibuf) {
9134 rte_pktmbuf_free(ut_params->ibuf);
9135 ut_params->ibuf = 0;
9139 /* Next session create should fail */
9140 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9141 sessions[i], &ut_params->auth_xform,
9142 ts_params->session_priv_mpool);
9143 TEST_ASSERT_NULL(sessions[i],
9144 "Session creation succeeded unexpectedly!");
9146 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9147 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9149 rte_cryptodev_sym_session_free(sessions[i]);
9154 return TEST_SUCCESS;
9157 struct multi_session_params {
9158 struct crypto_unittest_params ut_params;
9159 uint8_t *cipher_key;
9161 const uint8_t *cipher;
9162 const uint8_t *digest;
9166 #define MB_SESSION_NUMBER 3
9169 test_multi_session_random_usage(void)
9171 struct crypto_testsuite_params *ts_params = &testsuite_params;
9172 struct rte_cryptodev_info dev_info;
9173 struct rte_cryptodev_sym_session **sessions;
9175 struct multi_session_params ut_paramz[] = {
9178 .cipher_key = ms_aes_cbc_key0,
9179 .hmac_key = ms_hmac_key0,
9180 .cipher = ms_aes_cbc_cipher0,
9181 .digest = ms_hmac_digest0,
9182 .iv = ms_aes_cbc_iv0
9185 .cipher_key = ms_aes_cbc_key1,
9186 .hmac_key = ms_hmac_key1,
9187 .cipher = ms_aes_cbc_cipher1,
9188 .digest = ms_hmac_digest1,
9189 .iv = ms_aes_cbc_iv1
9192 .cipher_key = ms_aes_cbc_key2,
9193 .hmac_key = ms_hmac_key2,
9194 .cipher = ms_aes_cbc_cipher2,
9195 .digest = ms_hmac_digest2,
9196 .iv = ms_aes_cbc_iv2
9201 /* Verify the capabilities */
9202 struct rte_cryptodev_sym_capability_idx cap_idx;
9203 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9204 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9208 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9209 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9210 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9214 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9216 sessions = rte_malloc(NULL,
9217 (sizeof(struct rte_cryptodev_sym_session *)
9218 * MAX_NB_SESSIONS) + 1, 0);
9220 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9221 sessions[i] = rte_cryptodev_sym_session_create(
9222 ts_params->session_mpool);
9224 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9225 sizeof(struct crypto_unittest_params));
9227 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9228 &ut_paramz[i].ut_params,
9229 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9231 /* Create multiple crypto sessions*/
9232 rte_cryptodev_sym_session_init(
9233 ts_params->valid_devs[0],
9235 &ut_paramz[i].ut_params.auth_xform,
9236 ts_params->session_priv_mpool);
9238 TEST_ASSERT_NOT_NULL(sessions[i],
9239 "Session creation failed at session number %u",
9245 for (i = 0; i < 40000; i++) {
9247 j = rand() % MB_SESSION_NUMBER;
9249 TEST_ASSERT_SUCCESS(
9250 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9252 &ut_paramz[j].ut_params,
9253 ts_params, ut_paramz[j].cipher,
9254 ut_paramz[j].digest,
9256 "Failed to perform decrypt on request number %u.", i);
9258 if (ut_paramz[j].ut_params.op)
9259 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9262 * free mbuf - both obuf and ibuf are usually the same,
9263 * so check if they point at the same address is necessary,
9264 * to avoid freeing the mbuf twice.
9266 if (ut_paramz[j].ut_params.obuf) {
9267 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9268 if (ut_paramz[j].ut_params.ibuf
9269 == ut_paramz[j].ut_params.obuf)
9270 ut_paramz[j].ut_params.ibuf = 0;
9271 ut_paramz[j].ut_params.obuf = 0;
9273 if (ut_paramz[j].ut_params.ibuf) {
9274 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9275 ut_paramz[j].ut_params.ibuf = 0;
9279 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9280 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9282 rte_cryptodev_sym_session_free(sessions[i]);
9287 return TEST_SUCCESS;
9291 test_null_cipher_only_operation(void)
9293 struct crypto_testsuite_params *ts_params = &testsuite_params;
9294 struct crypto_unittest_params *ut_params = &unittest_params;
9296 /* Verify the capabilities */
9297 struct rte_cryptodev_sym_capability_idx cap_idx;
9298 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9299 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9300 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9304 /* Generate test mbuf data and space for digest */
9305 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9306 catch_22_quote, QUOTE_512_BYTES, 0);
9308 /* Setup Cipher Parameters */
9309 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9310 ut_params->cipher_xform.next = NULL;
9312 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9313 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9315 ut_params->sess = rte_cryptodev_sym_session_create(
9316 ts_params->session_mpool);
9318 /* Create Crypto session*/
9319 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9321 &ut_params->cipher_xform,
9322 ts_params->session_priv_mpool);
9323 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9325 /* Generate Crypto op data structure */
9326 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9327 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9328 TEST_ASSERT_NOT_NULL(ut_params->op,
9329 "Failed to allocate symmetric crypto operation struct");
9331 /* Set crypto operation data parameters */
9332 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9334 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9336 /* set crypto operation source mbuf */
9337 sym_op->m_src = ut_params->ibuf;
9339 sym_op->cipher.data.offset = 0;
9340 sym_op->cipher.data.length = QUOTE_512_BYTES;
9342 /* Process crypto operation */
9343 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9345 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9347 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9348 "crypto operation processing failed");
9351 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9352 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9355 "Ciphertext data not as expected");
9357 return TEST_SUCCESS;
9359 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9360 0xab, 0xab, 0xab, 0xab,
9361 0xab, 0xab, 0xab, 0xab,
9362 0xab, 0xab, 0xab, 0xab};
9364 test_null_auth_only_operation(void)
9366 struct crypto_testsuite_params *ts_params = &testsuite_params;
9367 struct crypto_unittest_params *ut_params = &unittest_params;
9370 /* Verify the capabilities */
9371 struct rte_cryptodev_sym_capability_idx cap_idx;
9372 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9373 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9374 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9378 /* Generate test mbuf data and space for digest */
9379 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9380 catch_22_quote, QUOTE_512_BYTES, 0);
9382 /* create a pointer for digest, but don't expect anything to be written
9383 * here in a NULL auth algo so no mbuf append done.
9385 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9387 /* prefill the memory pointed to by digest */
9388 memcpy(digest, orig_data, sizeof(orig_data));
9390 /* Setup HMAC Parameters */
9391 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9392 ut_params->auth_xform.next = NULL;
9394 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9395 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9397 ut_params->sess = rte_cryptodev_sym_session_create(
9398 ts_params->session_mpool);
9400 /* Create Crypto session*/
9401 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9402 ut_params->sess, &ut_params->auth_xform,
9403 ts_params->session_priv_mpool);
9404 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9406 /* Generate Crypto op data structure */
9407 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9408 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9409 TEST_ASSERT_NOT_NULL(ut_params->op,
9410 "Failed to allocate symmetric crypto operation struct");
9412 /* Set crypto operation data parameters */
9413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9415 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9417 sym_op->m_src = ut_params->ibuf;
9419 sym_op->auth.data.offset = 0;
9420 sym_op->auth.data.length = QUOTE_512_BYTES;
9421 sym_op->auth.digest.data = digest;
9422 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9425 /* Process crypto operation */
9426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9428 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9430 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9431 "crypto operation processing failed");
9432 /* Make sure memory pointed to by digest hasn't been overwritten */
9433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9437 "Memory at digest ptr overwritten unexpectedly");
9439 return TEST_SUCCESS;
9444 test_null_cipher_auth_operation(void)
9446 struct crypto_testsuite_params *ts_params = &testsuite_params;
9447 struct crypto_unittest_params *ut_params = &unittest_params;
9450 /* Verify the capabilities */
9451 struct rte_cryptodev_sym_capability_idx cap_idx;
9452 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9453 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9454 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9457 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9458 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9459 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9463 /* Generate test mbuf data and space for digest */
9464 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9465 catch_22_quote, QUOTE_512_BYTES, 0);
9467 /* create a pointer for digest, but don't expect anything to be written
9468 * here in a NULL auth algo so no mbuf append done.
9470 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9472 /* prefill the memory pointed to by digest */
9473 memcpy(digest, orig_data, sizeof(orig_data));
9475 /* Setup Cipher Parameters */
9476 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9477 ut_params->cipher_xform.next = &ut_params->auth_xform;
9479 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9480 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9482 /* Setup HMAC Parameters */
9483 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9484 ut_params->auth_xform.next = NULL;
9486 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9487 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9489 ut_params->sess = rte_cryptodev_sym_session_create(
9490 ts_params->session_mpool);
9492 /* Create Crypto session*/
9493 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9494 ut_params->sess, &ut_params->cipher_xform,
9495 ts_params->session_priv_mpool);
9496 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9498 /* Generate Crypto op data structure */
9499 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9500 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9501 TEST_ASSERT_NOT_NULL(ut_params->op,
9502 "Failed to allocate symmetric crypto operation struct");
9504 /* Set crypto operation data parameters */
9505 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9507 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9509 sym_op->m_src = ut_params->ibuf;
9511 sym_op->cipher.data.offset = 0;
9512 sym_op->cipher.data.length = QUOTE_512_BYTES;
9514 sym_op->auth.data.offset = 0;
9515 sym_op->auth.data.length = QUOTE_512_BYTES;
9516 sym_op->auth.digest.data = digest;
9517 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9520 /* Process crypto operation */
9521 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9523 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9525 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9526 "crypto operation processing failed");
9529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9530 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9533 "Ciphertext data not as expected");
9534 /* Make sure memory pointed to by digest hasn't been overwritten */
9535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9539 "Memory at digest ptr overwritten unexpectedly");
9541 return TEST_SUCCESS;
9545 test_null_auth_cipher_operation(void)
9547 struct crypto_testsuite_params *ts_params = &testsuite_params;
9548 struct crypto_unittest_params *ut_params = &unittest_params;
9551 /* Verify the capabilities */
9552 struct rte_cryptodev_sym_capability_idx cap_idx;
9553 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9554 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9555 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9558 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9559 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9560 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9564 /* Generate test mbuf data */
9565 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9566 catch_22_quote, QUOTE_512_BYTES, 0);
9568 /* create a pointer for digest, but don't expect anything to be written
9569 * here in a NULL auth algo so no mbuf append done.
9571 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9573 /* prefill the memory pointed to by digest */
9574 memcpy(digest, orig_data, sizeof(orig_data));
9576 /* Setup Cipher Parameters */
9577 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9578 ut_params->cipher_xform.next = NULL;
9580 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9581 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9583 /* Setup HMAC Parameters */
9584 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9585 ut_params->auth_xform.next = &ut_params->cipher_xform;
9587 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9588 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9590 ut_params->sess = rte_cryptodev_sym_session_create(
9591 ts_params->session_mpool);
9593 /* Create Crypto session*/
9594 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9595 ut_params->sess, &ut_params->cipher_xform,
9596 ts_params->session_priv_mpool);
9597 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9599 /* Generate Crypto op data structure */
9600 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9601 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9602 TEST_ASSERT_NOT_NULL(ut_params->op,
9603 "Failed to allocate symmetric crypto operation struct");
9605 /* Set crypto operation data parameters */
9606 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9608 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9610 sym_op->m_src = ut_params->ibuf;
9612 sym_op->cipher.data.offset = 0;
9613 sym_op->cipher.data.length = QUOTE_512_BYTES;
9615 sym_op->auth.data.offset = 0;
9616 sym_op->auth.data.length = QUOTE_512_BYTES;
9617 sym_op->auth.digest.data = digest;
9618 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9621 /* Process crypto operation */
9622 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9624 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9626 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9627 "crypto operation processing failed");
9630 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9631 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9634 "Ciphertext data not as expected");
9635 /* Make sure memory pointed to by digest hasn't been overwritten */
9636 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9640 "Memory at digest ptr overwritten unexpectedly");
9642 return TEST_SUCCESS;
9647 test_null_invalid_operation(void)
9649 struct crypto_testsuite_params *ts_params = &testsuite_params;
9650 struct crypto_unittest_params *ut_params = &unittest_params;
9653 /* This test is for NULL PMD only */
9654 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9655 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9658 /* Setup Cipher Parameters */
9659 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9660 ut_params->cipher_xform.next = NULL;
9662 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9663 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9665 ut_params->sess = rte_cryptodev_sym_session_create(
9666 ts_params->session_mpool);
9668 /* Create Crypto session*/
9669 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9670 ut_params->sess, &ut_params->cipher_xform,
9671 ts_params->session_priv_mpool);
9672 TEST_ASSERT(ret < 0,
9673 "Session creation succeeded unexpectedly");
9676 /* Setup HMAC Parameters */
9677 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9678 ut_params->auth_xform.next = NULL;
9680 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9681 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9683 ut_params->sess = rte_cryptodev_sym_session_create(
9684 ts_params->session_mpool);
9686 /* Create Crypto session*/
9687 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9688 ut_params->sess, &ut_params->auth_xform,
9689 ts_params->session_priv_mpool);
9690 TEST_ASSERT(ret < 0,
9691 "Session creation succeeded unexpectedly");
9693 return TEST_SUCCESS;
9697 #define NULL_BURST_LENGTH (32)
9700 test_null_burst_operation(void)
9702 struct crypto_testsuite_params *ts_params = &testsuite_params;
9703 struct crypto_unittest_params *ut_params = &unittest_params;
9705 unsigned i, burst_len = NULL_BURST_LENGTH;
9707 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9708 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9710 /* This test is for NULL PMD only */
9711 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9712 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9715 /* Setup Cipher Parameters */
9716 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9717 ut_params->cipher_xform.next = &ut_params->auth_xform;
9719 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9720 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9722 /* Setup HMAC Parameters */
9723 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9724 ut_params->auth_xform.next = NULL;
9726 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9727 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9729 ut_params->sess = rte_cryptodev_sym_session_create(
9730 ts_params->session_mpool);
9732 /* Create Crypto session*/
9733 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9734 ut_params->sess, &ut_params->cipher_xform,
9735 ts_params->session_priv_mpool);
9736 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9738 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9739 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9740 burst_len, "failed to generate burst of crypto ops");
9742 /* Generate an operation for each mbuf in burst */
9743 for (i = 0; i < burst_len; i++) {
9744 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9746 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9748 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9752 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9754 burst[i]->sym->m_src = m;
9757 /* Process crypto operation */
9758 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9759 0, burst, burst_len),
9761 "Error enqueuing burst");
9763 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9764 0, burst_dequeued, burst_len),
9766 "Error dequeuing burst");
9769 for (i = 0; i < burst_len; i++) {
9771 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9772 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9774 "data not as expected");
9776 rte_pktmbuf_free(burst[i]->sym->m_src);
9777 rte_crypto_op_free(burst[i]);
9780 return TEST_SUCCESS;
9784 generate_gmac_large_plaintext(uint8_t *data)
9788 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9789 memcpy(&data[i], &data[0], 32);
9793 create_gmac_operation(enum rte_crypto_auth_operation op,
9794 const struct gmac_test_data *tdata)
9796 struct crypto_testsuite_params *ts_params = &testsuite_params;
9797 struct crypto_unittest_params *ut_params = &unittest_params;
9798 struct rte_crypto_sym_op *sym_op;
9800 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9802 /* Generate Crypto op data structure */
9803 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9804 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9805 TEST_ASSERT_NOT_NULL(ut_params->op,
9806 "Failed to allocate symmetric crypto operation struct");
9808 sym_op = ut_params->op->sym;
9810 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9811 ut_params->ibuf, tdata->gmac_tag.len);
9812 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9813 "no room to append digest");
9815 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9816 ut_params->ibuf, plaintext_pad_len);
9818 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9819 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9820 tdata->gmac_tag.len);
9821 debug_hexdump(stdout, "digest:",
9822 sym_op->auth.digest.data,
9823 tdata->gmac_tag.len);
9826 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9827 uint8_t *, IV_OFFSET);
9829 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9831 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9833 sym_op->cipher.data.length = 0;
9834 sym_op->cipher.data.offset = 0;
9836 sym_op->auth.data.offset = 0;
9837 sym_op->auth.data.length = tdata->plaintext.len;
9842 static int create_gmac_session(uint8_t dev_id,
9843 const struct gmac_test_data *tdata,
9844 enum rte_crypto_auth_operation auth_op)
9846 uint8_t auth_key[tdata->key.len];
9848 struct crypto_testsuite_params *ts_params = &testsuite_params;
9849 struct crypto_unittest_params *ut_params = &unittest_params;
9851 memcpy(auth_key, tdata->key.data, tdata->key.len);
9853 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9854 ut_params->auth_xform.next = NULL;
9856 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9857 ut_params->auth_xform.auth.op = auth_op;
9858 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9859 ut_params->auth_xform.auth.key.length = tdata->key.len;
9860 ut_params->auth_xform.auth.key.data = auth_key;
9861 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9862 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9865 ut_params->sess = rte_cryptodev_sym_session_create(
9866 ts_params->session_mpool);
9868 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9869 &ut_params->auth_xform,
9870 ts_params->session_priv_mpool);
9872 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9878 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9880 struct crypto_testsuite_params *ts_params = &testsuite_params;
9881 struct crypto_unittest_params *ut_params = &unittest_params;
9885 uint8_t *auth_tag, *plaintext;
9886 uint16_t plaintext_pad_len;
9888 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9889 "No GMAC length in the source data");
9891 /* Verify the capabilities */
9892 struct rte_cryptodev_sym_capability_idx cap_idx;
9893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9894 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9895 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9899 retval = create_gmac_session(ts_params->valid_devs[0],
9900 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9905 if (tdata->plaintext.len > MBUF_SIZE)
9906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9908 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9909 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9910 "Failed to allocate input buffer in mempool");
9912 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9913 rte_pktmbuf_tailroom(ut_params->ibuf));
9915 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9917 * Runtime generate the large plain text instead of use hard code
9918 * plain text vector. It is done to avoid create huge source file
9919 * with the test vector.
9921 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9922 generate_gmac_large_plaintext(tdata->plaintext.data);
9924 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9926 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9928 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9929 debug_hexdump(stdout, "plaintext:", plaintext,
9930 tdata->plaintext.len);
9932 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9938 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9940 ut_params->op->sym->m_src = ut_params->ibuf;
9942 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9943 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9946 TEST_ASSERT_NOT_NULL(
9947 process_crypto_request(ts_params->valid_devs[0],
9948 ut_params->op), "failed to process sym crypto op");
9950 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9951 "crypto op processing failed");
9953 if (ut_params->op->sym->m_dst) {
9954 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9955 uint8_t *, plaintext_pad_len);
9957 auth_tag = plaintext + plaintext_pad_len;
9960 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9962 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9964 tdata->gmac_tag.data,
9965 tdata->gmac_tag.len,
9966 "GMAC Generated auth tag not as expected");
9972 test_AES_GMAC_authentication_test_case_1(void)
9974 return test_AES_GMAC_authentication(&gmac_test_case_1);
9978 test_AES_GMAC_authentication_test_case_2(void)
9980 return test_AES_GMAC_authentication(&gmac_test_case_2);
9984 test_AES_GMAC_authentication_test_case_3(void)
9986 return test_AES_GMAC_authentication(&gmac_test_case_3);
9990 test_AES_GMAC_authentication_test_case_4(void)
9992 return test_AES_GMAC_authentication(&gmac_test_case_4);
9996 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9998 struct crypto_testsuite_params *ts_params = &testsuite_params;
9999 struct crypto_unittest_params *ut_params = &unittest_params;
10001 uint32_t plaintext_pad_len;
10002 uint8_t *plaintext;
10004 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10005 "No GMAC length in the source data");
10007 /* Verify the capabilities */
10008 struct rte_cryptodev_sym_capability_idx cap_idx;
10009 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10010 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10011 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10015 retval = create_gmac_session(ts_params->valid_devs[0],
10016 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10021 if (tdata->plaintext.len > MBUF_SIZE)
10022 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10024 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10025 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10026 "Failed to allocate input buffer in mempool");
10028 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10029 rte_pktmbuf_tailroom(ut_params->ibuf));
10031 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10034 * Runtime generate the large plain text instead of use hard code
10035 * plain text vector. It is done to avoid create huge source file
10036 * with the test vector.
10038 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10039 generate_gmac_large_plaintext(tdata->plaintext.data);
10041 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10042 plaintext_pad_len);
10043 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10045 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10046 debug_hexdump(stdout, "plaintext:", plaintext,
10047 tdata->plaintext.len);
10049 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10055 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10057 ut_params->op->sym->m_src = ut_params->ibuf;
10059 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10060 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10063 TEST_ASSERT_NOT_NULL(
10064 process_crypto_request(ts_params->valid_devs[0],
10065 ut_params->op), "failed to process sym crypto op");
10067 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10068 "crypto op processing failed");
10075 test_AES_GMAC_authentication_verify_test_case_1(void)
10077 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10081 test_AES_GMAC_authentication_verify_test_case_2(void)
10083 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10087 test_AES_GMAC_authentication_verify_test_case_3(void)
10089 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10093 test_AES_GMAC_authentication_verify_test_case_4(void)
10095 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10098 struct test_crypto_vector {
10099 enum rte_crypto_cipher_algorithm crypto_algo;
10100 unsigned int cipher_offset;
10101 unsigned int cipher_len;
10114 const uint8_t *data;
10119 const uint8_t *data;
10123 enum rte_crypto_auth_algorithm auth_algo;
10124 unsigned int auth_offset;
10132 const uint8_t *data;
10142 static const struct test_crypto_vector
10143 hmac_sha1_test_crypto_vector = {
10144 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10146 .data = plaintext_hash,
10151 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10152 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10153 0xDE, 0xF4, 0xDE, 0xAD
10159 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10160 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10161 0x3F, 0x91, 0x64, 0x59
10167 static const struct test_crypto_vector
10168 aes128_gmac_test_vector = {
10169 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10171 .data = plaintext_hash,
10176 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10177 0x08, 0x09, 0x0A, 0x0B
10183 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10184 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10190 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10191 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10197 static const struct test_crypto_vector
10198 aes128cbc_hmac_sha1_test_vector = {
10199 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10200 .cipher_offset = 0,
10204 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10205 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10211 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10212 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10217 .data = plaintext_hash,
10221 .data = ciphertext512_aes128cbc,
10224 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10228 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10229 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10230 0xDE, 0xF4, 0xDE, 0xAD
10236 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10237 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10238 0x18, 0x8C, 0x1D, 0x32
10244 static const struct test_crypto_vector
10245 aes128cbc_hmac_sha1_aad_test_vector = {
10246 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10247 .cipher_offset = 12,
10251 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10252 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10258 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10259 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10264 .data = plaintext_hash,
10268 .data = ciphertext512_aes128cbc_aad,
10271 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10275 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10276 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10277 0xDE, 0xF4, 0xDE, 0xAD
10283 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10284 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10285 0x62, 0x8D, 0x62, 0x65
10292 data_corruption(uint8_t *data)
10298 tag_corruption(uint8_t *data, unsigned int tag_offset)
10300 data[tag_offset] += 1;
10304 create_auth_session(struct crypto_unittest_params *ut_params,
10306 const struct test_crypto_vector *reference,
10307 enum rte_crypto_auth_operation auth_op)
10309 struct crypto_testsuite_params *ts_params = &testsuite_params;
10310 uint8_t auth_key[reference->auth_key.len + 1];
10312 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10314 /* Setup Authentication Parameters */
10315 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10316 ut_params->auth_xform.auth.op = auth_op;
10317 ut_params->auth_xform.next = NULL;
10318 ut_params->auth_xform.auth.algo = reference->auth_algo;
10319 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10320 ut_params->auth_xform.auth.key.data = auth_key;
10321 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10323 /* Create Crypto session*/
10324 ut_params->sess = rte_cryptodev_sym_session_create(
10325 ts_params->session_mpool);
10327 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10328 &ut_params->auth_xform,
10329 ts_params->session_priv_mpool);
10331 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10337 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10339 const struct test_crypto_vector *reference,
10340 enum rte_crypto_auth_operation auth_op,
10341 enum rte_crypto_cipher_operation cipher_op)
10343 struct crypto_testsuite_params *ts_params = &testsuite_params;
10344 uint8_t cipher_key[reference->cipher_key.len + 1];
10345 uint8_t auth_key[reference->auth_key.len + 1];
10347 memcpy(cipher_key, reference->cipher_key.data,
10348 reference->cipher_key.len);
10349 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10351 /* Setup Authentication Parameters */
10352 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10353 ut_params->auth_xform.auth.op = auth_op;
10354 ut_params->auth_xform.auth.algo = reference->auth_algo;
10355 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10356 ut_params->auth_xform.auth.key.data = auth_key;
10357 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10359 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10360 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10361 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10363 ut_params->auth_xform.next = &ut_params->cipher_xform;
10365 /* Setup Cipher Parameters */
10366 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10367 ut_params->cipher_xform.next = NULL;
10368 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10369 ut_params->cipher_xform.cipher.op = cipher_op;
10370 ut_params->cipher_xform.cipher.key.data = cipher_key;
10371 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10372 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10373 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10376 /* Create Crypto session*/
10377 ut_params->sess = rte_cryptodev_sym_session_create(
10378 ts_params->session_mpool);
10380 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10381 &ut_params->auth_xform,
10382 ts_params->session_priv_mpool);
10384 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10390 create_auth_operation(struct crypto_testsuite_params *ts_params,
10391 struct crypto_unittest_params *ut_params,
10392 const struct test_crypto_vector *reference,
10393 unsigned int auth_generate)
10395 /* Generate Crypto op data structure */
10396 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10397 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10398 TEST_ASSERT_NOT_NULL(ut_params->op,
10399 "Failed to allocate pktmbuf offload");
10401 /* Set crypto operation data parameters */
10402 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10404 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10406 /* set crypto operation source mbuf */
10407 sym_op->m_src = ut_params->ibuf;
10410 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10411 ut_params->ibuf, reference->digest.len);
10413 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10414 "no room to append auth tag");
10416 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10417 ut_params->ibuf, reference->plaintext.len);
10420 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10422 memcpy(sym_op->auth.digest.data,
10423 reference->digest.data,
10424 reference->digest.len);
10426 debug_hexdump(stdout, "digest:",
10427 sym_op->auth.digest.data,
10428 reference->digest.len);
10430 sym_op->auth.data.length = reference->plaintext.len;
10431 sym_op->auth.data.offset = 0;
10437 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10438 struct crypto_unittest_params *ut_params,
10439 const struct test_crypto_vector *reference,
10440 unsigned int auth_generate)
10442 /* Generate Crypto op data structure */
10443 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10444 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10445 TEST_ASSERT_NOT_NULL(ut_params->op,
10446 "Failed to allocate pktmbuf offload");
10448 /* Set crypto operation data parameters */
10449 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10451 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10453 /* set crypto operation source mbuf */
10454 sym_op->m_src = ut_params->ibuf;
10457 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10458 ut_params->ibuf, reference->digest.len);
10460 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10461 "no room to append auth tag");
10463 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10464 ut_params->ibuf, reference->ciphertext.len);
10467 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10469 memcpy(sym_op->auth.digest.data,
10470 reference->digest.data,
10471 reference->digest.len);
10473 debug_hexdump(stdout, "digest:",
10474 sym_op->auth.digest.data,
10475 reference->digest.len);
10477 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10478 reference->iv.data, reference->iv.len);
10480 sym_op->cipher.data.length = 0;
10481 sym_op->cipher.data.offset = 0;
10483 sym_op->auth.data.length = reference->plaintext.len;
10484 sym_op->auth.data.offset = 0;
10490 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10491 struct crypto_unittest_params *ut_params,
10492 const struct test_crypto_vector *reference,
10493 unsigned int auth_generate)
10495 /* Generate Crypto op data structure */
10496 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10497 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10498 TEST_ASSERT_NOT_NULL(ut_params->op,
10499 "Failed to allocate pktmbuf offload");
10501 /* Set crypto operation data parameters */
10502 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10504 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10506 /* set crypto operation source mbuf */
10507 sym_op->m_src = ut_params->ibuf;
10510 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10511 ut_params->ibuf, reference->digest.len);
10513 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10514 "no room to append auth tag");
10516 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10517 ut_params->ibuf, reference->ciphertext.len);
10520 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10522 memcpy(sym_op->auth.digest.data,
10523 reference->digest.data,
10524 reference->digest.len);
10526 debug_hexdump(stdout, "digest:",
10527 sym_op->auth.digest.data,
10528 reference->digest.len);
10530 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10531 reference->iv.data, reference->iv.len);
10533 sym_op->cipher.data.length = reference->cipher_len;
10534 sym_op->cipher.data.offset = reference->cipher_offset;
10536 sym_op->auth.data.length = reference->plaintext.len;
10537 sym_op->auth.data.offset = reference->auth_offset;
10543 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10544 struct crypto_unittest_params *ut_params,
10545 const struct test_crypto_vector *reference)
10547 return create_auth_operation(ts_params, ut_params, reference, 0);
10551 create_auth_verify_GMAC_operation(
10552 struct crypto_testsuite_params *ts_params,
10553 struct crypto_unittest_params *ut_params,
10554 const struct test_crypto_vector *reference)
10556 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10560 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10561 struct crypto_unittest_params *ut_params,
10562 const struct test_crypto_vector *reference)
10564 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10568 test_authentication_verify_fail_when_data_corruption(
10569 struct crypto_testsuite_params *ts_params,
10570 struct crypto_unittest_params *ut_params,
10571 const struct test_crypto_vector *reference,
10572 unsigned int data_corrupted)
10576 uint8_t *plaintext;
10578 /* Verify the capabilities */
10579 struct rte_cryptodev_sym_capability_idx cap_idx;
10580 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10581 cap_idx.algo.auth = reference->auth_algo;
10582 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10586 /* Create session */
10587 retval = create_auth_session(ut_params,
10588 ts_params->valid_devs[0],
10590 RTE_CRYPTO_AUTH_OP_VERIFY);
10594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10595 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10596 "Failed to allocate input buffer in mempool");
10598 /* clear mbuf payload */
10599 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10600 rte_pktmbuf_tailroom(ut_params->ibuf));
10602 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10603 reference->plaintext.len);
10604 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10605 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10607 debug_hexdump(stdout, "plaintext:", plaintext,
10608 reference->plaintext.len);
10610 /* Create operation */
10611 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10616 if (data_corrupted)
10617 data_corruption(plaintext);
10619 tag_corruption(plaintext, reference->plaintext.len);
10621 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10622 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10624 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10625 RTE_CRYPTO_OP_STATUS_SUCCESS,
10626 "authentication not failed");
10628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10630 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10637 test_authentication_verify_GMAC_fail_when_corruption(
10638 struct crypto_testsuite_params *ts_params,
10639 struct crypto_unittest_params *ut_params,
10640 const struct test_crypto_vector *reference,
10641 unsigned int data_corrupted)
10644 uint8_t *plaintext;
10646 /* Verify the capabilities */
10647 struct rte_cryptodev_sym_capability_idx cap_idx;
10648 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10649 cap_idx.algo.auth = reference->auth_algo;
10650 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10654 /* Create session */
10655 retval = create_auth_cipher_session(ut_params,
10656 ts_params->valid_devs[0],
10658 RTE_CRYPTO_AUTH_OP_VERIFY,
10659 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10663 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10664 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10665 "Failed to allocate input buffer in mempool");
10667 /* clear mbuf payload */
10668 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10669 rte_pktmbuf_tailroom(ut_params->ibuf));
10671 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10672 reference->plaintext.len);
10673 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10674 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10676 debug_hexdump(stdout, "plaintext:", plaintext,
10677 reference->plaintext.len);
10679 /* Create operation */
10680 retval = create_auth_verify_GMAC_operation(ts_params,
10687 if (data_corrupted)
10688 data_corruption(plaintext);
10690 tag_corruption(plaintext, reference->aad.len);
10692 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10693 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10695 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10696 RTE_CRYPTO_OP_STATUS_SUCCESS,
10697 "authentication not failed");
10699 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10701 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10708 test_authenticated_decryption_fail_when_corruption(
10709 struct crypto_testsuite_params *ts_params,
10710 struct crypto_unittest_params *ut_params,
10711 const struct test_crypto_vector *reference,
10712 unsigned int data_corrupted)
10716 uint8_t *ciphertext;
10718 /* Verify the capabilities */
10719 struct rte_cryptodev_sym_capability_idx cap_idx;
10720 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10721 cap_idx.algo.auth = reference->auth_algo;
10722 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10725 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10726 cap_idx.algo.cipher = reference->crypto_algo;
10727 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10731 /* Create session */
10732 retval = create_auth_cipher_session(ut_params,
10733 ts_params->valid_devs[0],
10735 RTE_CRYPTO_AUTH_OP_VERIFY,
10736 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10741 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10742 "Failed to allocate input buffer in mempool");
10744 /* clear mbuf payload */
10745 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10746 rte_pktmbuf_tailroom(ut_params->ibuf));
10748 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10749 reference->ciphertext.len);
10750 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10751 memcpy(ciphertext, reference->ciphertext.data,
10752 reference->ciphertext.len);
10754 /* Create operation */
10755 retval = create_cipher_auth_verify_operation(ts_params,
10762 if (data_corrupted)
10763 data_corruption(ciphertext);
10765 tag_corruption(ciphertext, reference->ciphertext.len);
10767 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10768 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10770 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10771 RTE_CRYPTO_OP_STATUS_SUCCESS,
10772 "authentication not failed");
10774 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10776 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10783 test_authenticated_encryt_with_esn(
10784 struct crypto_testsuite_params *ts_params,
10785 struct crypto_unittest_params *ut_params,
10786 const struct test_crypto_vector *reference)
10790 uint8_t *authciphertext, *plaintext, *auth_tag;
10791 uint16_t plaintext_pad_len;
10792 uint8_t cipher_key[reference->cipher_key.len + 1];
10793 uint8_t auth_key[reference->auth_key.len + 1];
10795 /* Verify the capabilities */
10796 struct rte_cryptodev_sym_capability_idx cap_idx;
10797 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10798 cap_idx.algo.auth = reference->auth_algo;
10799 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10803 cap_idx.algo.cipher = reference->crypto_algo;
10804 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10808 /* Create session */
10809 memcpy(cipher_key, reference->cipher_key.data,
10810 reference->cipher_key.len);
10811 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10813 /* Setup Cipher Parameters */
10814 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10815 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10816 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10817 ut_params->cipher_xform.cipher.key.data = cipher_key;
10818 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10819 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10820 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10822 ut_params->cipher_xform.next = &ut_params->auth_xform;
10824 /* Setup Authentication Parameters */
10825 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10826 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10827 ut_params->auth_xform.auth.algo = reference->auth_algo;
10828 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10829 ut_params->auth_xform.auth.key.data = auth_key;
10830 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10831 ut_params->auth_xform.next = NULL;
10833 /* Create Crypto session*/
10834 ut_params->sess = rte_cryptodev_sym_session_create(
10835 ts_params->session_mpool);
10837 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10839 &ut_params->cipher_xform,
10840 ts_params->session_priv_mpool);
10842 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10845 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10846 "Failed to allocate input buffer in mempool");
10848 /* clear mbuf payload */
10849 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10850 rte_pktmbuf_tailroom(ut_params->ibuf));
10852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10853 reference->plaintext.len);
10854 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10855 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10857 /* Create operation */
10858 retval = create_cipher_auth_operation(ts_params,
10865 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10866 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10869 ut_params->op = process_crypto_request(
10870 ts_params->valid_devs[0], ut_params->op);
10872 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10874 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10875 "crypto op processing failed");
10877 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10879 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10880 ut_params->op->sym->auth.data.offset);
10881 auth_tag = authciphertext + plaintext_pad_len;
10882 debug_hexdump(stdout, "ciphertext:", authciphertext,
10883 reference->ciphertext.len);
10884 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10886 /* Validate obuf */
10887 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10889 reference->ciphertext.data,
10890 reference->ciphertext.len,
10891 "Ciphertext data not as expected");
10893 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10895 reference->digest.data,
10896 reference->digest.len,
10897 "Generated digest not as expected");
10899 return TEST_SUCCESS;
10904 test_authenticated_decrypt_with_esn(
10905 struct crypto_testsuite_params *ts_params,
10906 struct crypto_unittest_params *ut_params,
10907 const struct test_crypto_vector *reference)
10911 uint8_t *ciphertext;
10912 uint8_t cipher_key[reference->cipher_key.len + 1];
10913 uint8_t auth_key[reference->auth_key.len + 1];
10915 /* Verify the capabilities */
10916 struct rte_cryptodev_sym_capability_idx cap_idx;
10917 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10918 cap_idx.algo.auth = reference->auth_algo;
10919 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10922 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10923 cap_idx.algo.cipher = reference->crypto_algo;
10924 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10928 /* Create session */
10929 memcpy(cipher_key, reference->cipher_key.data,
10930 reference->cipher_key.len);
10931 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10933 /* Setup Authentication Parameters */
10934 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10935 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10936 ut_params->auth_xform.auth.algo = reference->auth_algo;
10937 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10938 ut_params->auth_xform.auth.key.data = auth_key;
10939 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10940 ut_params->auth_xform.next = &ut_params->cipher_xform;
10942 /* Setup Cipher Parameters */
10943 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10944 ut_params->cipher_xform.next = NULL;
10945 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10946 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10947 ut_params->cipher_xform.cipher.key.data = cipher_key;
10948 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10949 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10950 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10952 /* Create Crypto session*/
10953 ut_params->sess = rte_cryptodev_sym_session_create(
10954 ts_params->session_mpool);
10956 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10958 &ut_params->auth_xform,
10959 ts_params->session_priv_mpool);
10961 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10964 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10965 "Failed to allocate input buffer in mempool");
10967 /* clear mbuf payload */
10968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10969 rte_pktmbuf_tailroom(ut_params->ibuf));
10971 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10972 reference->ciphertext.len);
10973 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10974 memcpy(ciphertext, reference->ciphertext.data,
10975 reference->ciphertext.len);
10977 /* Create operation */
10978 retval = create_cipher_auth_verify_operation(ts_params,
10985 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10986 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10989 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10992 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10993 TEST_ASSERT_EQUAL(ut_params->op->status,
10994 RTE_CRYPTO_OP_STATUS_SUCCESS,
10995 "crypto op processing passed");
10997 ut_params->obuf = ut_params->op->sym->m_src;
10998 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11004 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11005 const struct aead_test_data *tdata,
11006 void *digest_mem, uint64_t digest_phys)
11008 struct crypto_testsuite_params *ts_params = &testsuite_params;
11009 struct crypto_unittest_params *ut_params = &unittest_params;
11011 const unsigned int auth_tag_len = tdata->auth_tag.len;
11012 const unsigned int iv_len = tdata->iv.len;
11013 unsigned int aad_len = tdata->aad.len;
11014 unsigned int aad_len_pad = 0;
11016 /* Generate Crypto op data structure */
11017 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11018 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11019 TEST_ASSERT_NOT_NULL(ut_params->op,
11020 "Failed to allocate symmetric crypto operation struct");
11022 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11024 sym_op->aead.digest.data = digest_mem;
11026 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11027 "no room to append digest");
11029 sym_op->aead.digest.phys_addr = digest_phys;
11031 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11032 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11034 debug_hexdump(stdout, "digest:",
11035 sym_op->aead.digest.data,
11039 /* Append aad data */
11040 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11041 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11042 uint8_t *, IV_OFFSET);
11044 /* Copy IV 1 byte after the IV pointer, according to the API */
11045 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11047 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11049 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11050 ut_params->ibuf, aad_len);
11051 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11052 "no room to prepend aad");
11053 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11056 memset(sym_op->aead.aad.data, 0, aad_len);
11057 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11058 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11060 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11061 debug_hexdump(stdout, "aad:",
11062 sym_op->aead.aad.data, aad_len);
11064 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11065 uint8_t *, IV_OFFSET);
11067 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11069 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11071 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11072 ut_params->ibuf, aad_len_pad);
11073 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11074 "no room to prepend aad");
11075 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11078 memset(sym_op->aead.aad.data, 0, aad_len);
11079 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11081 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11082 debug_hexdump(stdout, "aad:",
11083 sym_op->aead.aad.data, aad_len);
11086 sym_op->aead.data.length = tdata->plaintext.len;
11087 sym_op->aead.data.offset = aad_len_pad;
11092 #define SGL_MAX_NO 16
11095 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11096 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11098 struct crypto_testsuite_params *ts_params = &testsuite_params;
11099 struct crypto_unittest_params *ut_params = &unittest_params;
11100 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11103 int to_trn_tbl[SGL_MAX_NO];
11105 unsigned int trn_data = 0;
11106 uint8_t *plaintext, *ciphertext, *auth_tag;
11107 struct rte_cryptodev_info dev_info;
11109 /* Verify the capabilities */
11110 struct rte_cryptodev_sym_capability_idx cap_idx;
11111 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11112 cap_idx.algo.aead = tdata->algo;
11113 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11117 /* OOP not supported with CPU crypto */
11118 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11121 /* Detailed check for the particular SGL support flag */
11122 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11124 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11125 if (sgl_in && (!(dev_info.feature_flags &
11126 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11129 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11130 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11131 tdata->plaintext.len;
11132 if (sgl_in && !sgl_out) {
11133 if (!(dev_info.feature_flags &
11134 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11136 } else if (!sgl_in && sgl_out) {
11137 if (!(dev_info.feature_flags &
11138 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11140 } else if (sgl_in && sgl_out) {
11141 if (!(dev_info.feature_flags &
11142 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11147 if (fragsz > tdata->plaintext.len)
11148 fragsz = tdata->plaintext.len;
11150 uint16_t plaintext_len = fragsz;
11151 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11153 if (fragsz_oop > tdata->plaintext.len)
11154 frag_size_oop = tdata->plaintext.len;
11157 void *digest_mem = NULL;
11159 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11161 if (tdata->plaintext.len % fragsz != 0) {
11162 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11165 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11170 * For out-op-place we need to alloc another mbuf
11173 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11174 rte_pktmbuf_append(ut_params->obuf,
11175 frag_size_oop + prepend_len);
11176 buf_oop = ut_params->obuf;
11179 /* Create AEAD session */
11180 retval = create_aead_session(ts_params->valid_devs[0],
11182 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11183 tdata->key.data, tdata->key.len,
11184 tdata->aad.len, tdata->auth_tag.len,
11189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11191 /* clear mbuf payload */
11192 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11193 rte_pktmbuf_tailroom(ut_params->ibuf));
11195 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11198 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11200 trn_data += plaintext_len;
11202 buf = ut_params->ibuf;
11205 * Loop until no more fragments
11208 while (trn_data < tdata->plaintext.len) {
11210 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11211 (tdata->plaintext.len - trn_data) : fragsz;
11213 to_trn_tbl[ecx++] = to_trn;
11215 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11218 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11219 rte_pktmbuf_tailroom(buf));
11222 if (oop && !fragsz_oop) {
11223 buf_last_oop = buf_oop->next =
11224 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11225 buf_oop = buf_oop->next;
11226 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11227 0, rte_pktmbuf_tailroom(buf_oop));
11228 rte_pktmbuf_append(buf_oop, to_trn);
11231 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11234 memcpy(plaintext, tdata->plaintext.data + trn_data,
11236 trn_data += to_trn;
11237 if (trn_data == tdata->plaintext.len) {
11240 digest_mem = rte_pktmbuf_append(buf_oop,
11241 tdata->auth_tag.len);
11243 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11244 tdata->auth_tag.len);
11248 uint64_t digest_phys = 0;
11250 ut_params->ibuf->nb_segs = segs;
11253 if (fragsz_oop && oop) {
11257 if (frag_size_oop == tdata->plaintext.len) {
11258 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11259 tdata->auth_tag.len);
11261 digest_phys = rte_pktmbuf_iova_offset(
11263 tdata->plaintext.len + prepend_len);
11266 trn_data = frag_size_oop;
11267 while (trn_data < tdata->plaintext.len) {
11270 (tdata->plaintext.len - trn_data <
11272 (tdata->plaintext.len - trn_data) :
11275 to_trn_tbl[ecx++] = to_trn;
11277 buf_last_oop = buf_oop->next =
11278 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11279 buf_oop = buf_oop->next;
11280 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11281 0, rte_pktmbuf_tailroom(buf_oop));
11282 rte_pktmbuf_append(buf_oop, to_trn);
11284 trn_data += to_trn;
11286 if (trn_data == tdata->plaintext.len) {
11287 digest_mem = rte_pktmbuf_append(buf_oop,
11288 tdata->auth_tag.len);
11292 ut_params->obuf->nb_segs = segs;
11296 * Place digest at the end of the last buffer
11299 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11300 if (oop && buf_last_oop)
11301 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11303 if (!digest_mem && !oop) {
11304 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11305 + tdata->auth_tag.len);
11306 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11307 tdata->plaintext.len);
11310 /* Create AEAD operation */
11311 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11312 tdata, digest_mem, digest_phys);
11317 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11319 ut_params->op->sym->m_src = ut_params->ibuf;
11321 ut_params->op->sym->m_dst = ut_params->obuf;
11323 /* Process crypto operation */
11324 if (oop == IN_PLACE &&
11325 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11326 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11328 TEST_ASSERT_NOT_NULL(
11329 process_crypto_request(ts_params->valid_devs[0],
11330 ut_params->op), "failed to process sym crypto op");
11332 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11333 "crypto op processing failed");
11336 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11337 uint8_t *, prepend_len);
11339 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11340 uint8_t *, prepend_len);
11344 fragsz = fragsz_oop;
11346 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11348 tdata->ciphertext.data,
11350 "Ciphertext data not as expected");
11352 buf = ut_params->op->sym->m_src->next;
11354 buf = ut_params->op->sym->m_dst->next;
11356 unsigned int off = fragsz;
11360 ciphertext = rte_pktmbuf_mtod(buf,
11363 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11365 tdata->ciphertext.data + off,
11367 "Ciphertext data not as expected");
11369 off += to_trn_tbl[ecx++];
11373 auth_tag = digest_mem;
11374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11376 tdata->auth_tag.data,
11377 tdata->auth_tag.len,
11378 "Generated auth tag not as expected");
11384 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11386 return test_authenticated_encryption_SGL(
11387 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11391 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11393 return test_authenticated_encryption_SGL(
11394 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11398 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11400 return test_authenticated_encryption_SGL(
11401 &gcm_test_case_8, OUT_OF_PLACE, 400,
11402 gcm_test_case_8.plaintext.len);
11406 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11408 /* This test is not for OPENSSL PMD */
11409 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11413 return test_authenticated_encryption_SGL(
11414 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11418 test_authentication_verify_fail_when_data_corrupted(
11419 struct crypto_testsuite_params *ts_params,
11420 struct crypto_unittest_params *ut_params,
11421 const struct test_crypto_vector *reference)
11423 return test_authentication_verify_fail_when_data_corruption(
11424 ts_params, ut_params, reference, 1);
11428 test_authentication_verify_fail_when_tag_corrupted(
11429 struct crypto_testsuite_params *ts_params,
11430 struct crypto_unittest_params *ut_params,
11431 const struct test_crypto_vector *reference)
11433 return test_authentication_verify_fail_when_data_corruption(
11434 ts_params, ut_params, reference, 0);
11438 test_authentication_verify_GMAC_fail_when_data_corrupted(
11439 struct crypto_testsuite_params *ts_params,
11440 struct crypto_unittest_params *ut_params,
11441 const struct test_crypto_vector *reference)
11443 return test_authentication_verify_GMAC_fail_when_corruption(
11444 ts_params, ut_params, reference, 1);
11448 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11449 struct crypto_testsuite_params *ts_params,
11450 struct crypto_unittest_params *ut_params,
11451 const struct test_crypto_vector *reference)
11453 return test_authentication_verify_GMAC_fail_when_corruption(
11454 ts_params, ut_params, reference, 0);
11458 test_authenticated_decryption_fail_when_data_corrupted(
11459 struct crypto_testsuite_params *ts_params,
11460 struct crypto_unittest_params *ut_params,
11461 const struct test_crypto_vector *reference)
11463 return test_authenticated_decryption_fail_when_corruption(
11464 ts_params, ut_params, reference, 1);
11468 test_authenticated_decryption_fail_when_tag_corrupted(
11469 struct crypto_testsuite_params *ts_params,
11470 struct crypto_unittest_params *ut_params,
11471 const struct test_crypto_vector *reference)
11473 return test_authenticated_decryption_fail_when_corruption(
11474 ts_params, ut_params, reference, 0);
11478 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11480 return test_authentication_verify_fail_when_data_corrupted(
11481 &testsuite_params, &unittest_params,
11482 &hmac_sha1_test_crypto_vector);
11486 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11488 return test_authentication_verify_fail_when_tag_corrupted(
11489 &testsuite_params, &unittest_params,
11490 &hmac_sha1_test_crypto_vector);
11494 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11496 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11497 &testsuite_params, &unittest_params,
11498 &aes128_gmac_test_vector);
11502 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11504 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11505 &testsuite_params, &unittest_params,
11506 &aes128_gmac_test_vector);
11510 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11512 return test_authenticated_decryption_fail_when_data_corrupted(
11515 &aes128cbc_hmac_sha1_test_vector);
11519 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11521 return test_authenticated_decryption_fail_when_tag_corrupted(
11524 &aes128cbc_hmac_sha1_test_vector);
11528 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11530 return test_authenticated_encryt_with_esn(
11533 &aes128cbc_hmac_sha1_aad_test_vector);
11537 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11539 return test_authenticated_decrypt_with_esn(
11542 &aes128cbc_hmac_sha1_aad_test_vector);
11545 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11547 /* global AESNI slave IDs for the scheduler test */
11548 uint8_t aesni_ids[2];
11551 test_scheduler_attach_slave_op(void)
11553 struct crypto_testsuite_params *ts_params = &testsuite_params;
11554 uint8_t sched_id = ts_params->valid_devs[0];
11555 uint32_t nb_devs, i, nb_devs_attached = 0;
11557 char vdev_name[32];
11559 /* create 2 AESNI_MB if necessary */
11560 nb_devs = rte_cryptodev_device_count_by_driver(
11561 rte_cryptodev_driver_id_get(
11562 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11564 for (i = nb_devs; i < 2; i++) {
11565 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11566 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11568 ret = rte_vdev_init(vdev_name, NULL);
11570 TEST_ASSERT(ret == 0,
11571 "Failed to create instance %u of"
11573 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11577 /* attach 2 AESNI_MB cdevs */
11578 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11580 struct rte_cryptodev_info info;
11581 unsigned int session_size;
11583 rte_cryptodev_info_get(i, &info);
11584 if (info.driver_id != rte_cryptodev_driver_id_get(
11585 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11588 session_size = rte_cryptodev_sym_get_private_session_size(i);
11590 * Create the session mempool again, since now there are new devices
11591 * to use the mempool.
11593 if (ts_params->session_mpool) {
11594 rte_mempool_free(ts_params->session_mpool);
11595 ts_params->session_mpool = NULL;
11597 if (ts_params->session_priv_mpool) {
11598 rte_mempool_free(ts_params->session_priv_mpool);
11599 ts_params->session_priv_mpool = NULL;
11602 if (info.sym.max_nb_sessions != 0 &&
11603 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11604 RTE_LOG(ERR, USER1,
11605 "Device does not support "
11606 "at least %u sessions\n",
11608 return TEST_FAILED;
11611 * Create mempool with maximum number of sessions,
11612 * to include the session headers
11614 if (ts_params->session_mpool == NULL) {
11615 ts_params->session_mpool =
11616 rte_cryptodev_sym_session_pool_create(
11618 MAX_NB_SESSIONS, 0, 0, 0,
11620 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11621 "session mempool allocation failed");
11625 * Create mempool with maximum number of sessions,
11626 * to include device specific session private data
11628 if (ts_params->session_priv_mpool == NULL) {
11629 ts_params->session_priv_mpool = rte_mempool_create(
11630 "test_sess_mp_priv",
11633 0, 0, NULL, NULL, NULL,
11634 NULL, SOCKET_ID_ANY,
11637 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11638 "session mempool allocation failed");
11641 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11642 ts_params->qp_conf.mp_session_private =
11643 ts_params->session_priv_mpool;
11645 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11648 TEST_ASSERT(ret == 0,
11649 "Failed to attach device %u of pmd : %s", i,
11650 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11652 aesni_ids[nb_devs_attached] = (uint8_t)i;
11654 nb_devs_attached++;
11661 test_scheduler_detach_slave_op(void)
11663 struct crypto_testsuite_params *ts_params = &testsuite_params;
11664 uint8_t sched_id = ts_params->valid_devs[0];
11668 for (i = 0; i < 2; i++) {
11669 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11671 TEST_ASSERT(ret == 0,
11672 "Failed to detach device %u", aesni_ids[i]);
11679 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11681 struct crypto_testsuite_params *ts_params = &testsuite_params;
11682 uint8_t sched_id = ts_params->valid_devs[0];
11684 return rte_cryptodev_scheduler_mode_set(sched_id,
11689 test_scheduler_mode_roundrobin_op(void)
11691 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11692 0, "Failed to set roundrobin mode");
11698 test_scheduler_mode_multicore_op(void)
11700 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11701 0, "Failed to set multicore mode");
11707 test_scheduler_mode_failover_op(void)
11709 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11710 0, "Failed to set failover mode");
11716 test_scheduler_mode_pkt_size_distr_op(void)
11718 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11719 0, "Failed to set pktsize mode");
11724 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11725 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11726 .setup = testsuite_setup,
11727 .teardown = testsuite_teardown,
11728 .unit_test_cases = {
11730 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11731 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11732 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11733 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11734 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11735 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11738 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11739 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11740 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11741 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11742 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11743 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11746 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11747 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11748 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11749 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11750 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11751 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11754 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11755 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11757 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11758 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11759 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11761 TEST_CASES_END() /**< NULL terminate unit test array */
11765 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11767 static struct unit_test_suite cryptodev_testsuite = {
11768 .suite_name = "Crypto Unit Test Suite",
11769 .setup = testsuite_setup,
11770 .teardown = testsuite_teardown,
11771 .unit_test_cases = {
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_device_configure_invalid_dev_id),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_device_configure_invalid_queue_pair_ids),
11776 TEST_CASE_ST(ut_setup, ut_teardown,
11777 test_queue_pair_descriptor_setup),
11779 TEST_CASE_ST(ut_setup, ut_teardown,
11780 test_multi_session),
11781 TEST_CASE_ST(ut_setup, ut_teardown,
11782 test_multi_session_random_usage),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_null_invalid_operation),
11786 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11788 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11789 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11790 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11791 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11792 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11793 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11794 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11795 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11796 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11798 /** AES CCM Authenticated Encryption 128 bits key */
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_AES_CCM_authenticated_encryption_test_case_128_1),
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_AES_CCM_authenticated_encryption_test_case_128_2),
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_AES_CCM_authenticated_encryption_test_case_128_3),
11806 /** AES CCM Authenticated Decryption 128 bits key*/
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_AES_CCM_authenticated_decryption_test_case_128_1),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_AES_CCM_authenticated_decryption_test_case_128_2),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_AES_CCM_authenticated_decryption_test_case_128_3),
11814 /** AES CCM Authenticated Encryption 192 bits key */
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_AES_CCM_authenticated_encryption_test_case_192_1),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_CCM_authenticated_encryption_test_case_192_2),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_AES_CCM_authenticated_encryption_test_case_192_3),
11822 /** AES CCM Authenticated Decryption 192 bits key*/
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_AES_CCM_authenticated_decryption_test_case_192_1),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_CCM_authenticated_decryption_test_case_192_2),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_CCM_authenticated_decryption_test_case_192_3),
11830 /** AES CCM Authenticated Encryption 256 bits key */
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_CCM_authenticated_encryption_test_case_256_1),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_CCM_authenticated_encryption_test_case_256_2),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_CCM_authenticated_encryption_test_case_256_3),
11838 /** AES CCM Authenticated Decryption 256 bits key*/
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_CCM_authenticated_decryption_test_case_256_1),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_CCM_authenticated_decryption_test_case_256_2),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_CCM_authenticated_decryption_test_case_256_3),
11846 /** AES GCM Authenticated Encryption */
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_GCM_authenticated_encryption_test_case_1),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_AES_GCM_authenticated_encryption_test_case_2),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_authenticated_encryption_test_case_3),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_authenticated_encryption_test_case_4),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_authenticated_encryption_test_case_5),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_authenticated_encryption_test_case_6),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_authenticated_encryption_test_case_7),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_authenticated_encryption_test_case_8),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11874 /** AES GCM Authenticated Decryption */
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_authenticated_decryption_test_case_1),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_authenticated_decryption_test_case_2),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_authenticated_decryption_test_case_3),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_authenticated_decryption_test_case_4),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_authenticated_decryption_test_case_5),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_authenticated_decryption_test_case_6),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_authenticated_decryption_test_case_7),
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_authenticated_decryption_test_case_8),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11894 /** AES GCM Authenticated Encryption 192 bits key */
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_auth_encryption_test_case_192_1),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_auth_encryption_test_case_192_2),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_auth_encryption_test_case_192_3),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_auth_encryption_test_case_192_4),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_auth_encryption_test_case_192_5),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_auth_encryption_test_case_192_6),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_encryption_test_case_192_7),
11910 /** AES GCM Authenticated Decryption 192 bits key */
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_decryption_test_case_192_1),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_decryption_test_case_192_2),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_decryption_test_case_192_3),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_decryption_test_case_192_4),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_auth_decryption_test_case_192_5),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_auth_decryption_test_case_192_6),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_decryption_test_case_192_7),
11926 /** AES GCM Authenticated Encryption 256 bits key */
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_encryption_test_case_256_1),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_encryption_test_case_256_2),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_encryption_test_case_256_3),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_encryption_test_case_256_4),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_auth_encryption_test_case_256_5),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_auth_encryption_test_case_256_6),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_auth_encryption_test_case_256_7),
11942 /** AES GCM Authenticated Decryption 256 bits key */
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_decryption_test_case_256_1),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_decryption_test_case_256_2),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_decryption_test_case_256_3),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_decryption_test_case_256_4),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GCM_auth_decryption_test_case_256_5),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_decryption_test_case_256_6),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GCM_auth_decryption_test_case_256_7),
11958 /** AES GCM Authenticated Encryption big aad size */
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_encryption_test_case_aad_1),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GCM_auth_encryption_test_case_aad_2),
11964 /** AES GCM Authenticated Decryption big aad size */
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_decryption_test_case_aad_1),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_GCM_auth_decryption_test_case_aad_2),
11970 /** Out of place tests */
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11976 /** Session-less tests */
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11982 /** AES GMAC Authentication */
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GMAC_authentication_test_case_1),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_GMAC_authentication_verify_test_case_1),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GMAC_authentication_test_case_2),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GMAC_authentication_verify_test_case_2),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_GMAC_authentication_test_case_3),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_GMAC_authentication_verify_test_case_3),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_AES_GMAC_authentication_test_case_4),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_AES_GMAC_authentication_verify_test_case_4),
12000 /** SNOW 3G encrypt only (UEA2) */
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_encryption_test_case_1),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_encryption_test_case_2),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_snow3g_encryption_test_case_3),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_encryption_test_case_4),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_snow3g_encryption_test_case_5),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_snow3g_encryption_test_case_1_oop),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_snow3g_encryption_test_case_1_oop_sgl),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_snow3g_encryption_test_case_1_offset_oop),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_snow3g_decryption_test_case_1_oop),
12021 /** SNOW 3G generate auth, then encrypt (UEA2) */
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_snow3g_auth_cipher_test_case_1),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_snow3g_auth_cipher_test_case_2),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_auth_cipher_test_case_2_oop),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_auth_cipher_part_digest_enc),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_snow3g_auth_cipher_part_digest_enc_oop),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_auth_cipher_test_case_3_sgl),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_auth_cipher_part_digest_enc_sgl),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12041 /** SNOW 3G decrypt (UEA2), then verify auth */
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_verify_test_case_1),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_verify_test_case_2),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_verify_test_case_2_oop),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_verify_part_digest_enc),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12061 /** SNOW 3G decrypt only (UEA2) */
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_decryption_test_case_1),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_decryption_test_case_2),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_decryption_test_case_3),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_decryption_test_case_4),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_decryption_test_case_5),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_decryption_with_digest_test_case_1),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_snow3g_hash_generate_test_case_1),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_hash_generate_test_case_2),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_snow3g_hash_generate_test_case_3),
12080 /* Tests with buffers which length is not byte-aligned */
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_hash_generate_test_case_4),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_hash_generate_test_case_5),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_snow3g_hash_generate_test_case_6),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_snow3g_hash_verify_test_case_1),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_snow3g_hash_verify_test_case_2),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_snow3g_hash_verify_test_case_3),
12093 /* Tests with buffers which length is not byte-aligned */
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_snow3g_hash_verify_test_case_4),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_snow3g_hash_verify_test_case_5),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_snow3g_hash_verify_test_case_6),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_snow3g_cipher_auth_test_case_1),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_snow3g_auth_cipher_with_digest_test_case_1),
12105 /** ZUC encrypt only (EEA3) */
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_zuc_encryption_test_case_1),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_zuc_encryption_test_case_2),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_zuc_encryption_test_case_3),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_zuc_encryption_test_case_4),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_zuc_encryption_test_case_5),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_zuc_encryption_test_case_6_sgl),
12119 /** ZUC authenticate (EIA3) */
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_hash_generate_test_case_1),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_hash_generate_test_case_2),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_hash_generate_test_case_3),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_hash_generate_test_case_4),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_zuc_hash_generate_test_case_5),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_zuc_hash_generate_test_case_6),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_zuc_hash_generate_test_case_7),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_hash_generate_test_case_8),
12137 /** ZUC alg-chain (EEA3/EIA3) */
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_cipher_auth_test_case_1),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_cipher_auth_test_case_2),
12143 /** ZUC generate auth, then encrypt (EEA3) */
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_auth_cipher_test_case_1),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_zuc_auth_cipher_test_case_1_oop),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_auth_cipher_test_case_1_sgl),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_zuc_auth_cipher_test_case_1_oop_sgl),
12153 /** ZUC decrypt (EEA3), then verify auth */
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_auth_cipher_verify_test_case_1),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_zuc_auth_cipher_verify_test_case_1_oop),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_zuc_auth_cipher_verify_test_case_1_sgl),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12163 /** HMAC_MD5 Authentication */
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_MD5_HMAC_generate_case_1),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_MD5_HMAC_verify_case_1),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_MD5_HMAC_generate_case_2),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_MD5_HMAC_verify_case_2),
12173 /** KASUMI hash only (UIA1) */
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_hash_generate_test_case_1),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_hash_generate_test_case_2),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_kasumi_hash_generate_test_case_3),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_kasumi_hash_generate_test_case_4),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_hash_generate_test_case_5),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_kasumi_hash_generate_test_case_6),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_verify_test_case_1),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_verify_test_case_2),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_kasumi_hash_verify_test_case_3),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_hash_verify_test_case_4),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_kasumi_hash_verify_test_case_5),
12198 /** KASUMI encrypt only (UEA1) */
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_encryption_test_case_1),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_encryption_test_case_1_sgl),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_encryption_test_case_1_oop),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_encryption_test_case_1_oop_sgl),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_encryption_test_case_2),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_kasumi_encryption_test_case_3),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_encryption_test_case_4),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_encryption_test_case_5),
12216 /** KASUMI decrypt only (UEA1) */
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_decryption_test_case_1),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_decryption_test_case_2),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_decryption_test_case_3),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_decryption_test_case_4),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_kasumi_decryption_test_case_5),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_decryption_test_case_1_oop),
12230 TEST_CASE_ST(ut_setup, ut_teardown,
12231 test_kasumi_cipher_auth_test_case_1),
12233 /** KASUMI generate auth, then encrypt (F8) */
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_kasumi_auth_cipher_test_case_1),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_kasumi_auth_cipher_test_case_2),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_kasumi_auth_cipher_test_case_2_oop),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_kasumi_auth_cipher_test_case_2_sgl),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12245 /** KASUMI decrypt (F8), then verify auth */
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_kasumi_auth_cipher_verify_test_case_1),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_kasumi_auth_cipher_verify_test_case_2),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_kasumi_auth_cipher_verify_test_case_2_oop),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12257 /** ESN Testcase */
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12263 /** Negative tests */
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 authentication_verify_AES128_GMAC_fail_data_corrupt),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12301 /** Mixed CIPHER + HASH algorithms */
12302 /** AUTH AES CMAC + CIPHER AES CTR */
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12320 /** AUTH ZUC + CIPHER SNOW3G */
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_auth_zuc_cipher_snow_test_case_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_verify_auth_zuc_cipher_snow_test_case_1),
12325 /** AUTH AES CMAC + CIPHER SNOW3G */
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_auth_aes_cmac_cipher_snow_test_case_1),
12328 TEST_CASE_ST(ut_setup, ut_teardown,
12329 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12330 /** AUTH ZUC + CIPHER AES CTR */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_auth_zuc_cipher_aes_ctr_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12335 /** AUTH SNOW3G + CIPHER AES CTR */
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_auth_snow_cipher_aes_ctr_test_case_1),
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12340 /** AUTH SNOW3G + CIPHER ZUC */
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_auth_snow_cipher_zuc_test_case_1),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_verify_auth_snow_cipher_zuc_test_case_1),
12345 /** AUTH AES CMAC + CIPHER ZUC */
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_auth_aes_cmac_cipher_zuc_test_case_1),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12351 /** AUTH NULL + CIPHER SNOW3G */
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_auth_null_cipher_snow_test_case_1),
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_verify_auth_null_cipher_snow_test_case_1),
12356 /** AUTH NULL + CIPHER ZUC */
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_auth_null_cipher_zuc_test_case_1),
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_verify_auth_null_cipher_zuc_test_case_1),
12361 /** AUTH SNOW3G + CIPHER NULL */
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_auth_snow_cipher_null_test_case_1),
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_verify_auth_snow_cipher_null_test_case_1),
12366 /** AUTH ZUC + CIPHER NULL */
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_auth_zuc_cipher_null_test_case_1),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_verify_auth_zuc_cipher_null_test_case_1),
12371 /** AUTH NULL + CIPHER AES CTR */
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_auth_null_cipher_aes_ctr_test_case_1),
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12376 /** AUTH AES CMAC + CIPHER NULL */
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_auth_aes_cmac_cipher_null_test_case_1),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12382 TEST_CASES_END() /**< NULL terminate unit test array */
12386 static struct unit_test_suite cryptodev_virtio_testsuite = {
12387 .suite_name = "Crypto VIRTIO Unit Test Suite",
12388 .setup = testsuite_setup,
12389 .teardown = testsuite_teardown,
12390 .unit_test_cases = {
12391 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12393 TEST_CASES_END() /**< NULL terminate unit test array */
12397 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12398 .suite_name = "Crypto CAAM JR Unit Test Suite",
12399 .setup = testsuite_setup,
12400 .teardown = testsuite_teardown,
12401 .unit_test_cases = {
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_device_configure_invalid_dev_id),
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_multi_session),
12407 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12408 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12409 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12410 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12411 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12413 TEST_CASES_END() /**< NULL terminate unit test array */
12417 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12418 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12419 .setup = testsuite_setup,
12420 .teardown = testsuite_teardown,
12421 .unit_test_cases = {
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_device_configure_invalid_dev_id),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_multi_session),
12427 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12428 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12429 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12430 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12431 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12433 #ifdef RTE_LIBRTE_SECURITY
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_PDCP_PROTO_cplane_encap_all),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_PDCP_PROTO_cplane_decap_all),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_PDCP_PROTO_uplane_encap_all),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_PDCP_PROTO_uplane_decap_all),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_PDCP_PROTO_SGL_in_place_32B),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_PDCP_PROTO_SGL_oop_32B_128B),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_PDCP_PROTO_SGL_oop_32B_40B),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_PDCP_PROTO_SGL_oop_128B_32B),
12455 /** AES GCM Authenticated Encryption */
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_AES_GCM_authenticated_encryption_test_case_1),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_AES_GCM_authenticated_encryption_test_case_2),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_AES_GCM_authenticated_encryption_test_case_3),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_AES_GCM_authenticated_encryption_test_case_4),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_AES_GCM_authenticated_encryption_test_case_5),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_AES_GCM_authenticated_encryption_test_case_6),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_GCM_authenticated_encryption_test_case_7),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_AES_GCM_authenticated_encryption_test_case_8),
12481 /** AES GCM Authenticated Decryption */
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_AES_GCM_authenticated_decryption_test_case_1),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_AES_GCM_authenticated_decryption_test_case_2),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_GCM_authenticated_decryption_test_case_3),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_AES_GCM_authenticated_decryption_test_case_4),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_AES_GCM_authenticated_decryption_test_case_5),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_AES_GCM_authenticated_decryption_test_case_6),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_AES_GCM_authenticated_decryption_test_case_7),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_AES_GCM_authenticated_decryption_test_case_8),
12499 /** AES GCM Authenticated Encryption 192 bits key */
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_auth_encryption_test_case_192_1),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_auth_encryption_test_case_192_2),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_auth_encryption_test_case_192_3),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_auth_encryption_test_case_192_4),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_auth_encryption_test_case_192_5),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_auth_encryption_test_case_192_6),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_auth_encryption_test_case_192_7),
12515 /** AES GCM Authenticated Decryption 192 bits key */
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_auth_decryption_test_case_192_1),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_auth_decryption_test_case_192_2),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_decryption_test_case_192_3),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_decryption_test_case_192_4),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_auth_decryption_test_case_192_5),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_auth_decryption_test_case_192_6),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_auth_decryption_test_case_192_7),
12531 /** AES GCM Authenticated Encryption 256 bits key */
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_auth_encryption_test_case_256_1),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_auth_encryption_test_case_256_2),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_encryption_test_case_256_3),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_encryption_test_case_256_4),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_auth_encryption_test_case_256_5),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_encryption_test_case_256_6),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_auth_encryption_test_case_256_7),
12547 /** AES GCM Authenticated Decryption 256 bits key */
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_auth_decryption_test_case_256_1),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_auth_decryption_test_case_256_2),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_decryption_test_case_256_3),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_decryption_test_case_256_4),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_auth_decryption_test_case_256_5),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_auth_decryption_test_case_256_6),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_AES_GCM_auth_decryption_test_case_256_7),
12563 /** Out of place tests */
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12569 /** SNOW 3G encrypt only (UEA2) */
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_snow3g_encryption_test_case_1),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_encryption_test_case_2),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_encryption_test_case_3),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_encryption_test_case_4),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_snow3g_encryption_test_case_5),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_snow3g_encryption_test_case_1_oop),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_snow3g_encryption_test_case_1_oop_sgl),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_snow3g_decryption_test_case_1_oop),
12588 /** SNOW 3G decrypt only (UEA2) */
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_snow3g_decryption_test_case_1),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_snow3g_decryption_test_case_2),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_snow3g_decryption_test_case_3),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_snow3g_decryption_test_case_4),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_snow3g_decryption_test_case_5),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_snow3g_hash_generate_test_case_1),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_snow3g_hash_generate_test_case_2),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_snow3g_hash_generate_test_case_3),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_snow3g_hash_verify_test_case_1),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_snow3g_hash_verify_test_case_2),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_snow3g_hash_verify_test_case_3),
12613 /** ZUC encrypt only (EEA3) */
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_zuc_encryption_test_case_1),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_zuc_encryption_test_case_2),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_zuc_encryption_test_case_3),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_zuc_encryption_test_case_4),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_zuc_encryption_test_case_5),
12625 /** ZUC authenticate (EIA3) */
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_zuc_hash_generate_test_case_6),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_zuc_hash_generate_test_case_7),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_zuc_hash_generate_test_case_8),
12633 /** Negative tests */
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12673 TEST_CASES_END() /**< NULL terminate unit test array */
12677 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12678 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12679 .setup = testsuite_setup,
12680 .teardown = testsuite_teardown,
12681 .unit_test_cases = {
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_device_configure_invalid_dev_id),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_multi_session),
12686 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12687 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12688 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12689 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12690 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12692 #ifdef RTE_LIBRTE_SECURITY
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_PDCP_PROTO_cplane_encap_all),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_PDCP_PROTO_cplane_decap_all),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_PDCP_PROTO_uplane_encap_all),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_PDCP_PROTO_uplane_decap_all),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_PDCP_PROTO_SGL_in_place_32B),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_PDCP_PROTO_SGL_oop_32B_128B),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_PDCP_PROTO_SGL_oop_32B_40B),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_PDCP_PROTO_SGL_oop_128B_32B),
12714 /** AES GCM Authenticated Encryption */
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_authenticated_encryption_test_case_1),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_authenticated_encryption_test_case_2),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_authenticated_encryption_test_case_3),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_authenticated_encryption_test_case_4),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_authenticated_encryption_test_case_5),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_authenticated_encryption_test_case_6),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_authenticated_encryption_test_case_7),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_AES_GCM_authenticated_encryption_test_case_8),
12740 /** AES GCM Authenticated Decryption */
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_authenticated_decryption_test_case_1),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_authenticated_decryption_test_case_2),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_decryption_test_case_3),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_decryption_test_case_4),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_authenticated_decryption_test_case_5),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_authenticated_decryption_test_case_6),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_authenticated_decryption_test_case_7),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_authenticated_decryption_test_case_8),
12758 /** AES GCM Authenticated Encryption 192 bits key */
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_encryption_test_case_192_1),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_192_2),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_192_3),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_192_4),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_auth_encryption_test_case_192_5),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_auth_encryption_test_case_192_6),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_auth_encryption_test_case_192_7),
12774 /** AES GCM Authenticated Decryption 192 bits key */
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_auth_decryption_test_case_192_1),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_192_2),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_192_3),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_192_4),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_auth_decryption_test_case_192_5),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_auth_decryption_test_case_192_6),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_auth_decryption_test_case_192_7),
12790 /** AES GCM Authenticated Encryption 256 bits key */
12791 TEST_CASE_ST(ut_setup, ut_teardown,
12792 test_AES_GCM_auth_encryption_test_case_256_1),
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_auth_encryption_test_case_256_2),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_AES_GCM_auth_encryption_test_case_256_3),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_AES_GCM_auth_encryption_test_case_256_4),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_AES_GCM_auth_encryption_test_case_256_5),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GCM_auth_encryption_test_case_256_6),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_AES_GCM_auth_encryption_test_case_256_7),
12806 /** AES GCM Authenticated Decryption 256 bits key */
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_AES_GCM_auth_decryption_test_case_256_1),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_AES_GCM_auth_decryption_test_case_256_2),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_AES_GCM_auth_decryption_test_case_256_3),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_AES_GCM_auth_decryption_test_case_256_4),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_AES_GCM_auth_decryption_test_case_256_5),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_AES_GCM_auth_decryption_test_case_256_6),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_AES_GCM_auth_decryption_test_case_256_7),
12822 /** Out of place tests */
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12828 /** SNOW 3G encrypt only (UEA2) */
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_encryption_test_case_1),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_snow3g_encryption_test_case_2),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_snow3g_encryption_test_case_3),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_snow3g_encryption_test_case_4),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_snow3g_encryption_test_case_5),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_snow3g_encryption_test_case_1_oop),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_snow3g_encryption_test_case_1_oop_sgl),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_snow3g_decryption_test_case_1_oop),
12847 /** SNOW 3G decrypt only (UEA2) */
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_snow3g_decryption_test_case_1),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_snow3g_decryption_test_case_2),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_snow3g_decryption_test_case_3),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_snow3g_decryption_test_case_4),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_snow3g_decryption_test_case_5),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_snow3g_hash_generate_test_case_1),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_snow3g_hash_generate_test_case_2),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_snow3g_hash_generate_test_case_3),
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_snow3g_hash_verify_test_case_1),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_snow3g_hash_verify_test_case_2),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_snow3g_hash_verify_test_case_3),
12872 /** ZUC encrypt only (EEA3) */
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_zuc_encryption_test_case_1),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_zuc_encryption_test_case_2),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_zuc_encryption_test_case_3),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_zuc_encryption_test_case_4),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_zuc_encryption_test_case_5),
12884 /** ZUC authenticate (EIA3) */
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_zuc_hash_generate_test_case_6),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_zuc_hash_generate_test_case_7),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_zuc_hash_generate_test_case_8),
12892 /** HMAC_MD5 Authentication */
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_MD5_HMAC_generate_case_1),
12895 TEST_CASE_ST(ut_setup, ut_teardown,
12896 test_MD5_HMAC_verify_case_1),
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_MD5_HMAC_generate_case_2),
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_MD5_HMAC_verify_case_2),
12902 /** Negative tests */
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12929 TEST_CASE_ST(ut_setup, ut_teardown,
12930 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12943 TEST_CASES_END() /**< NULL terminate unit test array */
12947 static struct unit_test_suite cryptodev_armv8_testsuite = {
12948 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12949 .setup = testsuite_setup,
12950 .teardown = testsuite_teardown,
12951 .unit_test_cases = {
12952 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12954 /** Negative tests */
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12960 TEST_CASES_END() /**< NULL terminate unit test array */
12964 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12965 .suite_name = "Crypto Device Marvell Component Test Suite",
12966 .setup = testsuite_setup,
12967 .teardown = testsuite_teardown,
12968 .unit_test_cases = {
12969 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_multi_session_random_usage),
12972 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12973 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12974 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12975 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12976 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12978 /** Negative tests */
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12985 TEST_CASE_ST(ut_setup, ut_teardown,
12986 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12988 TEST_CASES_END() /**< NULL terminate unit test array */
12992 static struct unit_test_suite cryptodev_ccp_testsuite = {
12993 .suite_name = "Crypto Device CCP Unit Test Suite",
12994 .setup = testsuite_setup,
12995 .teardown = testsuite_teardown,
12996 .unit_test_cases = {
12997 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_multi_session_random_usage),
13000 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13001 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13002 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13003 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13004 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13006 /** Negative tests */
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13016 TEST_CASES_END() /**< NULL terminate unit test array */
13020 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13021 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13022 .setup = testsuite_setup,
13023 .teardown = testsuite_teardown,
13024 .unit_test_cases = {
13025 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13026 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13027 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13028 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13029 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13031 /** AES GCM Authenticated Encryption */
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_authenticated_encryption_test_case_1),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GCM_authenticated_encryption_test_case_2),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_authenticated_encryption_test_case_3),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GCM_authenticated_encryption_test_case_4),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_AES_GCM_authenticated_encryption_test_case_5),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_authenticated_encryption_test_case_6),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GCM_authenticated_encryption_test_case_7),
13047 /** AES GCM Authenticated Decryption */
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_authenticated_decryption_test_case_1),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_decryption_test_case_2),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_decryption_test_case_3),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_decryption_test_case_4),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GCM_authenticated_decryption_test_case_5),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_AES_GCM_authenticated_decryption_test_case_6),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_AES_GCM_authenticated_decryption_test_case_7),
13062 /** AES GMAC Authentication */
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_AES_GMAC_authentication_test_case_1),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_AES_GMAC_authentication_verify_test_case_1),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_AES_GMAC_authentication_test_case_2),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_AES_GMAC_authentication_verify_test_case_2),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_AES_GMAC_authentication_test_case_3),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_AES_GMAC_authentication_verify_test_case_3),
13076 /** SNOW 3G encrypt only (UEA2) */
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_snow3g_encryption_test_case_1),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_encryption_test_case_2),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_snow3g_encryption_test_case_3),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_snow3g_encryption_test_case_4),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_snow3g_encryption_test_case_5),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_snow3g_encryption_test_case_1_oop),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_snow3g_decryption_test_case_1_oop),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_snow3g_encryption_test_case_1_oop_sgl),
13095 /** SNOW 3G decrypt only (UEA2) */
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_snow3g_decryption_test_case_1),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_snow3g_decryption_test_case_2),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_snow3g_decryption_test_case_3),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_snow3g_decryption_test_case_4),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_snow3g_decryption_test_case_5),
13107 TEST_CASE_ST(ut_setup, ut_teardown,
13108 test_snow3g_hash_generate_test_case_1),
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_snow3g_hash_generate_test_case_2),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_snow3g_hash_generate_test_case_3),
13113 TEST_CASE_ST(ut_setup, ut_teardown,
13114 test_snow3g_hash_verify_test_case_1),
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_snow3g_hash_verify_test_case_2),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_snow3g_hash_verify_test_case_3),
13120 /** ZUC encrypt only (EEA3) */
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_zuc_encryption_test_case_1),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_zuc_encryption_test_case_2),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_zuc_encryption_test_case_3),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_zuc_encryption_test_case_4),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_zuc_encryption_test_case_5),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_zuc_hash_generate_test_case_1),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 test_zuc_hash_generate_test_case_2),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_zuc_hash_generate_test_case_3),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_zuc_hash_generate_test_case_4),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_zuc_hash_generate_test_case_5),
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_zuc_encryption_test_case_6_sgl),
13144 /** KASUMI encrypt only (UEA1) */
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_kasumi_encryption_test_case_1),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_kasumi_encryption_test_case_2),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_kasumi_encryption_test_case_3),
13151 TEST_CASE_ST(ut_setup, ut_teardown,
13152 test_kasumi_encryption_test_case_4),
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_kasumi_encryption_test_case_5),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_kasumi_encryption_test_case_1_sgl),
13157 TEST_CASE_ST(ut_setup, ut_teardown,
13158 test_kasumi_encryption_test_case_1_oop_sgl),
13159 /** KASUMI decrypt only (UEA1) */
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_decryption_test_case_1),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_kasumi_decryption_test_case_2),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_kasumi_decryption_test_case_3),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_kasumi_decryption_test_case_4),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_kasumi_decryption_test_case_5),
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_kasumi_encryption_test_case_1_oop),
13173 TEST_CASE_ST(ut_setup, ut_teardown,
13174 test_kasumi_decryption_test_case_1_oop),
13176 /** KASUMI hash only (UIA1) */
13177 TEST_CASE_ST(ut_setup, ut_teardown,
13178 test_kasumi_hash_generate_test_case_1),
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 test_kasumi_hash_generate_test_case_2),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_kasumi_hash_generate_test_case_3),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_kasumi_hash_generate_test_case_4),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 test_kasumi_hash_generate_test_case_5),
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_kasumi_hash_generate_test_case_6),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_kasumi_hash_verify_test_case_1),
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_kasumi_hash_verify_test_case_2),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_kasumi_hash_verify_test_case_3),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_kasumi_hash_verify_test_case_4),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_kasumi_hash_verify_test_case_5),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_null_cipher_only_operation),
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_null_auth_only_operation),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_null_cipher_auth_operation),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_null_auth_cipher_operation),
13210 /** Negative tests */
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 authentication_verify_AES128_GMAC_fail_data_corrupt),
13217 TEST_CASE_ST(ut_setup, ut_teardown,
13218 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13221 TEST_CASE_ST(ut_setup, ut_teardown,
13222 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13223 TEST_CASES_END() /**< NULL terminate unit test array */
13227 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13228 .suite_name = "Crypto NITROX Unit Test Suite",
13229 .setup = testsuite_setup,
13230 .teardown = testsuite_teardown,
13231 .unit_test_cases = {
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_device_configure_invalid_dev_id),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_device_configure_invalid_queue_pair_ids),
13236 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13237 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13239 TEST_CASES_END() /**< NULL terminate unit test array */
13243 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13244 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13245 .setup = testsuite_setup,
13246 .teardown = testsuite_teardown,
13247 .unit_test_cases = {
13248 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13249 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13250 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13251 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13252 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13254 /** AES GCM Authenticated Encryption */
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_AES_GCM_authenticated_encryption_test_case_1),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_AES_GCM_authenticated_encryption_test_case_2),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_AES_GCM_authenticated_encryption_test_case_3),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_AES_GCM_authenticated_encryption_test_case_4),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_AES_GCM_authenticated_encryption_test_case_5),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_AES_GCM_authenticated_encryption_test_case_6),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_AES_GCM_authenticated_encryption_test_case_7),
13270 /** AES GCM Authenticated Decryption */
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_AES_GCM_authenticated_decryption_test_case_1),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_AES_GCM_authenticated_decryption_test_case_2),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_AES_GCM_authenticated_decryption_test_case_3),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_AES_GCM_authenticated_decryption_test_case_4),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_AES_GCM_authenticated_decryption_test_case_5),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_AES_GCM_authenticated_decryption_test_case_6),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_AES_GCM_authenticated_decryption_test_case_7),
13285 /** AES GMAC Authentication */
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_AES_GMAC_authentication_test_case_1),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_AES_GMAC_authentication_verify_test_case_1),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_AES_GMAC_authentication_test_case_2),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_AES_GMAC_authentication_verify_test_case_2),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_AES_GMAC_authentication_test_case_3),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_AES_GMAC_authentication_verify_test_case_3),
13299 /** SNOW 3G encrypt only (UEA2) */
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_encryption_test_case_1),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_encryption_test_case_2),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_encryption_test_case_3),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_snow3g_encryption_test_case_4),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_snow3g_encryption_test_case_5),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_snow3g_encryption_test_case_1_oop),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_snow3g_decryption_test_case_1_oop),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_snow3g_encryption_test_case_1_oop_sgl),
13318 /** SNOW 3G decrypt only (UEA2) */
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_snow3g_decryption_test_case_1),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_snow3g_decryption_test_case_2),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_snow3g_decryption_test_case_3),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_snow3g_decryption_test_case_4),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_snow3g_decryption_test_case_5),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_snow3g_hash_generate_test_case_1),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_snow3g_hash_generate_test_case_2),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_snow3g_hash_generate_test_case_3),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_snow3g_hash_verify_test_case_1),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_snow3g_hash_verify_test_case_2),
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 test_snow3g_hash_verify_test_case_3),
13343 /** ZUC encrypt only (EEA3) */
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_zuc_encryption_test_case_1),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_zuc_encryption_test_case_2),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_zuc_encryption_test_case_3),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_zuc_encryption_test_case_4),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_zuc_encryption_test_case_5),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_zuc_hash_generate_test_case_1),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_zuc_hash_generate_test_case_2),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_zuc_hash_generate_test_case_3),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_zuc_hash_generate_test_case_4),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_zuc_hash_generate_test_case_5),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_zuc_encryption_test_case_6_sgl),
13367 /** KASUMI encrypt only (UEA1) */
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_kasumi_encryption_test_case_1),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_kasumi_encryption_test_case_2),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_encryption_test_case_3),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_kasumi_encryption_test_case_4),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_kasumi_encryption_test_case_5),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_kasumi_encryption_test_case_1_sgl),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_kasumi_encryption_test_case_1_oop_sgl),
13382 /** KASUMI decrypt only (UEA1) */
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_kasumi_decryption_test_case_1),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_kasumi_decryption_test_case_2),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_kasumi_decryption_test_case_3),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_kasumi_decryption_test_case_4),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_kasumi_decryption_test_case_5),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_kasumi_encryption_test_case_1_oop),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_kasumi_decryption_test_case_1_oop),
13399 /** KASUMI hash only (UIA1) */
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_kasumi_hash_generate_test_case_1),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_kasumi_hash_generate_test_case_2),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_kasumi_hash_generate_test_case_3),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_kasumi_hash_generate_test_case_4),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_kasumi_hash_generate_test_case_5),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_kasumi_hash_generate_test_case_6),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_kasumi_hash_verify_test_case_1),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_kasumi_hash_verify_test_case_2),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_kasumi_hash_verify_test_case_3),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_kasumi_hash_verify_test_case_4),
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_kasumi_hash_verify_test_case_5),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_null_cipher_only_operation),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_null_auth_only_operation),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_null_cipher_auth_operation),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_null_auth_cipher_operation),
13433 /** Negative tests */
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 authentication_verify_AES128_GMAC_fail_data_corrupt),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13446 TEST_CASES_END() /**< NULL terminate unit test array */
13451 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13453 gbl_driver_id = rte_cryptodev_driver_id_get(
13454 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13456 if (gbl_driver_id == -1) {
13457 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13458 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13459 "are enabled in config file to run this testsuite.\n");
13460 return TEST_SKIPPED;
13463 return unit_test_suite_runner(&cryptodev_testsuite);
13467 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13469 gbl_driver_id = rte_cryptodev_driver_id_get(
13470 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13472 if (gbl_driver_id == -1) {
13473 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13474 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13475 "in config file to run this testsuite.\n");
13476 return TEST_FAILED;
13479 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13483 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13485 gbl_driver_id = rte_cryptodev_driver_id_get(
13486 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13488 if (gbl_driver_id == -1) {
13489 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13490 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13491 "in config file to run this testsuite.\n");
13492 return TEST_SKIPPED;
13495 return unit_test_suite_runner(&cryptodev_testsuite);
13499 test_cryptodev_cpu_aesni_mb(void)
13502 enum rte_security_session_action_type at;
13504 gbl_driver_id = rte_cryptodev_driver_id_get(
13505 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13507 if (gbl_driver_id == -1) {
13508 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13509 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13510 "in config file to run this testsuite.\n");
13511 return TEST_SKIPPED;
13514 at = gbl_action_type;
13515 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13516 rc = unit_test_suite_runner(&cryptodev_testsuite);
13517 gbl_action_type = at;
13522 test_cryptodev_openssl(void)
13524 gbl_driver_id = rte_cryptodev_driver_id_get(
13525 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13527 if (gbl_driver_id == -1) {
13528 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13529 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13530 "in config file to run this testsuite.\n");
13531 return TEST_SKIPPED;
13534 return unit_test_suite_runner(&cryptodev_testsuite);
13538 test_cryptodev_aesni_gcm(void)
13540 gbl_driver_id = rte_cryptodev_driver_id_get(
13541 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13543 if (gbl_driver_id == -1) {
13544 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13545 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13546 "in config file to run this testsuite.\n");
13547 return TEST_SKIPPED;
13550 return unit_test_suite_runner(&cryptodev_testsuite);
13554 test_cryptodev_cpu_aesni_gcm(void)
13557 enum rte_security_session_action_type at;
13559 gbl_driver_id = rte_cryptodev_driver_id_get(
13560 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13562 if (gbl_driver_id == -1) {
13563 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13564 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13565 "in config file to run this testsuite.\n");
13566 return TEST_SKIPPED;
13569 at = gbl_action_type;
13570 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13571 rc = unit_test_suite_runner(&cryptodev_testsuite);
13572 gbl_action_type = at;
13577 test_cryptodev_null(void)
13579 gbl_driver_id = rte_cryptodev_driver_id_get(
13580 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13582 if (gbl_driver_id == -1) {
13583 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13584 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13585 "in config file to run this testsuite.\n");
13586 return TEST_SKIPPED;
13589 return unit_test_suite_runner(&cryptodev_testsuite);
13593 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13595 gbl_driver_id = rte_cryptodev_driver_id_get(
13596 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13598 if (gbl_driver_id == -1) {
13599 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13600 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13601 "in config file to run this testsuite.\n");
13602 return TEST_SKIPPED;
13605 return unit_test_suite_runner(&cryptodev_testsuite);
13609 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13611 gbl_driver_id = rte_cryptodev_driver_id_get(
13612 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13614 if (gbl_driver_id == -1) {
13615 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13616 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13617 "in config file to run this testsuite.\n");
13618 return TEST_SKIPPED;
13621 return unit_test_suite_runner(&cryptodev_testsuite);
13625 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13627 gbl_driver_id = rte_cryptodev_driver_id_get(
13628 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13630 if (gbl_driver_id == -1) {
13631 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13632 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13633 "in config file to run this testsuite.\n");
13634 return TEST_SKIPPED;
13637 return unit_test_suite_runner(&cryptodev_testsuite);
13641 test_cryptodev_armv8(void)
13643 gbl_driver_id = rte_cryptodev_driver_id_get(
13644 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13646 if (gbl_driver_id == -1) {
13647 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13648 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13649 "in config file to run this testsuite.\n");
13650 return TEST_SKIPPED;
13653 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13657 test_cryptodev_mrvl(void)
13659 gbl_driver_id = rte_cryptodev_driver_id_get(
13660 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13662 if (gbl_driver_id == -1) {
13663 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13664 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13665 "in config file to run this testsuite.\n");
13666 return TEST_SKIPPED;
13669 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13672 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13675 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13677 gbl_driver_id = rte_cryptodev_driver_id_get(
13678 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13680 if (gbl_driver_id == -1) {
13681 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13682 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13683 "in config file to run this testsuite.\n");
13684 return TEST_SKIPPED;
13687 if (rte_cryptodev_driver_id_get(
13688 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13689 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13690 " enabled in config file to run this testsuite.\n");
13691 return TEST_SKIPPED;
13693 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13696 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13701 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13703 gbl_driver_id = rte_cryptodev_driver_id_get(
13704 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13706 if (gbl_driver_id == -1) {
13707 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13708 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13709 "in config file to run this testsuite.\n");
13710 return TEST_SKIPPED;
13713 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13717 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13719 gbl_driver_id = rte_cryptodev_driver_id_get(
13720 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13722 if (gbl_driver_id == -1) {
13723 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13724 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13725 "in config file to run this testsuite.\n");
13726 return TEST_SKIPPED;
13729 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13733 test_cryptodev_ccp(void)
13735 gbl_driver_id = rte_cryptodev_driver_id_get(
13736 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13738 if (gbl_driver_id == -1) {
13739 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13740 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13741 "in config file to run this testsuite.\n");
13742 return TEST_FAILED;
13745 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13749 test_cryptodev_octeontx(void)
13751 gbl_driver_id = rte_cryptodev_driver_id_get(
13752 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13753 if (gbl_driver_id == -1) {
13754 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13755 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13756 "enabled in config file to run this "
13758 return TEST_FAILED;
13760 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13764 test_cryptodev_octeontx2(void)
13766 gbl_driver_id = rte_cryptodev_driver_id_get(
13767 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13768 if (gbl_driver_id == -1) {
13769 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13770 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13771 "enabled in config file to run this "
13773 return TEST_FAILED;
13775 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13779 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13781 gbl_driver_id = rte_cryptodev_driver_id_get(
13782 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13784 if (gbl_driver_id == -1) {
13785 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13786 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13787 "in config file to run this testsuite.\n");
13788 return TEST_FAILED;
13791 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13795 test_cryptodev_nitrox(void)
13797 gbl_driver_id = rte_cryptodev_driver_id_get(
13798 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13800 if (gbl_driver_id == -1) {
13801 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13802 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13803 "in config file to run this testsuite.\n");
13804 return TEST_FAILED;
13807 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13810 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13811 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13812 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13813 test_cryptodev_cpu_aesni_mb);
13814 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13815 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13816 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13817 test_cryptodev_cpu_aesni_gcm);
13818 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13819 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13820 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13821 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13822 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13823 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13824 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13825 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13826 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13827 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13828 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13829 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13830 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13831 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);