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