1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* This test is for QAT and NITROX PMDs only */
771 if (gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
773 gbl_driver_id != rte_cryptodev_driver_id_get(
774 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
777 /* Stop the device in case it's started so it can be configured */
778 rte_cryptodev_stop(ts_params->valid_devs[0]);
780 /* valid - one queue pairs */
781 ts_params->conf.nb_queue_pairs = 1;
783 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
785 "Failed to configure cryptodev: dev_id %u, qp_id %u",
786 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
789 /* valid - max value queue pairs */
790 ts_params->conf.nb_queue_pairs = orig_nb_qps;
792 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
794 "Failed to configure cryptodev: dev_id %u, qp_id %u",
795 ts_params->valid_devs[0],
796 ts_params->conf.nb_queue_pairs);
799 /* invalid - zero queue pairs */
800 ts_params->conf.nb_queue_pairs = 0;
802 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
804 "Failed test for rte_cryptodev_configure, dev_id %u,"
806 ts_params->valid_devs[0],
807 ts_params->conf.nb_queue_pairs);
810 /* invalid - max value supported by field queue pairs */
811 ts_params->conf.nb_queue_pairs = UINT16_MAX;
813 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
815 "Failed test for rte_cryptodev_configure, dev_id %u,"
817 ts_params->valid_devs[0],
818 ts_params->conf.nb_queue_pairs);
821 /* invalid - max value + 1 queue pairs */
822 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
824 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
826 "Failed test for rte_cryptodev_configure, dev_id %u,"
828 ts_params->valid_devs[0],
829 ts_params->conf.nb_queue_pairs);
831 /* revert to original testsuite value */
832 ts_params->conf.nb_queue_pairs = orig_nb_qps;
838 test_queue_pair_descriptor_setup(void)
840 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 struct rte_cryptodev_info dev_info;
842 struct rte_cryptodev_qp_conf qp_conf = {
843 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
848 /* This test is for QAT PMD only */
849 if (gbl_driver_id != rte_cryptodev_driver_id_get(
850 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
853 /* Stop the device in case it's started so it can be configured */
854 rte_cryptodev_stop(ts_params->valid_devs[0]);
857 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
859 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
861 "Failed to configure cryptodev %u",
862 ts_params->valid_devs[0]);
865 * Test various ring sizes on this device. memzones can't be
866 * freed so are re-used if ring is released and re-created.
868 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
869 qp_conf.mp_session = ts_params->session_mpool;
870 qp_conf.mp_session_private = ts_params->session_priv_mpool;
872 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
873 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
874 ts_params->valid_devs[0], qp_id, &qp_conf,
875 rte_cryptodev_socket_id(
876 ts_params->valid_devs[0])),
878 "rte_cryptodev_queue_pair_setup: num_inflights "
879 "%u on qp %u on cryptodev %u",
880 qp_conf.nb_descriptors, qp_id,
881 ts_params->valid_devs[0]);
884 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
886 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
887 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
888 ts_params->valid_devs[0], qp_id, &qp_conf,
889 rte_cryptodev_socket_id(
890 ts_params->valid_devs[0])),
892 " rte_cryptodev_queue_pair_setup: num_inflights"
893 " %u on qp %u on cryptodev %u",
894 qp_conf.nb_descriptors, qp_id,
895 ts_params->valid_devs[0]);
898 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
900 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
901 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
902 ts_params->valid_devs[0], qp_id, &qp_conf,
903 rte_cryptodev_socket_id(
904 ts_params->valid_devs[0])),
906 "rte_cryptodev_queue_pair_setup: num_inflights"
907 " %u on qp %u on cryptodev %u",
908 qp_conf.nb_descriptors, qp_id,
909 ts_params->valid_devs[0]);
912 /* invalid number of descriptors - max supported + 2 */
913 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
915 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
916 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
917 ts_params->valid_devs[0], qp_id, &qp_conf,
918 rte_cryptodev_socket_id(
919 ts_params->valid_devs[0])),
920 "Unexpectedly passed test for "
921 "rte_cryptodev_queue_pair_setup:"
922 "num_inflights %u on qp %u on cryptodev %u",
923 qp_conf.nb_descriptors, qp_id,
924 ts_params->valid_devs[0]);
927 /* invalid number of descriptors - max value of parameter */
928 qp_conf.nb_descriptors = UINT32_MAX-1;
930 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
931 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
932 ts_params->valid_devs[0], qp_id, &qp_conf,
933 rte_cryptodev_socket_id(
934 ts_params->valid_devs[0])),
935 "Unexpectedly passed test for "
936 "rte_cryptodev_queue_pair_setup:"
937 "num_inflights %u on qp %u on cryptodev %u",
938 qp_conf.nb_descriptors, qp_id,
939 ts_params->valid_devs[0]);
942 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
944 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
945 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
946 ts_params->valid_devs[0], qp_id, &qp_conf,
947 rte_cryptodev_socket_id(
948 ts_params->valid_devs[0])),
950 " rte_cryptodev_queue_pair_setup:"
951 "num_inflights %u on qp %u on cryptodev %u",
952 qp_conf.nb_descriptors, qp_id,
953 ts_params->valid_devs[0]);
956 /* invalid number of descriptors - max supported + 1 */
957 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
959 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
960 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
961 ts_params->valid_devs[0], qp_id, &qp_conf,
962 rte_cryptodev_socket_id(
963 ts_params->valid_devs[0])),
964 "Unexpectedly passed test for "
965 "rte_cryptodev_queue_pair_setup:"
966 "num_inflights %u on qp %u on cryptodev %u",
967 qp_conf.nb_descriptors, qp_id,
968 ts_params->valid_devs[0]);
971 /* test invalid queue pair id */
972 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
974 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
976 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
977 ts_params->valid_devs[0],
979 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
980 "Failed test for rte_cryptodev_queue_pair_setup:"
981 "invalid qp %u on cryptodev %u",
982 qp_id, ts_params->valid_devs[0]);
984 qp_id = 0xffff; /*invalid*/
986 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
987 ts_params->valid_devs[0],
989 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
990 "Failed test for rte_cryptodev_queue_pair_setup:"
991 "invalid qp %u on cryptodev %u",
992 qp_id, ts_params->valid_devs[0]);
997 /* ***** Plaintext data for tests ***** */
999 const char catch_22_quote_1[] =
1000 "There was only one catch and that was Catch-22, which "
1001 "specified that a concern for one's safety in the face of "
1002 "dangers that were real and immediate was the process of a "
1003 "rational mind. Orr was crazy and could be grounded. All he "
1004 "had to do was ask; and as soon as he did, he would no longer "
1005 "be crazy and would have to fly more missions. Orr would be "
1006 "crazy to fly more missions and sane if he didn't, but if he "
1007 "was sane he had to fly them. If he flew them he was crazy "
1008 "and didn't have to; but if he didn't want to he was sane and "
1009 "had to. Yossarian was moved very deeply by the absolute "
1010 "simplicity of this clause of Catch-22 and let out a "
1011 "respectful whistle. \"That's some catch, that Catch-22\", he "
1012 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1014 const char catch_22_quote[] =
1015 "What a lousy earth! He wondered how many people were "
1016 "destitute that same night even in his own prosperous country, "
1017 "how many homes were shanties, how many husbands were drunk "
1018 "and wives socked, and how many children were bullied, abused, "
1019 "or abandoned. How many families hungered for food they could "
1020 "not afford to buy? How many hearts were broken? How many "
1021 "suicides would take place that same night, how many people "
1022 "would go insane? How many cockroaches and landlords would "
1023 "triumph? How many winners were losers, successes failures, "
1024 "and rich men poor men? How many wise guys were stupid? How "
1025 "many happy endings were unhappy endings? How many honest men "
1026 "were liars, brave men cowards, loyal men traitors, how many "
1027 "sainted men were corrupt, how many people in positions of "
1028 "trust had sold their souls to bodyguards, how many had never "
1029 "had souls? How many straight-and-narrow paths were crooked "
1030 "paths? How many best families were worst families and how "
1031 "many good people were bad people? When you added them all up "
1032 "and then subtracted, you might be left with only the children, "
1033 "and perhaps with Albert Einstein and an old violinist or "
1034 "sculptor somewhere.";
1036 #define QUOTE_480_BYTES (480)
1037 #define QUOTE_512_BYTES (512)
1038 #define QUOTE_768_BYTES (768)
1039 #define QUOTE_1024_BYTES (1024)
1043 /* ***** SHA1 Hash Tests ***** */
1045 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1047 static uint8_t hmac_sha1_key[] = {
1048 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1049 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1050 0xDE, 0xF4, 0xDE, 0xAD };
1052 /* ***** SHA224 Hash Tests ***** */
1054 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1057 /* ***** AES-CBC Cipher Tests ***** */
1059 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1060 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1062 static uint8_t aes_cbc_key[] = {
1063 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1064 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1066 static uint8_t aes_cbc_iv[] = {
1067 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1068 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1071 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1073 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1074 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1075 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1076 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1077 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1078 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1079 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1080 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1081 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1082 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1083 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1084 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1085 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1086 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1087 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1088 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1089 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1090 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1091 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1092 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1093 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1094 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1095 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1096 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1097 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1098 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1099 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1100 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1101 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1102 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1103 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1104 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1105 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1106 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1107 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1108 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1109 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1110 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1111 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1112 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1113 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1114 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1115 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1116 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1117 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1118 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1119 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1120 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1121 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1122 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1123 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1124 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1125 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1126 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1127 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1128 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1129 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1130 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1131 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1132 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1133 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1134 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1135 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1136 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1137 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1140 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1141 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1142 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1143 0x18, 0x8c, 0x1d, 0x32
1147 /* Multisession Vector context Test */
1148 /*Begin Session 0 */
1149 static uint8_t ms_aes_cbc_key0[] = {
1150 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1151 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1154 static uint8_t ms_aes_cbc_iv0[] = {
1155 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1156 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1159 static const uint8_t ms_aes_cbc_cipher0[] = {
1160 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1161 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1162 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1163 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1164 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1165 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1166 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1167 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1168 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1169 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1170 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1171 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1172 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1173 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1174 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1175 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1176 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1177 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1178 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1179 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1180 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1181 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1182 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1183 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1184 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1185 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1186 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1187 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1188 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1189 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1190 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1191 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1192 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1193 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1194 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1195 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1196 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1197 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1198 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1199 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1200 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1201 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1202 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1203 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1204 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1205 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1206 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1207 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1208 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1209 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1210 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1211 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1212 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1213 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1214 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1215 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1216 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1217 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1218 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1219 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1220 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1221 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1222 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1223 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1227 static uint8_t ms_hmac_key0[] = {
1228 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest0[] = {
1239 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1240 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1241 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1242 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1243 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1244 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1245 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1246 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1250 /* Begin session 1 */
1252 static uint8_t ms_aes_cbc_key1[] = {
1253 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1254 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1257 static uint8_t ms_aes_cbc_iv1[] = {
1258 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1259 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1262 static const uint8_t ms_aes_cbc_cipher1[] = {
1263 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1264 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1265 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1266 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1267 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1268 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1269 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1270 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1271 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1272 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1273 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1274 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1275 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1276 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1277 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1278 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1279 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1280 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1281 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1282 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1283 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1284 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1285 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1286 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1287 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1288 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1289 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1290 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1291 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1292 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1293 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1294 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1295 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1296 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1297 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1298 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1299 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1300 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1301 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1302 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1303 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1304 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1305 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1306 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1307 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1308 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1309 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1310 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1311 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1312 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1313 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1314 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1315 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1316 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1317 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1318 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1319 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1320 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1321 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1322 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1323 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1324 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1325 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1326 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1330 static uint8_t ms_hmac_key1[] = {
1331 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1332 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1333 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1334 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1335 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1336 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1337 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1338 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1341 static const uint8_t ms_hmac_digest1[] = {
1342 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1343 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1344 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1345 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1346 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1347 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1348 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1349 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1352 /* Begin Session 2 */
1353 static uint8_t ms_aes_cbc_key2[] = {
1354 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1355 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1358 static uint8_t ms_aes_cbc_iv2[] = {
1359 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1360 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1363 static const uint8_t ms_aes_cbc_cipher2[] = {
1364 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1365 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1366 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1367 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1368 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1369 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1370 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1371 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1372 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1373 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1374 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1375 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1376 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1377 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1378 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1379 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1380 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1381 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1382 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1383 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1384 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1385 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1386 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1387 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1388 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1389 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1390 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1391 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1392 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1393 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1394 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1395 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1396 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1397 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1398 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1399 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1400 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1401 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1402 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1403 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1404 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1405 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1406 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1407 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1408 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1409 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1410 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1411 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1412 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1413 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1414 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1415 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1416 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1417 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1418 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1419 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1420 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1421 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1422 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1423 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1424 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1425 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1426 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1427 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1430 static uint8_t ms_hmac_key2[] = {
1431 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1432 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1433 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1434 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1435 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1436 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1437 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1438 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1441 static const uint8_t ms_hmac_digest2[] = {
1442 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1443 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1444 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1445 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1446 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1447 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1448 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1449 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1456 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1458 struct crypto_testsuite_params *ts_params = &testsuite_params;
1459 struct crypto_unittest_params *ut_params = &unittest_params;
1461 /* Verify the capabilities */
1462 struct rte_cryptodev_sym_capability_idx cap_idx;
1463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1464 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1469 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1474 /* Generate test mbuf data and space for digest */
1475 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1476 catch_22_quote, QUOTE_512_BYTES, 0);
1478 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1479 DIGEST_BYTE_LENGTH_SHA1);
1480 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1482 /* Setup Cipher Parameters */
1483 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1484 ut_params->cipher_xform.next = &ut_params->auth_xform;
1486 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1487 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1488 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1489 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1490 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1491 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1493 /* Setup HMAC Parameters */
1494 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1496 ut_params->auth_xform.next = NULL;
1498 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1499 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1500 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1501 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1502 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1504 ut_params->sess = rte_cryptodev_sym_session_create(
1505 ts_params->session_mpool);
1507 /* Create crypto session*/
1508 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1509 ut_params->sess, &ut_params->cipher_xform,
1510 ts_params->session_priv_mpool);
1511 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1513 /* Generate crypto op data structure */
1514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1516 TEST_ASSERT_NOT_NULL(ut_params->op,
1517 "Failed to allocate symmetric crypto operation struct");
1519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1523 /* set crypto operation source mbuf */
1524 sym_op->m_src = ut_params->ibuf;
1526 /* Set crypto operation authentication parameters */
1527 sym_op->auth.digest.data = ut_params->digest;
1528 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1529 ut_params->ibuf, QUOTE_512_BYTES);
1531 sym_op->auth.data.offset = 0;
1532 sym_op->auth.data.length = QUOTE_512_BYTES;
1534 /* Copy IV at the end of the crypto operation */
1535 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1536 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1538 /* Set crypto operation cipher parameters */
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1544 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1547 TEST_ASSERT_NOT_NULL(
1548 process_crypto_request(ts_params->valid_devs[0],
1550 "failed to process sym crypto op");
1552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1553 "crypto op processing failed");
1556 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1559 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1560 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1562 "ciphertext data not as expected");
1564 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1566 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1567 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1568 gbl_driver_id == rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1570 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1571 DIGEST_BYTE_LENGTH_SHA1,
1572 "Generated digest data not as expected");
1574 return TEST_SUCCESS;
1577 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1579 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1581 static uint8_t hmac_sha512_key[] = {
1582 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1583 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1584 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1585 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1586 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1587 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1588 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1589 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1591 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1592 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1593 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1594 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1595 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1596 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1597 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1598 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1599 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1604 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1605 struct crypto_unittest_params *ut_params,
1606 uint8_t *cipher_key,
1610 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1611 struct crypto_unittest_params *ut_params,
1612 struct crypto_testsuite_params *ts_params,
1613 const uint8_t *cipher,
1614 const uint8_t *digest,
1619 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1620 struct crypto_unittest_params *ut_params,
1621 uint8_t *cipher_key,
1625 /* Setup Cipher Parameters */
1626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1627 ut_params->cipher_xform.next = NULL;
1629 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1630 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1631 ut_params->cipher_xform.cipher.key.data = cipher_key;
1632 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1633 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1634 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1636 /* Setup HMAC Parameters */
1637 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1638 ut_params->auth_xform.next = &ut_params->cipher_xform;
1640 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1641 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1642 ut_params->auth_xform.auth.key.data = hmac_key;
1643 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1644 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1646 return TEST_SUCCESS;
1651 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1652 struct crypto_unittest_params *ut_params,
1653 struct crypto_testsuite_params *ts_params,
1654 const uint8_t *cipher,
1655 const uint8_t *digest,
1658 /* Generate test mbuf data and digest */
1659 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1662 QUOTE_512_BYTES, 0);
1664 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1665 DIGEST_BYTE_LENGTH_SHA512);
1666 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1668 rte_memcpy(ut_params->digest,
1670 DIGEST_BYTE_LENGTH_SHA512);
1672 /* Generate Crypto op data structure */
1673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1675 TEST_ASSERT_NOT_NULL(ut_params->op,
1676 "Failed to allocate symmetric crypto operation struct");
1678 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1680 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1682 /* set crypto operation source mbuf */
1683 sym_op->m_src = ut_params->ibuf;
1685 sym_op->auth.digest.data = ut_params->digest;
1686 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1687 ut_params->ibuf, QUOTE_512_BYTES);
1689 sym_op->auth.data.offset = 0;
1690 sym_op->auth.data.length = QUOTE_512_BYTES;
1692 /* Copy IV at the end of the crypto operation */
1693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1694 iv, CIPHER_IV_LENGTH_AES_CBC);
1696 sym_op->cipher.data.offset = 0;
1697 sym_op->cipher.data.length = QUOTE_512_BYTES;
1699 /* Process crypto operation */
1700 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1701 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1704 TEST_ASSERT_NOT_NULL(
1705 process_crypto_request(ts_params->valid_devs[0],
1707 "failed to process sym crypto op");
1709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1710 "crypto op processing failed");
1712 ut_params->obuf = ut_params->op->sym->m_src;
1715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1716 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1719 "Plaintext data not as expected");
1722 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1723 "Digest verification failed");
1725 return TEST_SUCCESS;
1729 test_blockcipher(enum blockcipher_test_type test_type)
1731 struct crypto_testsuite_params *ts_params = &testsuite_params;
1734 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1735 ts_params->op_mpool,
1736 ts_params->session_mpool, ts_params->session_priv_mpool,
1737 ts_params->valid_devs[0],
1740 if (status == -ENOTSUP)
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 return TEST_SUCCESS;
1749 test_AES_cipheronly_all(void)
1751 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1755 test_AES_docsis_all(void)
1757 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1761 test_DES_docsis_all(void)
1763 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1767 test_DES_cipheronly_all(void)
1769 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1773 test_authonly_all(void)
1775 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1779 test_AES_chain_all(void)
1781 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1785 test_3DES_chain_all(void)
1787 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1791 test_3DES_cipheronly_all(void)
1793 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1796 /* ***** SNOW 3G Tests ***** */
1798 create_wireless_algo_hash_session(uint8_t dev_id,
1799 const uint8_t *key, const uint8_t key_len,
1800 const uint8_t iv_len, const uint8_t auth_len,
1801 enum rte_crypto_auth_operation op,
1802 enum rte_crypto_auth_algorithm algo)
1804 uint8_t hash_key[key_len];
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 struct crypto_unittest_params *ut_params = &unittest_params;
1810 memcpy(hash_key, key, key_len);
1812 debug_hexdump(stdout, "key:", key, key_len);
1814 /* Setup Authentication Parameters */
1815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1816 ut_params->auth_xform.next = NULL;
1818 ut_params->auth_xform.auth.op = op;
1819 ut_params->auth_xform.auth.algo = algo;
1820 ut_params->auth_xform.auth.key.length = key_len;
1821 ut_params->auth_xform.auth.key.data = hash_key;
1822 ut_params->auth_xform.auth.digest_length = auth_len;
1823 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1824 ut_params->auth_xform.auth.iv.length = iv_len;
1825 ut_params->sess = rte_cryptodev_sym_session_create(
1826 ts_params->session_mpool);
1828 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1829 &ut_params->auth_xform,
1830 ts_params->session_priv_mpool);
1831 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1837 create_wireless_algo_cipher_session(uint8_t dev_id,
1838 enum rte_crypto_cipher_operation op,
1839 enum rte_crypto_cipher_algorithm algo,
1840 const uint8_t *key, const uint8_t key_len,
1843 uint8_t cipher_key[key_len];
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 memcpy(cipher_key, key, key_len);
1850 /* Setup Cipher Parameters */
1851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1852 ut_params->cipher_xform.next = NULL;
1854 ut_params->cipher_xform.cipher.algo = algo;
1855 ut_params->cipher_xform.cipher.op = op;
1856 ut_params->cipher_xform.cipher.key.data = cipher_key;
1857 ut_params->cipher_xform.cipher.key.length = key_len;
1858 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1859 ut_params->cipher_xform.cipher.iv.length = iv_len;
1861 debug_hexdump(stdout, "key:", key, key_len);
1863 /* Create Crypto session */
1864 ut_params->sess = rte_cryptodev_sym_session_create(
1865 ts_params->session_mpool);
1867 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1868 &ut_params->cipher_xform,
1869 ts_params->session_priv_mpool);
1870 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1871 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1876 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1877 unsigned int cipher_len,
1878 unsigned int cipher_offset)
1880 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 struct crypto_unittest_params *ut_params = &unittest_params;
1883 /* Generate Crypto op data structure */
1884 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1885 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1886 TEST_ASSERT_NOT_NULL(ut_params->op,
1887 "Failed to allocate pktmbuf offload");
1889 /* Set crypto operation data parameters */
1890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1892 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1894 /* set crypto operation source mbuf */
1895 sym_op->m_src = ut_params->ibuf;
1898 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1900 sym_op->cipher.data.length = cipher_len;
1901 sym_op->cipher.data.offset = cipher_offset;
1906 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1907 unsigned int cipher_len,
1908 unsigned int cipher_offset)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1911 struct crypto_unittest_params *ut_params = &unittest_params;
1913 /* Generate Crypto op data structure */
1914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1916 TEST_ASSERT_NOT_NULL(ut_params->op,
1917 "Failed to allocate pktmbuf offload");
1919 /* Set crypto operation data parameters */
1920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1922 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1924 /* set crypto operation source mbuf */
1925 sym_op->m_src = ut_params->ibuf;
1926 sym_op->m_dst = ut_params->obuf;
1929 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1931 sym_op->cipher.data.length = cipher_len;
1932 sym_op->cipher.data.offset = cipher_offset;
1937 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1938 enum rte_crypto_cipher_operation cipher_op,
1939 enum rte_crypto_auth_operation auth_op,
1940 enum rte_crypto_auth_algorithm auth_algo,
1941 enum rte_crypto_cipher_algorithm cipher_algo,
1942 const uint8_t *key, uint8_t key_len,
1943 uint8_t auth_iv_len, uint8_t auth_len,
1944 uint8_t cipher_iv_len)
1947 uint8_t cipher_auth_key[key_len];
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 struct crypto_unittest_params *ut_params = &unittest_params;
1953 memcpy(cipher_auth_key, key, key_len);
1955 /* Setup Authentication Parameters */
1956 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1957 ut_params->auth_xform.next = NULL;
1959 ut_params->auth_xform.auth.op = auth_op;
1960 ut_params->auth_xform.auth.algo = auth_algo;
1961 ut_params->auth_xform.auth.key.length = key_len;
1962 /* Hash key = cipher key */
1963 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1964 ut_params->auth_xform.auth.digest_length = auth_len;
1965 /* Auth IV will be after cipher IV */
1966 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1967 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1969 /* Setup Cipher Parameters */
1970 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1971 ut_params->cipher_xform.next = &ut_params->auth_xform;
1973 ut_params->cipher_xform.cipher.algo = cipher_algo;
1974 ut_params->cipher_xform.cipher.op = cipher_op;
1975 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1976 ut_params->cipher_xform.cipher.key.length = key_len;
1977 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1978 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1980 debug_hexdump(stdout, "key:", key, key_len);
1982 /* Create Crypto session*/
1983 ut_params->sess = rte_cryptodev_sym_session_create(
1984 ts_params->session_mpool);
1985 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1987 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1988 &ut_params->cipher_xform,
1989 ts_params->session_priv_mpool);
1990 if (status == -ENOTSUP)
1993 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1998 create_wireless_cipher_auth_session(uint8_t dev_id,
1999 enum rte_crypto_cipher_operation cipher_op,
2000 enum rte_crypto_auth_operation auth_op,
2001 enum rte_crypto_auth_algorithm auth_algo,
2002 enum rte_crypto_cipher_algorithm cipher_algo,
2003 const struct wireless_test_data *tdata)
2005 const uint8_t key_len = tdata->key.len;
2006 uint8_t cipher_auth_key[key_len];
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 struct crypto_unittest_params *ut_params = &unittest_params;
2011 const uint8_t *key = tdata->key.data;
2012 const uint8_t auth_len = tdata->digest.len;
2013 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2014 uint8_t auth_iv_len = tdata->auth_iv.len;
2016 memcpy(cipher_auth_key, key, key_len);
2018 /* Setup Authentication Parameters */
2019 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2020 ut_params->auth_xform.next = NULL;
2022 ut_params->auth_xform.auth.op = auth_op;
2023 ut_params->auth_xform.auth.algo = auth_algo;
2024 ut_params->auth_xform.auth.key.length = key_len;
2025 /* Hash key = cipher key */
2026 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 /* Auth IV will be after cipher IV */
2029 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2030 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2032 /* Setup Cipher Parameters */
2033 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2034 ut_params->cipher_xform.next = &ut_params->auth_xform;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2041 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2044 debug_hexdump(stdout, "key:", key, key_len);
2046 /* Create Crypto session*/
2047 ut_params->sess = rte_cryptodev_sym_session_create(
2048 ts_params->session_mpool);
2050 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2051 &ut_params->cipher_xform,
2052 ts_params->session_priv_mpool);
2054 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2060 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2061 const struct wireless_test_data *tdata)
2063 return create_wireless_cipher_auth_session(dev_id,
2064 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2065 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2066 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2070 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2071 enum rte_crypto_cipher_operation cipher_op,
2072 enum rte_crypto_auth_operation auth_op,
2073 enum rte_crypto_auth_algorithm auth_algo,
2074 enum rte_crypto_cipher_algorithm cipher_algo,
2075 const uint8_t *key, const uint8_t key_len,
2076 uint8_t auth_iv_len, uint8_t auth_len,
2077 uint8_t cipher_iv_len)
2079 uint8_t auth_cipher_key[key_len];
2081 struct crypto_testsuite_params *ts_params = &testsuite_params;
2082 struct crypto_unittest_params *ut_params = &unittest_params;
2084 memcpy(auth_cipher_key, key, key_len);
2086 /* Setup Authentication Parameters */
2087 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2088 ut_params->auth_xform.auth.op = auth_op;
2089 ut_params->auth_xform.next = &ut_params->cipher_xform;
2090 ut_params->auth_xform.auth.algo = auth_algo;
2091 ut_params->auth_xform.auth.key.length = key_len;
2092 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2093 ut_params->auth_xform.auth.digest_length = auth_len;
2094 /* Auth IV will be after cipher IV */
2095 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2096 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2098 /* Setup Cipher Parameters */
2099 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2100 ut_params->cipher_xform.next = NULL;
2101 ut_params->cipher_xform.cipher.algo = cipher_algo;
2102 ut_params->cipher_xform.cipher.op = cipher_op;
2103 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2104 ut_params->cipher_xform.cipher.key.length = key_len;
2105 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2106 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2108 debug_hexdump(stdout, "key:", key, key_len);
2110 /* Create Crypto session*/
2111 ut_params->sess = rte_cryptodev_sym_session_create(
2112 ts_params->session_mpool);
2113 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2115 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2116 ut_params->auth_xform.next = NULL;
2117 ut_params->cipher_xform.next = &ut_params->auth_xform;
2118 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2119 &ut_params->cipher_xform,
2120 ts_params->session_priv_mpool);
2123 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2124 &ut_params->auth_xform,
2125 ts_params->session_priv_mpool);
2127 if (status == -ENOTSUP)
2130 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2136 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2137 unsigned int auth_tag_len,
2138 const uint8_t *iv, unsigned int iv_len,
2139 unsigned int data_pad_len,
2140 enum rte_crypto_auth_operation op,
2141 unsigned int auth_len, unsigned int auth_offset)
2143 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 struct crypto_unittest_params *ut_params = &unittest_params;
2147 /* Generate Crypto op data structure */
2148 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2149 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2150 TEST_ASSERT_NOT_NULL(ut_params->op,
2151 "Failed to allocate pktmbuf offload");
2153 /* Set crypto operation data parameters */
2154 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2156 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2158 /* set crypto operation source mbuf */
2159 sym_op->m_src = ut_params->ibuf;
2162 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2165 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2166 ut_params->ibuf, auth_tag_len);
2168 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2169 "no room to append auth tag");
2170 ut_params->digest = sym_op->auth.digest.data;
2171 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2172 ut_params->ibuf, data_pad_len);
2173 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2174 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2176 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2178 debug_hexdump(stdout, "digest:",
2179 sym_op->auth.digest.data,
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = auth_offset;
2189 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2190 enum rte_crypto_auth_operation op)
2192 struct crypto_testsuite_params *ts_params = &testsuite_params;
2193 struct crypto_unittest_params *ut_params = &unittest_params;
2195 const uint8_t *auth_tag = tdata->digest.data;
2196 const unsigned int auth_tag_len = tdata->digest.len;
2197 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2198 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2200 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2201 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2202 const uint8_t *auth_iv = tdata->auth_iv.data;
2203 const uint8_t auth_iv_len = tdata->auth_iv.len;
2204 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2205 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2207 /* Generate Crypto op data structure */
2208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2210 TEST_ASSERT_NOT_NULL(ut_params->op,
2211 "Failed to allocate pktmbuf offload");
2212 /* Set crypto operation data parameters */
2213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2215 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2217 /* set crypto operation source mbuf */
2218 sym_op->m_src = ut_params->ibuf;
2221 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2222 ut_params->ibuf, auth_tag_len);
2224 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2225 "no room to append auth tag");
2226 ut_params->digest = sym_op->auth.digest.data;
2227 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2228 ut_params->ibuf, data_pad_len);
2229 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2230 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2232 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2234 debug_hexdump(stdout, "digest:",
2235 sym_op->auth.digest.data,
2238 /* Copy cipher and auth IVs at the end of the crypto operation */
2239 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2241 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2242 iv_ptr += cipher_iv_len;
2243 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2245 sym_op->cipher.data.length = cipher_len;
2246 sym_op->cipher.data.offset = 0;
2247 sym_op->auth.data.length = auth_len;
2248 sym_op->auth.data.offset = 0;
2254 create_zuc_cipher_hash_generate_operation(
2255 const struct wireless_test_data *tdata)
2257 return create_wireless_cipher_hash_operation(tdata,
2258 RTE_CRYPTO_AUTH_OP_GENERATE);
2262 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2263 const unsigned auth_tag_len,
2264 const uint8_t *auth_iv, uint8_t auth_iv_len,
2265 unsigned data_pad_len,
2266 enum rte_crypto_auth_operation op,
2267 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2268 const unsigned cipher_len, const unsigned cipher_offset,
2269 const unsigned auth_len, const unsigned auth_offset)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2272 struct crypto_unittest_params *ut_params = &unittest_params;
2274 enum rte_crypto_cipher_algorithm cipher_algo =
2275 ut_params->cipher_xform.cipher.algo;
2276 enum rte_crypto_auth_algorithm auth_algo =
2277 ut_params->auth_xform.auth.algo;
2279 /* Generate Crypto op data structure */
2280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2282 TEST_ASSERT_NOT_NULL(ut_params->op,
2283 "Failed to allocate pktmbuf offload");
2284 /* Set crypto operation data parameters */
2285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2287 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2289 /* set crypto operation source mbuf */
2290 sym_op->m_src = ut_params->ibuf;
2293 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2294 ut_params->ibuf, auth_tag_len);
2296 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2297 "no room to append auth tag");
2298 ut_params->digest = sym_op->auth.digest.data;
2300 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2301 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2302 ut_params->ibuf, data_pad_len);
2304 struct rte_mbuf *m = ut_params->ibuf;
2305 unsigned int offset = data_pad_len;
2307 while (offset > m->data_len && m->next != NULL) {
2308 offset -= m->data_len;
2311 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2315 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2316 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2318 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2320 debug_hexdump(stdout, "digest:",
2321 sym_op->auth.digest.data,
2324 /* Copy cipher and auth IVs at the end of the crypto operation */
2325 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2327 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2328 iv_ptr += cipher_iv_len;
2329 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2331 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2332 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2333 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2334 sym_op->cipher.data.length = cipher_len;
2335 sym_op->cipher.data.offset = cipher_offset;
2337 sym_op->cipher.data.length = cipher_len >> 3;
2338 sym_op->cipher.data.offset = cipher_offset >> 3;
2341 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2342 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2343 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2344 sym_op->auth.data.length = auth_len;
2345 sym_op->auth.data.offset = auth_offset;
2347 sym_op->auth.data.length = auth_len >> 3;
2348 sym_op->auth.data.offset = auth_offset >> 3;
2355 create_wireless_algo_auth_cipher_operation(
2356 const uint8_t *auth_tag, unsigned int auth_tag_len,
2357 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2358 const uint8_t *auth_iv, uint8_t auth_iv_len,
2359 unsigned int data_pad_len,
2360 unsigned int cipher_len, unsigned int cipher_offset,
2361 unsigned int auth_len, unsigned int auth_offset,
2362 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2364 struct crypto_testsuite_params *ts_params = &testsuite_params;
2365 struct crypto_unittest_params *ut_params = &unittest_params;
2367 enum rte_crypto_cipher_algorithm cipher_algo =
2368 ut_params->cipher_xform.cipher.algo;
2369 enum rte_crypto_auth_algorithm auth_algo =
2370 ut_params->auth_xform.auth.algo;
2372 /* Generate Crypto op data structure */
2373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2375 TEST_ASSERT_NOT_NULL(ut_params->op,
2376 "Failed to allocate pktmbuf offload");
2378 /* Set crypto operation data parameters */
2379 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2381 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2383 /* set crypto operation mbufs */
2384 sym_op->m_src = ut_params->ibuf;
2385 if (op_mode == OUT_OF_PLACE)
2386 sym_op->m_dst = ut_params->obuf;
2390 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2391 (op_mode == IN_PLACE ?
2392 ut_params->ibuf : ut_params->obuf),
2393 uint8_t *, data_pad_len);
2394 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2395 (op_mode == IN_PLACE ?
2396 ut_params->ibuf : ut_params->obuf),
2398 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2400 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2401 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2402 sym_op->m_src : sym_op->m_dst);
2403 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2404 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2405 sgl_buf = sgl_buf->next;
2407 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2408 uint8_t *, remaining_off);
2409 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2411 memset(sym_op->auth.digest.data, 0, remaining_off);
2412 while (sgl_buf->next != NULL) {
2413 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2414 0, rte_pktmbuf_data_len(sgl_buf));
2415 sgl_buf = sgl_buf->next;
2419 /* Copy digest for the verification */
2421 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2423 /* Copy cipher and auth IVs at the end of the crypto operation */
2424 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2425 ut_params->op, uint8_t *, IV_OFFSET);
2427 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2428 iv_ptr += cipher_iv_len;
2429 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2431 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2432 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2433 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2434 sym_op->cipher.data.length = cipher_len;
2435 sym_op->cipher.data.offset = cipher_offset;
2437 sym_op->cipher.data.length = cipher_len >> 3;
2438 sym_op->cipher.data.offset = cipher_offset >> 3;
2441 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2442 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2443 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2444 sym_op->auth.data.length = auth_len;
2445 sym_op->auth.data.offset = auth_offset;
2447 sym_op->auth.data.length = auth_len >> 3;
2448 sym_op->auth.data.offset = auth_offset >> 3;
2455 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2461 unsigned plaintext_pad_len;
2462 unsigned plaintext_len;
2464 struct rte_cryptodev_info dev_info;
2466 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2467 uint64_t feat_flags = dev_info.feature_flags;
2469 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2470 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2471 printf("Device doesn't support NON-Byte Aligned Data.\n");
2475 /* Verify the capabilities */
2476 struct rte_cryptodev_sym_capability_idx cap_idx;
2477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2478 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2483 /* Create SNOW 3G session */
2484 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2485 tdata->key.data, tdata->key.len,
2486 tdata->auth_iv.len, tdata->digest.len,
2487 RTE_CRYPTO_AUTH_OP_GENERATE,
2488 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2492 /* alloc mbuf and set payload */
2493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2495 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2496 rte_pktmbuf_tailroom(ut_params->ibuf));
2498 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2499 /* Append data which is padded to a multiple of */
2500 /* the algorithms block size */
2501 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2502 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2504 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2506 /* Create SNOW 3G operation */
2507 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2508 tdata->auth_iv.data, tdata->auth_iv.len,
2509 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2510 tdata->validAuthLenInBits.len,
2515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2517 ut_params->obuf = ut_params->op->sym->m_src;
2518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2519 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2520 + plaintext_pad_len;
2523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2526 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2527 "SNOW 3G Generated auth tag not as expected");
2533 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2535 struct crypto_testsuite_params *ts_params = &testsuite_params;
2536 struct crypto_unittest_params *ut_params = &unittest_params;
2539 unsigned plaintext_pad_len;
2540 unsigned plaintext_len;
2542 struct rte_cryptodev_info dev_info;
2544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2545 uint64_t feat_flags = dev_info.feature_flags;
2547 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2548 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2549 printf("Device doesn't support NON-Byte Aligned Data.\n");
2553 /* Verify the capabilities */
2554 struct rte_cryptodev_sym_capability_idx cap_idx;
2555 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2556 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2557 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2561 /* Create SNOW 3G session */
2562 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2563 tdata->key.data, tdata->key.len,
2564 tdata->auth_iv.len, tdata->digest.len,
2565 RTE_CRYPTO_AUTH_OP_VERIFY,
2566 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2569 /* alloc mbuf and set payload */
2570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2572 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2573 rte_pktmbuf_tailroom(ut_params->ibuf));
2575 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2576 /* Append data which is padded to a multiple of */
2577 /* the algorithms block size */
2578 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2579 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2581 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2583 /* Create SNOW 3G operation */
2584 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2586 tdata->auth_iv.data, tdata->auth_iv.len,
2588 RTE_CRYPTO_AUTH_OP_VERIFY,
2589 tdata->validAuthLenInBits.len,
2594 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2596 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2597 ut_params->obuf = ut_params->op->sym->m_src;
2598 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2599 + plaintext_pad_len;
2602 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2611 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2613 struct crypto_testsuite_params *ts_params = &testsuite_params;
2614 struct crypto_unittest_params *ut_params = &unittest_params;
2617 unsigned plaintext_pad_len;
2618 unsigned plaintext_len;
2621 /* Verify the capabilities */
2622 struct rte_cryptodev_sym_capability_idx cap_idx;
2623 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2624 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2625 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2629 /* Create KASUMI session */
2630 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2631 tdata->key.data, tdata->key.len,
2632 0, tdata->digest.len,
2633 RTE_CRYPTO_AUTH_OP_GENERATE,
2634 RTE_CRYPTO_AUTH_KASUMI_F9);
2638 /* alloc mbuf and set payload */
2639 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2641 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2642 rte_pktmbuf_tailroom(ut_params->ibuf));
2644 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2645 /* Append data which is padded to a multiple of */
2646 /* the algorithms block size */
2647 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2648 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2650 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2652 /* Create KASUMI operation */
2653 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2655 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2656 tdata->plaintext.len,
2661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2662 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2668 ut_params->obuf = ut_params->op->sym->m_src;
2669 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2670 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2671 + plaintext_pad_len;
2674 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2677 DIGEST_BYTE_LENGTH_KASUMI_F9,
2678 "KASUMI Generated auth tag not as expected");
2684 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2686 struct crypto_testsuite_params *ts_params = &testsuite_params;
2687 struct crypto_unittest_params *ut_params = &unittest_params;
2690 unsigned plaintext_pad_len;
2691 unsigned plaintext_len;
2694 /* Verify the capabilities */
2695 struct rte_cryptodev_sym_capability_idx cap_idx;
2696 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2698 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2702 /* Create KASUMI session */
2703 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2704 tdata->key.data, tdata->key.len,
2705 0, tdata->digest.len,
2706 RTE_CRYPTO_AUTH_OP_VERIFY,
2707 RTE_CRYPTO_AUTH_KASUMI_F9);
2710 /* alloc mbuf and set payload */
2711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2714 rte_pktmbuf_tailroom(ut_params->ibuf));
2716 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2717 /* Append data which is padded to a multiple */
2718 /* of the algorithms block size */
2719 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2720 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2724 /* Create KASUMI operation */
2725 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2729 RTE_CRYPTO_AUTH_OP_VERIFY,
2730 tdata->plaintext.len,
2735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2738 ut_params->obuf = ut_params->op->sym->m_src;
2739 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2740 + plaintext_pad_len;
2743 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2752 test_snow3g_hash_generate_test_case_1(void)
2754 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2758 test_snow3g_hash_generate_test_case_2(void)
2760 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2764 test_snow3g_hash_generate_test_case_3(void)
2766 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2770 test_snow3g_hash_generate_test_case_4(void)
2772 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2776 test_snow3g_hash_generate_test_case_5(void)
2778 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2782 test_snow3g_hash_generate_test_case_6(void)
2784 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2788 test_snow3g_hash_verify_test_case_1(void)
2790 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2795 test_snow3g_hash_verify_test_case_2(void)
2797 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2801 test_snow3g_hash_verify_test_case_3(void)
2803 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2807 test_snow3g_hash_verify_test_case_4(void)
2809 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2813 test_snow3g_hash_verify_test_case_5(void)
2815 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2819 test_snow3g_hash_verify_test_case_6(void)
2821 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2825 test_kasumi_hash_generate_test_case_1(void)
2827 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2831 test_kasumi_hash_generate_test_case_2(void)
2833 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2837 test_kasumi_hash_generate_test_case_3(void)
2839 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2843 test_kasumi_hash_generate_test_case_4(void)
2845 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2849 test_kasumi_hash_generate_test_case_5(void)
2851 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2855 test_kasumi_hash_generate_test_case_6(void)
2857 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2861 test_kasumi_hash_verify_test_case_1(void)
2863 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2867 test_kasumi_hash_verify_test_case_2(void)
2869 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2873 test_kasumi_hash_verify_test_case_3(void)
2875 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2879 test_kasumi_hash_verify_test_case_4(void)
2881 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2885 test_kasumi_hash_verify_test_case_5(void)
2887 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2891 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2893 struct crypto_testsuite_params *ts_params = &testsuite_params;
2894 struct crypto_unittest_params *ut_params = &unittest_params;
2897 uint8_t *plaintext, *ciphertext;
2898 unsigned plaintext_pad_len;
2899 unsigned plaintext_len;
2901 /* Verify the capabilities */
2902 struct rte_cryptodev_sym_capability_idx cap_idx;
2903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2909 /* Create KASUMI session */
2910 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2911 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2912 RTE_CRYPTO_CIPHER_KASUMI_F8,
2913 tdata->key.data, tdata->key.len,
2914 tdata->cipher_iv.len);
2918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2920 /* Clear mbuf payload */
2921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2922 rte_pktmbuf_tailroom(ut_params->ibuf));
2924 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2925 /* Append data which is padded to a multiple */
2926 /* of the algorithms block size */
2927 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2928 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2930 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2932 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2934 /* Create KASUMI operation */
2935 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2936 tdata->cipher_iv.len,
2937 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2938 tdata->validCipherOffsetInBits.len);
2942 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2944 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2946 ut_params->obuf = ut_params->op->sym->m_dst;
2947 if (ut_params->obuf)
2948 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2950 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2952 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2954 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2955 (tdata->validCipherOffsetInBits.len >> 3);
2957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2959 reference_ciphertext,
2960 tdata->validCipherLenInBits.len,
2961 "KASUMI Ciphertext data not as expected");
2966 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2968 struct crypto_testsuite_params *ts_params = &testsuite_params;
2969 struct crypto_unittest_params *ut_params = &unittest_params;
2973 unsigned int plaintext_pad_len;
2974 unsigned int plaintext_len;
2976 uint8_t buffer[10000];
2977 const uint8_t *ciphertext;
2979 struct rte_cryptodev_info dev_info;
2981 /* Verify the capabilities */
2982 struct rte_cryptodev_sym_capability_idx cap_idx;
2983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2984 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2985 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2989 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2991 uint64_t feat_flags = dev_info.feature_flags;
2993 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2994 printf("Device doesn't support in-place scatter-gather. "
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3002 RTE_CRYPTO_CIPHER_KASUMI_F8,
3003 tdata->key.data, tdata->key.len,
3004 tdata->cipher_iv.len);
3008 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3011 /* Append data which is padded to a multiple */
3012 /* of the algorithms block size */
3013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3015 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3016 plaintext_pad_len, 10, 0);
3018 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3020 /* Create KASUMI operation */
3021 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3022 tdata->cipher_iv.len,
3023 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3024 tdata->validCipherOffsetInBits.len);
3028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3032 ut_params->obuf = ut_params->op->sym->m_dst;
3034 if (ut_params->obuf)
3035 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3036 plaintext_len, buffer);
3038 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3039 tdata->validCipherOffsetInBits.len >> 3,
3040 plaintext_len, buffer);
3043 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3045 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3046 (tdata->validCipherOffsetInBits.len >> 3);
3048 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3050 reference_ciphertext,
3051 tdata->validCipherLenInBits.len,
3052 "KASUMI Ciphertext data not as expected");
3057 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3059 struct crypto_testsuite_params *ts_params = &testsuite_params;
3060 struct crypto_unittest_params *ut_params = &unittest_params;
3063 uint8_t *plaintext, *ciphertext;
3064 unsigned plaintext_pad_len;
3065 unsigned plaintext_len;
3067 /* Verify the capabilities */
3068 struct rte_cryptodev_sym_capability_idx cap_idx;
3069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3070 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3071 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3075 /* Create KASUMI session */
3076 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3077 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3078 RTE_CRYPTO_CIPHER_KASUMI_F8,
3079 tdata->key.data, tdata->key.len,
3080 tdata->cipher_iv.len);
3084 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3085 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3087 /* Clear mbuf payload */
3088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3089 rte_pktmbuf_tailroom(ut_params->ibuf));
3091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3092 /* Append data which is padded to a multiple */
3093 /* of the algorithms block size */
3094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3097 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3098 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3100 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3102 /* Create KASUMI operation */
3103 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3104 tdata->cipher_iv.len,
3105 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3106 tdata->validCipherOffsetInBits.len);
3110 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3112 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3114 ut_params->obuf = ut_params->op->sym->m_dst;
3115 if (ut_params->obuf)
3116 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3118 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3120 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3122 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3123 (tdata->validCipherOffsetInBits.len >> 3);
3125 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3127 reference_ciphertext,
3128 tdata->validCipherLenInBits.len,
3129 "KASUMI Ciphertext data not as expected");
3134 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3136 struct crypto_testsuite_params *ts_params = &testsuite_params;
3137 struct crypto_unittest_params *ut_params = &unittest_params;
3140 unsigned int plaintext_pad_len;
3141 unsigned int plaintext_len;
3143 const uint8_t *ciphertext;
3144 uint8_t buffer[2048];
3146 struct rte_cryptodev_info dev_info;
3148 /* Verify the capabilities */
3149 struct rte_cryptodev_sym_capability_idx cap_idx;
3150 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3151 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3152 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3156 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3158 uint64_t feat_flags = dev_info.feature_flags;
3159 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3160 printf("Device doesn't support out-of-place scatter-gather "
3161 "in both input and output mbufs. "
3166 /* Create KASUMI session */
3167 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3168 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3169 RTE_CRYPTO_CIPHER_KASUMI_F8,
3170 tdata->key.data, tdata->key.len,
3171 tdata->cipher_iv.len);
3175 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3176 /* Append data which is padded to a multiple */
3177 /* of the algorithms block size */
3178 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3180 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3181 plaintext_pad_len, 10, 0);
3182 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3183 plaintext_pad_len, 3, 0);
3185 /* Append data which is padded to a multiple */
3186 /* of the algorithms block size */
3187 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3189 /* Create KASUMI operation */
3190 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3191 tdata->cipher_iv.len,
3192 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3193 tdata->validCipherOffsetInBits.len);
3197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3199 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3201 ut_params->obuf = ut_params->op->sym->m_dst;
3202 if (ut_params->obuf)
3203 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3204 plaintext_pad_len, buffer);
3206 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3207 tdata->validCipherOffsetInBits.len >> 3,
3208 plaintext_pad_len, buffer);
3210 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3211 (tdata->validCipherOffsetInBits.len >> 3);
3213 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3215 reference_ciphertext,
3216 tdata->validCipherLenInBits.len,
3217 "KASUMI Ciphertext data not as expected");
3223 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3225 struct crypto_testsuite_params *ts_params = &testsuite_params;
3226 struct crypto_unittest_params *ut_params = &unittest_params;
3229 uint8_t *ciphertext, *plaintext;
3230 unsigned ciphertext_pad_len;
3231 unsigned ciphertext_len;
3233 /* Verify the capabilities */
3234 struct rte_cryptodev_sym_capability_idx cap_idx;
3235 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3236 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3241 /* Create KASUMI session */
3242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3243 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3244 RTE_CRYPTO_CIPHER_KASUMI_F8,
3245 tdata->key.data, tdata->key.len,
3246 tdata->cipher_iv.len);
3250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3253 /* Clear mbuf payload */
3254 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3255 rte_pktmbuf_tailroom(ut_params->ibuf));
3257 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3258 /* Append data which is padded to a multiple */
3259 /* of the algorithms block size */
3260 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3261 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3262 ciphertext_pad_len);
3263 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3264 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3266 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3268 /* Create KASUMI operation */
3269 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3270 tdata->cipher_iv.len,
3271 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3272 tdata->validCipherOffsetInBits.len);
3276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_dst;
3281 if (ut_params->obuf)
3282 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3284 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3286 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3288 const uint8_t *reference_plaintext = tdata->plaintext.data +
3289 (tdata->validCipherOffsetInBits.len >> 3);
3291 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3293 reference_plaintext,
3294 tdata->validCipherLenInBits.len,
3295 "KASUMI Plaintext data not as expected");
3300 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3302 struct crypto_testsuite_params *ts_params = &testsuite_params;
3303 struct crypto_unittest_params *ut_params = &unittest_params;
3306 uint8_t *ciphertext, *plaintext;
3307 unsigned ciphertext_pad_len;
3308 unsigned ciphertext_len;
3310 /* Verify the capabilities */
3311 struct rte_cryptodev_sym_capability_idx cap_idx;
3312 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3313 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3314 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3318 /* Create KASUMI session */
3319 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3320 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3321 RTE_CRYPTO_CIPHER_KASUMI_F8,
3322 tdata->key.data, tdata->key.len,
3323 tdata->cipher_iv.len);
3327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3329 /* Clear mbuf payload */
3330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3331 rte_pktmbuf_tailroom(ut_params->ibuf));
3333 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3334 /* Append data which is padded to a multiple */
3335 /* of the algorithms block size */
3336 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3337 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3338 ciphertext_pad_len);
3339 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3341 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3343 /* Create KASUMI operation */
3344 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3345 tdata->cipher_iv.len,
3346 tdata->ciphertext.len,
3347 tdata->validCipherOffsetInBits.len);
3351 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3353 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3355 ut_params->obuf = ut_params->op->sym->m_dst;
3356 if (ut_params->obuf)
3357 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3359 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3361 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3363 const uint8_t *reference_plaintext = tdata->plaintext.data +
3364 (tdata->validCipherOffsetInBits.len >> 3);
3366 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3368 reference_plaintext,
3369 tdata->validCipherLenInBits.len,
3370 "KASUMI Plaintext data not as expected");
3375 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3377 struct crypto_testsuite_params *ts_params = &testsuite_params;
3378 struct crypto_unittest_params *ut_params = &unittest_params;
3381 uint8_t *plaintext, *ciphertext;
3382 unsigned plaintext_pad_len;
3383 unsigned plaintext_len;
3385 /* Verify the capabilities */
3386 struct rte_cryptodev_sym_capability_idx cap_idx;
3387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3393 /* Create SNOW 3G session */
3394 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3395 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3396 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3397 tdata->key.data, tdata->key.len,
3398 tdata->cipher_iv.len);
3402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3404 /* Clear mbuf payload */
3405 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3406 rte_pktmbuf_tailroom(ut_params->ibuf));
3408 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3409 /* Append data which is padded to a multiple of */
3410 /* the algorithms block size */
3411 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3412 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3414 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3416 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3418 /* Create SNOW 3G operation */
3419 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3420 tdata->cipher_iv.len,
3421 tdata->validCipherLenInBits.len,
3426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3430 ut_params->obuf = ut_params->op->sym->m_dst;
3431 if (ut_params->obuf)
3432 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3434 ciphertext = plaintext;
3436 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3439 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3441 tdata->ciphertext.data,
3442 tdata->validDataLenInBits.len,
3443 "SNOW 3G Ciphertext data not as expected");
3449 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3453 uint8_t *plaintext, *ciphertext;
3456 unsigned plaintext_pad_len;
3457 unsigned plaintext_len;
3459 /* Verify the capabilities */
3460 struct rte_cryptodev_sym_capability_idx cap_idx;
3461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3462 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3467 /* Create SNOW 3G session */
3468 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3470 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3471 tdata->key.data, tdata->key.len,
3472 tdata->cipher_iv.len);
3476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3480 "Failed to allocate input buffer in mempool");
3481 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3482 "Failed to allocate output buffer in mempool");
3484 /* Clear mbuf payload */
3485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3486 rte_pktmbuf_tailroom(ut_params->ibuf));
3488 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3489 /* Append data which is padded to a multiple of */
3490 /* the algorithms block size */
3491 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3492 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3494 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3497 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3499 /* Create SNOW 3G operation */
3500 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3501 tdata->cipher_iv.len,
3502 tdata->validCipherLenInBits.len,
3507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 ut_params->obuf = ut_params->op->sym->m_dst;
3512 if (ut_params->obuf)
3513 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3515 ciphertext = plaintext;
3517 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3520 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3522 tdata->ciphertext.data,
3523 tdata->validDataLenInBits.len,
3524 "SNOW 3G Ciphertext data not as expected");
3529 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3531 struct crypto_testsuite_params *ts_params = &testsuite_params;
3532 struct crypto_unittest_params *ut_params = &unittest_params;
3535 unsigned int plaintext_pad_len;
3536 unsigned int plaintext_len;
3537 uint8_t buffer[10000];
3538 const uint8_t *ciphertext;
3540 struct rte_cryptodev_info dev_info;
3542 /* Verify the capabilities */
3543 struct rte_cryptodev_sym_capability_idx cap_idx;
3544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3545 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3550 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3552 uint64_t feat_flags = dev_info.feature_flags;
3554 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3555 printf("Device doesn't support out-of-place scatter-gather "
3556 "in both input and output mbufs. "
3561 /* Create SNOW 3G session */
3562 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3563 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3564 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3565 tdata->key.data, tdata->key.len,
3566 tdata->cipher_iv.len);
3570 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3571 /* Append data which is padded to a multiple of */
3572 /* the algorithms block size */
3573 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3575 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3576 plaintext_pad_len, 10, 0);
3577 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 3, 0);
3580 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3581 "Failed to allocate input buffer in mempool");
3582 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3583 "Failed to allocate output buffer in mempool");
3585 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3587 /* Create SNOW 3G operation */
3588 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3589 tdata->cipher_iv.len,
3590 tdata->validCipherLenInBits.len,
3595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3597 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3599 ut_params->obuf = ut_params->op->sym->m_dst;
3600 if (ut_params->obuf)
3601 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3602 plaintext_len, buffer);
3604 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3605 plaintext_len, buffer);
3607 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3610 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3612 tdata->ciphertext.data,
3613 tdata->validDataLenInBits.len,
3614 "SNOW 3G Ciphertext data not as expected");
3619 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3621 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3623 uint8_t curr_byte, prev_byte;
3624 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3625 uint8_t lower_byte_mask = (1 << offset) - 1;
3628 prev_byte = buffer[0];
3629 buffer[0] >>= offset;
3631 for (i = 1; i < length_in_bytes; i++) {
3632 curr_byte = buffer[i];
3633 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3634 (curr_byte >> offset);
3635 prev_byte = curr_byte;
3640 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3642 struct crypto_testsuite_params *ts_params = &testsuite_params;
3643 struct crypto_unittest_params *ut_params = &unittest_params;
3644 uint8_t *plaintext, *ciphertext;
3646 uint32_t plaintext_len;
3647 uint32_t plaintext_pad_len;
3648 uint8_t extra_offset = 4;
3649 uint8_t *expected_ciphertext_shifted;
3650 struct rte_cryptodev_info dev_info;
3652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3653 uint64_t feat_flags = dev_info.feature_flags;
3655 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3656 ((tdata->validDataLenInBits.len % 8) != 0)) {
3657 printf("Device doesn't support NON-Byte Aligned Data.\n");
3661 /* Verify the capabilities */
3662 struct rte_cryptodev_sym_capability_idx cap_idx;
3663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3664 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3669 /* Create SNOW 3G session */
3670 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3671 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3672 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3673 tdata->key.data, tdata->key.len,
3674 tdata->cipher_iv.len);
3678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3681 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3682 "Failed to allocate input buffer in mempool");
3683 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3684 "Failed to allocate output buffer in mempool");
3686 /* Clear mbuf payload */
3687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 rte_pktmbuf_tailroom(ut_params->ibuf));
3690 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3692 * Append data which is padded to a
3693 * multiple of the algorithms block size
3695 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3697 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3700 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3702 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3703 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3705 #ifdef RTE_APP_TEST_DEBUG
3706 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3708 /* Create SNOW 3G operation */
3709 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3710 tdata->cipher_iv.len,
3711 tdata->validCipherLenInBits.len,
3716 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3720 ut_params->obuf = ut_params->op->sym->m_dst;
3721 if (ut_params->obuf)
3722 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3724 ciphertext = plaintext;
3726 #ifdef RTE_APP_TEST_DEBUG
3727 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3730 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3732 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3733 "failed to reserve memory for ciphertext shifted\n");
3735 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3736 ceil_byte_length(tdata->ciphertext.len));
3737 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3742 expected_ciphertext_shifted,
3743 tdata->validDataLenInBits.len,
3745 "SNOW 3G Ciphertext data not as expected");
3749 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3751 struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 struct crypto_unittest_params *ut_params = &unittest_params;
3756 uint8_t *plaintext, *ciphertext;
3757 unsigned ciphertext_pad_len;
3758 unsigned ciphertext_len;
3760 /* Verify the capabilities */
3761 struct rte_cryptodev_sym_capability_idx cap_idx;
3762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3763 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3768 /* Create SNOW 3G session */
3769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3770 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3772 tdata->key.data, tdata->key.len,
3773 tdata->cipher_iv.len);
3777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3779 /* Clear mbuf payload */
3780 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3781 rte_pktmbuf_tailroom(ut_params->ibuf));
3783 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3784 /* Append data which is padded to a multiple of */
3785 /* the algorithms block size */
3786 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3787 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 ciphertext_pad_len);
3789 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3791 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3793 /* Create SNOW 3G operation */
3794 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3795 tdata->cipher_iv.len,
3796 tdata->validCipherLenInBits.len,
3797 tdata->cipher.offset_bits);
3801 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3803 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3804 ut_params->obuf = ut_params->op->sym->m_dst;
3805 if (ut_params->obuf)
3806 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3808 plaintext = ciphertext;
3810 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3814 tdata->plaintext.data,
3815 tdata->validDataLenInBits.len,
3816 "SNOW 3G Plaintext data not as expected");
3820 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3822 struct crypto_testsuite_params *ts_params = &testsuite_params;
3823 struct crypto_unittest_params *ut_params = &unittest_params;
3827 uint8_t *plaintext, *ciphertext;
3828 unsigned ciphertext_pad_len;
3829 unsigned ciphertext_len;
3831 /* Verify the capabilities */
3832 struct rte_cryptodev_sym_capability_idx cap_idx;
3833 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3834 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3839 /* Create SNOW 3G session */
3840 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3841 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3842 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3843 tdata->key.data, tdata->key.len,
3844 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3849 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3852 "Failed to allocate input buffer");
3853 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3854 "Failed to allocate output buffer");
3856 /* Clear mbuf payload */
3857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3858 rte_pktmbuf_tailroom(ut_params->ibuf));
3860 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3861 rte_pktmbuf_tailroom(ut_params->obuf));
3863 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3864 /* Append data which is padded to a multiple of */
3865 /* the algorithms block size */
3866 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3867 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 ciphertext_pad_len);
3869 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3870 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3874 /* Create SNOW 3G operation */
3875 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3876 tdata->cipher_iv.len,
3877 tdata->validCipherLenInBits.len,
3882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3885 ut_params->obuf = ut_params->op->sym->m_dst;
3886 if (ut_params->obuf)
3887 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3889 plaintext = ciphertext;
3891 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3895 tdata->plaintext.data,
3896 tdata->validDataLenInBits.len,
3897 "SNOW 3G Plaintext data not as expected");
3902 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3904 struct crypto_testsuite_params *ts_params = &testsuite_params;
3905 struct crypto_unittest_params *ut_params = &unittest_params;
3909 uint8_t *plaintext, *ciphertext;
3910 unsigned int plaintext_pad_len;
3911 unsigned int plaintext_len;
3913 struct rte_cryptodev_info dev_info;
3914 struct rte_cryptodev_sym_capability_idx cap_idx;
3916 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3917 uint64_t feat_flags = dev_info.feature_flags;
3919 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3920 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3921 (tdata->validDataLenInBits.len % 8 != 0))) {
3922 printf("Device doesn't support NON-Byte Aligned Data.\n");
3926 /* Check if device supports ZUC EEA3 */
3927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3928 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3930 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3934 /* Check if device supports ZUC EIA3 */
3935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3936 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3938 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3942 /* Create ZUC session */
3943 retval = create_zuc_cipher_auth_encrypt_generate_session(
3944 ts_params->valid_devs[0],
3948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3950 /* clear mbuf payload */
3951 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3952 rte_pktmbuf_tailroom(ut_params->ibuf));
3954 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3955 /* Append data which is padded to a multiple of */
3956 /* the algorithms block size */
3957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3958 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3960 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3962 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3964 /* Create ZUC operation */
3965 retval = create_zuc_cipher_hash_generate_operation(tdata);
3969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3972 ut_params->obuf = ut_params->op->sym->m_src;
3973 if (ut_params->obuf)
3974 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3976 ciphertext = plaintext;
3978 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 tdata->ciphertext.data,
3983 tdata->validDataLenInBits.len,
3984 "ZUC Ciphertext data not as expected");
3986 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3987 + plaintext_pad_len;
3990 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3994 "ZUC Generated auth tag not as expected");
3999 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4001 struct crypto_testsuite_params *ts_params = &testsuite_params;
4002 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *plaintext, *ciphertext;
4007 unsigned plaintext_pad_len;
4008 unsigned plaintext_len;
4010 /* Verify the capabilities */
4011 struct rte_cryptodev_sym_capability_idx cap_idx;
4012 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4013 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4014 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4018 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4023 /* Create SNOW 3G session */
4024 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4025 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4026 RTE_CRYPTO_AUTH_OP_GENERATE,
4027 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4029 tdata->key.data, tdata->key.len,
4030 tdata->auth_iv.len, tdata->digest.len,
4031 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 /* clear mbuf payload */
4037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4038 rte_pktmbuf_tailroom(ut_params->ibuf));
4040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4041 /* Append data which is padded to a multiple of */
4042 /* the algorithms block size */
4043 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4044 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4048 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4052 tdata->digest.len, tdata->auth_iv.data,
4054 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4055 tdata->cipher_iv.data, tdata->cipher_iv.len,
4056 tdata->validCipherLenInBits.len,
4058 tdata->validAuthLenInBits.len,
4064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4066 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4067 ut_params->obuf = ut_params->op->sym->m_src;
4068 if (ut_params->obuf)
4069 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4071 ciphertext = plaintext;
4073 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4077 tdata->ciphertext.data,
4078 tdata->validDataLenInBits.len,
4079 "SNOW 3G Ciphertext data not as expected");
4081 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4082 + plaintext_pad_len;
4085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4088 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4089 "SNOW 3G Generated auth tag not as expected");
4094 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4095 uint8_t op_mode, uint8_t verify)
4097 struct crypto_testsuite_params *ts_params = &testsuite_params;
4098 struct crypto_unittest_params *ut_params = &unittest_params;
4102 uint8_t *plaintext = NULL, *ciphertext = NULL;
4103 unsigned int plaintext_pad_len;
4104 unsigned int plaintext_len;
4105 unsigned int ciphertext_pad_len;
4106 unsigned int ciphertext_len;
4108 struct rte_cryptodev_info dev_info;
4110 /* Verify the capabilities */
4111 struct rte_cryptodev_sym_capability_idx cap_idx;
4112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4113 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4114 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4117 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4118 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4119 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4123 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4125 uint64_t feat_flags = dev_info.feature_flags;
4127 if (op_mode == OUT_OF_PLACE) {
4128 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4129 printf("Device doesn't support digest encrypted.\n");
4134 /* Create SNOW 3G session */
4135 retval = create_wireless_algo_auth_cipher_session(
4136 ts_params->valid_devs[0],
4137 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4138 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4139 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4140 : RTE_CRYPTO_AUTH_OP_GENERATE),
4141 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4142 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4143 tdata->key.data, tdata->key.len,
4144 tdata->auth_iv.len, tdata->digest.len,
4145 tdata->cipher_iv.len);
4150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4151 if (op_mode == OUT_OF_PLACE)
4152 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4154 /* clear mbuf payload */
4155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4156 rte_pktmbuf_tailroom(ut_params->ibuf));
4157 if (op_mode == OUT_OF_PLACE)
4158 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4159 rte_pktmbuf_tailroom(ut_params->obuf));
4161 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4162 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4163 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4164 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4167 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4168 ciphertext_pad_len);
4169 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4170 if (op_mode == OUT_OF_PLACE)
4171 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4172 debug_hexdump(stdout, "ciphertext:", ciphertext,
4175 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4177 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4178 if (op_mode == OUT_OF_PLACE)
4179 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4180 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4183 /* Create SNOW 3G operation */
4184 retval = create_wireless_algo_auth_cipher_operation(
4185 tdata->digest.data, tdata->digest.len,
4186 tdata->cipher_iv.data, tdata->cipher_iv.len,
4187 tdata->auth_iv.data, tdata->auth_iv.len,
4188 (tdata->digest.offset_bytes == 0 ?
4189 (verify ? ciphertext_pad_len : plaintext_pad_len)
4190 : tdata->digest.offset_bytes),
4191 tdata->validCipherLenInBits.len,
4192 tdata->cipher.offset_bits,
4193 tdata->validAuthLenInBits.len,
4194 tdata->auth.offset_bits,
4195 op_mode, 0, verify);
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4205 ut_params->obuf = (op_mode == IN_PLACE ?
4206 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4209 if (ut_params->obuf)
4210 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4213 plaintext = ciphertext +
4214 (tdata->cipher.offset_bits >> 3);
4216 debug_hexdump(stdout, "plaintext:", plaintext,
4217 (tdata->plaintext.len >> 3) - tdata->digest.len);
4218 debug_hexdump(stdout, "plaintext expected:",
4219 tdata->plaintext.data,
4220 (tdata->plaintext.len >> 3) - tdata->digest.len);
4222 if (ut_params->obuf)
4223 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4226 ciphertext = plaintext;
4228 debug_hexdump(stdout, "ciphertext:", ciphertext,
4230 debug_hexdump(stdout, "ciphertext expected:",
4231 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4233 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4234 + (tdata->digest.offset_bytes == 0 ?
4235 plaintext_pad_len : tdata->digest.offset_bytes);
4237 debug_hexdump(stdout, "digest:", ut_params->digest,
4239 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4245 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4247 tdata->plaintext.data,
4248 tdata->plaintext.len >> 3,
4249 "SNOW 3G Plaintext data not as expected");
4251 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4253 tdata->ciphertext.data,
4254 tdata->validDataLenInBits.len,
4255 "SNOW 3G Ciphertext data not as expected");
4257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4260 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4261 "SNOW 3G Generated auth tag not as expected");
4267 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4268 uint8_t op_mode, uint8_t verify)
4270 struct crypto_testsuite_params *ts_params = &testsuite_params;
4271 struct crypto_unittest_params *ut_params = &unittest_params;
4275 const uint8_t *plaintext = NULL;
4276 const uint8_t *ciphertext = NULL;
4277 const uint8_t *digest = NULL;
4278 unsigned int plaintext_pad_len;
4279 unsigned int plaintext_len;
4280 unsigned int ciphertext_pad_len;
4281 unsigned int ciphertext_len;
4282 uint8_t buffer[10000];
4283 uint8_t digest_buffer[10000];
4285 struct rte_cryptodev_info dev_info;
4287 /* Verify the capabilities */
4288 struct rte_cryptodev_sym_capability_idx cap_idx;
4289 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4290 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4291 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4294 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4295 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4302 uint64_t feat_flags = dev_info.feature_flags;
4304 if (op_mode == IN_PLACE) {
4305 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4306 printf("Device doesn't support in-place scatter-gather "
4307 "in both input and output mbufs.\n");
4311 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4312 printf("Device doesn't support out-of-place scatter-gather "
4313 "in both input and output mbufs.\n");
4316 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4317 printf("Device doesn't support digest encrypted.\n");
4322 /* Create SNOW 3G session */
4323 retval = create_wireless_algo_auth_cipher_session(
4324 ts_params->valid_devs[0],
4325 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4326 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4327 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4328 : RTE_CRYPTO_AUTH_OP_GENERATE),
4329 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4330 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4331 tdata->key.data, tdata->key.len,
4332 tdata->auth_iv.len, tdata->digest.len,
4333 tdata->cipher_iv.len);
4338 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4339 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4340 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4341 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4343 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4344 plaintext_pad_len, 15, 0);
4345 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4346 "Failed to allocate input buffer in mempool");
4348 if (op_mode == OUT_OF_PLACE) {
4349 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4350 plaintext_pad_len, 15, 0);
4351 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4352 "Failed to allocate output buffer in mempool");
4356 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4357 tdata->ciphertext.data);
4358 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4359 ciphertext_len, buffer);
4360 debug_hexdump(stdout, "ciphertext:", ciphertext,
4363 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4364 tdata->plaintext.data);
4365 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4366 plaintext_len, buffer);
4367 debug_hexdump(stdout, "plaintext:", plaintext,
4370 memset(buffer, 0, sizeof(buffer));
4372 /* Create SNOW 3G operation */
4373 retval = create_wireless_algo_auth_cipher_operation(
4374 tdata->digest.data, tdata->digest.len,
4375 tdata->cipher_iv.data, tdata->cipher_iv.len,
4376 tdata->auth_iv.data, tdata->auth_iv.len,
4377 (tdata->digest.offset_bytes == 0 ?
4378 (verify ? ciphertext_pad_len : plaintext_pad_len)
4379 : tdata->digest.offset_bytes),
4380 tdata->validCipherLenInBits.len,
4381 tdata->cipher.offset_bits,
4382 tdata->validAuthLenInBits.len,
4383 tdata->auth.offset_bits,
4384 op_mode, 1, verify);
4389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4394 ut_params->obuf = (op_mode == IN_PLACE ?
4395 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4398 if (ut_params->obuf)
4399 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4400 plaintext_len, buffer);
4402 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4403 plaintext_len, buffer);
4405 debug_hexdump(stdout, "plaintext:", plaintext,
4406 (tdata->plaintext.len >> 3) - tdata->digest.len);
4407 debug_hexdump(stdout, "plaintext expected:",
4408 tdata->plaintext.data,
4409 (tdata->plaintext.len >> 3) - tdata->digest.len);
4411 if (ut_params->obuf)
4412 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4413 ciphertext_len, buffer);
4415 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4416 ciphertext_len, buffer);
4418 debug_hexdump(stdout, "ciphertext:", ciphertext,
4420 debug_hexdump(stdout, "ciphertext expected:",
4421 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4423 if (ut_params->obuf)
4424 digest = rte_pktmbuf_read(ut_params->obuf,
4425 (tdata->digest.offset_bytes == 0 ?
4426 plaintext_pad_len : tdata->digest.offset_bytes),
4427 tdata->digest.len, digest_buffer);
4429 digest = rte_pktmbuf_read(ut_params->ibuf,
4430 (tdata->digest.offset_bytes == 0 ?
4431 plaintext_pad_len : tdata->digest.offset_bytes),
4432 tdata->digest.len, digest_buffer);
4434 debug_hexdump(stdout, "digest:", digest,
4436 debug_hexdump(stdout, "digest expected:",
4437 tdata->digest.data, tdata->digest.len);
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4444 tdata->plaintext.data,
4445 tdata->plaintext.len >> 3,
4446 "SNOW 3G Plaintext data not as expected");
4448 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4450 tdata->ciphertext.data,
4451 tdata->validDataLenInBits.len,
4452 "SNOW 3G Ciphertext data not as expected");
4454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4457 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4458 "SNOW 3G Generated auth tag not as expected");
4464 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4465 uint8_t op_mode, uint8_t verify)
4467 struct crypto_testsuite_params *ts_params = &testsuite_params;
4468 struct crypto_unittest_params *ut_params = &unittest_params;
4472 uint8_t *plaintext = NULL, *ciphertext = NULL;
4473 unsigned int plaintext_pad_len;
4474 unsigned int plaintext_len;
4475 unsigned int ciphertext_pad_len;
4476 unsigned int ciphertext_len;
4478 struct rte_cryptodev_info dev_info;
4480 /* Verify the capabilities */
4481 struct rte_cryptodev_sym_capability_idx cap_idx;
4482 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4483 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4484 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4489 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4493 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4495 uint64_t feat_flags = dev_info.feature_flags;
4497 if (op_mode == OUT_OF_PLACE) {
4498 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4499 printf("Device doesn't support digest encrypted.\n");
4504 /* Create KASUMI session */
4505 retval = create_wireless_algo_auth_cipher_session(
4506 ts_params->valid_devs[0],
4507 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4508 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4509 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4510 : RTE_CRYPTO_AUTH_OP_GENERATE),
4511 RTE_CRYPTO_AUTH_KASUMI_F9,
4512 RTE_CRYPTO_CIPHER_KASUMI_F8,
4513 tdata->key.data, tdata->key.len,
4514 0, tdata->digest.len,
4515 tdata->cipher_iv.len);
4520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4521 if (op_mode == OUT_OF_PLACE)
4522 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4524 /* clear mbuf payload */
4525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4526 rte_pktmbuf_tailroom(ut_params->ibuf));
4527 if (op_mode == OUT_OF_PLACE)
4528 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4529 rte_pktmbuf_tailroom(ut_params->obuf));
4531 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4532 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4533 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4534 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4537 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4538 ciphertext_pad_len);
4539 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4540 if (op_mode == OUT_OF_PLACE)
4541 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4542 debug_hexdump(stdout, "ciphertext:", ciphertext,
4545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4548 if (op_mode == OUT_OF_PLACE)
4549 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4550 debug_hexdump(stdout, "plaintext:", plaintext,
4554 /* Create KASUMI operation */
4555 retval = create_wireless_algo_auth_cipher_operation(
4556 tdata->digest.data, tdata->digest.len,
4557 tdata->cipher_iv.data, tdata->cipher_iv.len,
4559 (tdata->digest.offset_bytes == 0 ?
4560 (verify ? ciphertext_pad_len : plaintext_pad_len)
4561 : tdata->digest.offset_bytes),
4562 tdata->validCipherLenInBits.len,
4563 tdata->validCipherOffsetInBits.len,
4564 tdata->validAuthLenInBits.len,
4566 op_mode, 0, verify);
4571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4574 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4576 ut_params->obuf = (op_mode == IN_PLACE ?
4577 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4581 if (ut_params->obuf)
4582 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4585 plaintext = ciphertext;
4587 debug_hexdump(stdout, "plaintext:", plaintext,
4588 (tdata->plaintext.len >> 3) - tdata->digest.len);
4589 debug_hexdump(stdout, "plaintext expected:",
4590 tdata->plaintext.data,
4591 (tdata->plaintext.len >> 3) - tdata->digest.len);
4593 if (ut_params->obuf)
4594 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4597 ciphertext = plaintext;
4599 debug_hexdump(stdout, "ciphertext:", ciphertext,
4601 debug_hexdump(stdout, "ciphertext expected:",
4602 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4604 ut_params->digest = rte_pktmbuf_mtod(
4605 ut_params->obuf, uint8_t *) +
4606 (tdata->digest.offset_bytes == 0 ?
4607 plaintext_pad_len : tdata->digest.offset_bytes);
4609 debug_hexdump(stdout, "digest:", ut_params->digest,
4611 debug_hexdump(stdout, "digest expected:",
4612 tdata->digest.data, tdata->digest.len);
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4619 tdata->plaintext.data,
4620 tdata->plaintext.len >> 3,
4621 "KASUMI Plaintext data not as expected");
4623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4625 tdata->ciphertext.data,
4626 tdata->ciphertext.len >> 3,
4627 "KASUMI Ciphertext data not as expected");
4629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4632 DIGEST_BYTE_LENGTH_KASUMI_F9,
4633 "KASUMI Generated auth tag not as expected");
4639 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4640 uint8_t op_mode, uint8_t verify)
4642 struct crypto_testsuite_params *ts_params = &testsuite_params;
4643 struct crypto_unittest_params *ut_params = &unittest_params;
4647 const uint8_t *plaintext = NULL;
4648 const uint8_t *ciphertext = NULL;
4649 const uint8_t *digest = NULL;
4650 unsigned int plaintext_pad_len;
4651 unsigned int plaintext_len;
4652 unsigned int ciphertext_pad_len;
4653 unsigned int ciphertext_len;
4654 uint8_t buffer[10000];
4655 uint8_t digest_buffer[10000];
4657 struct rte_cryptodev_info dev_info;
4659 /* Verify the capabilities */
4660 struct rte_cryptodev_sym_capability_idx cap_idx;
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4662 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4666 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4667 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4674 uint64_t feat_flags = dev_info.feature_flags;
4676 if (op_mode == IN_PLACE) {
4677 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4678 printf("Device doesn't support in-place scatter-gather "
4679 "in both input and output mbufs.\n");
4683 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4684 printf("Device doesn't support out-of-place scatter-gather "
4685 "in both input and output mbufs.\n");
4688 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4689 printf("Device doesn't support digest encrypted.\n");
4694 /* Create KASUMI session */
4695 retval = create_wireless_algo_auth_cipher_session(
4696 ts_params->valid_devs[0],
4697 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4698 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4699 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4700 : RTE_CRYPTO_AUTH_OP_GENERATE),
4701 RTE_CRYPTO_AUTH_KASUMI_F9,
4702 RTE_CRYPTO_CIPHER_KASUMI_F8,
4703 tdata->key.data, tdata->key.len,
4704 0, tdata->digest.len,
4705 tdata->cipher_iv.len);
4710 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4711 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4712 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4713 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4715 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4716 plaintext_pad_len, 15, 0);
4717 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4718 "Failed to allocate input buffer in mempool");
4720 if (op_mode == OUT_OF_PLACE) {
4721 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4722 plaintext_pad_len, 15, 0);
4723 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4724 "Failed to allocate output buffer in mempool");
4728 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4729 tdata->ciphertext.data);
4730 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4731 ciphertext_len, buffer);
4732 debug_hexdump(stdout, "ciphertext:", ciphertext,
4735 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4736 tdata->plaintext.data);
4737 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4738 plaintext_len, buffer);
4739 debug_hexdump(stdout, "plaintext:", plaintext,
4742 memset(buffer, 0, sizeof(buffer));
4744 /* Create KASUMI operation */
4745 retval = create_wireless_algo_auth_cipher_operation(
4746 tdata->digest.data, tdata->digest.len,
4747 tdata->cipher_iv.data, tdata->cipher_iv.len,
4749 (tdata->digest.offset_bytes == 0 ?
4750 (verify ? ciphertext_pad_len : plaintext_pad_len)
4751 : tdata->digest.offset_bytes),
4752 tdata->validCipherLenInBits.len,
4753 tdata->validCipherOffsetInBits.len,
4754 tdata->validAuthLenInBits.len,
4756 op_mode, 1, verify);
4761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4764 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4766 ut_params->obuf = (op_mode == IN_PLACE ?
4767 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4770 if (ut_params->obuf)
4771 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4772 plaintext_len, buffer);
4774 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4775 plaintext_len, buffer);
4777 debug_hexdump(stdout, "plaintext:", plaintext,
4778 (tdata->plaintext.len >> 3) - tdata->digest.len);
4779 debug_hexdump(stdout, "plaintext expected:",
4780 tdata->plaintext.data,
4781 (tdata->plaintext.len >> 3) - tdata->digest.len);
4783 if (ut_params->obuf)
4784 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4785 ciphertext_len, buffer);
4787 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4788 ciphertext_len, buffer);
4790 debug_hexdump(stdout, "ciphertext:", ciphertext,
4792 debug_hexdump(stdout, "ciphertext expected:",
4793 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4795 if (ut_params->obuf)
4796 digest = rte_pktmbuf_read(ut_params->obuf,
4797 (tdata->digest.offset_bytes == 0 ?
4798 plaintext_pad_len : tdata->digest.offset_bytes),
4799 tdata->digest.len, digest_buffer);
4801 digest = rte_pktmbuf_read(ut_params->ibuf,
4802 (tdata->digest.offset_bytes == 0 ?
4803 plaintext_pad_len : tdata->digest.offset_bytes),
4804 tdata->digest.len, digest_buffer);
4806 debug_hexdump(stdout, "digest:", digest,
4808 debug_hexdump(stdout, "digest expected:",
4809 tdata->digest.data, tdata->digest.len);
4814 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4816 tdata->plaintext.data,
4817 tdata->plaintext.len >> 3,
4818 "KASUMI Plaintext data not as expected");
4820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4822 tdata->ciphertext.data,
4823 tdata->validDataLenInBits.len,
4824 "KASUMI Ciphertext data not as expected");
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4829 DIGEST_BYTE_LENGTH_KASUMI_F9,
4830 "KASUMI Generated auth tag not as expected");
4836 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4838 struct crypto_testsuite_params *ts_params = &testsuite_params;
4839 struct crypto_unittest_params *ut_params = &unittest_params;
4843 uint8_t *plaintext, *ciphertext;
4844 unsigned plaintext_pad_len;
4845 unsigned plaintext_len;
4847 /* Verify the capabilities */
4848 struct rte_cryptodev_sym_capability_idx cap_idx;
4849 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4850 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4851 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4854 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4855 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4856 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4860 /* Create KASUMI session */
4861 retval = create_wireless_algo_cipher_auth_session(
4862 ts_params->valid_devs[0],
4863 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4864 RTE_CRYPTO_AUTH_OP_GENERATE,
4865 RTE_CRYPTO_AUTH_KASUMI_F9,
4866 RTE_CRYPTO_CIPHER_KASUMI_F8,
4867 tdata->key.data, tdata->key.len,
4868 0, tdata->digest.len,
4869 tdata->cipher_iv.len);
4873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4875 /* clear mbuf payload */
4876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4877 rte_pktmbuf_tailroom(ut_params->ibuf));
4879 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4880 /* Append data which is padded to a multiple of */
4881 /* the algorithms block size */
4882 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4883 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4885 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4887 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4889 /* Create KASUMI operation */
4890 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4891 tdata->digest.len, NULL, 0,
4892 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4893 tdata->cipher_iv.data, tdata->cipher_iv.len,
4894 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4895 tdata->validCipherOffsetInBits.len,
4896 tdata->validAuthLenInBits.len,
4902 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4904 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4906 if (ut_params->op->sym->m_dst)
4907 ut_params->obuf = ut_params->op->sym->m_dst;
4909 ut_params->obuf = ut_params->op->sym->m_src;
4911 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4912 tdata->validCipherOffsetInBits.len >> 3);
4914 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4915 + plaintext_pad_len;
4917 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4918 (tdata->validCipherOffsetInBits.len >> 3);
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4922 reference_ciphertext,
4923 tdata->validCipherLenInBits.len,
4924 "KASUMI Ciphertext data not as expected");
4927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4930 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4931 "KASUMI Generated auth tag not as expected");
4936 test_zuc_encryption(const struct wireless_test_data *tdata)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4939 struct crypto_unittest_params *ut_params = &unittest_params;
4942 uint8_t *plaintext, *ciphertext;
4943 unsigned plaintext_pad_len;
4944 unsigned plaintext_len;
4946 struct rte_cryptodev_sym_capability_idx cap_idx;
4948 /* Check if device supports ZUC EEA3 */
4949 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4950 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4956 /* Create ZUC session */
4957 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4958 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4959 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4960 tdata->key.data, tdata->key.len,
4961 tdata->cipher_iv.len);
4965 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4967 /* Clear mbuf payload */
4968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4969 rte_pktmbuf_tailroom(ut_params->ibuf));
4971 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4972 /* Append data which is padded to a multiple */
4973 /* of the algorithms block size */
4974 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4975 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4977 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4979 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4981 /* Create ZUC operation */
4982 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4983 tdata->cipher_iv.len,
4984 tdata->plaintext.len,
4989 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4991 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4993 ut_params->obuf = ut_params->op->sym->m_dst;
4994 if (ut_params->obuf)
4995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4997 ciphertext = plaintext;
4999 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5004 tdata->ciphertext.data,
5005 tdata->validCipherLenInBits.len,
5006 "ZUC Ciphertext data not as expected");
5011 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5013 struct crypto_testsuite_params *ts_params = &testsuite_params;
5014 struct crypto_unittest_params *ut_params = &unittest_params;
5018 unsigned int plaintext_pad_len;
5019 unsigned int plaintext_len;
5020 const uint8_t *ciphertext;
5021 uint8_t ciphertext_buffer[2048];
5022 struct rte_cryptodev_info dev_info;
5024 struct rte_cryptodev_sym_capability_idx cap_idx;
5026 /* Check if device supports ZUC EEA3 */
5027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5028 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5030 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5034 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5036 uint64_t feat_flags = dev_info.feature_flags;
5038 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5039 printf("Device doesn't support in-place scatter-gather. "
5044 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5046 /* Append data which is padded to a multiple */
5047 /* of the algorithms block size */
5048 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5050 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5051 plaintext_pad_len, 10, 0);
5053 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5054 tdata->plaintext.data);
5056 /* Create ZUC session */
5057 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5058 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5059 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5060 tdata->key.data, tdata->key.len,
5061 tdata->cipher_iv.len);
5065 /* Clear mbuf payload */
5067 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5069 /* Create ZUC operation */
5070 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5071 tdata->cipher_iv.len, tdata->plaintext.len,
5076 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5078 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5080 ut_params->obuf = ut_params->op->sym->m_dst;
5081 if (ut_params->obuf)
5082 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5083 0, plaintext_len, ciphertext_buffer);
5085 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5086 0, plaintext_len, ciphertext_buffer);
5089 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5092 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5094 tdata->ciphertext.data,
5095 tdata->validCipherLenInBits.len,
5096 "ZUC Ciphertext data not as expected");
5102 test_zuc_authentication(const struct wireless_test_data *tdata)
5104 struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 struct crypto_unittest_params *ut_params = &unittest_params;
5108 unsigned plaintext_pad_len;
5109 unsigned plaintext_len;
5112 struct rte_cryptodev_sym_capability_idx cap_idx;
5113 struct rte_cryptodev_info dev_info;
5115 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5116 uint64_t feat_flags = dev_info.feature_flags;
5118 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5119 (tdata->validAuthLenInBits.len % 8 != 0)) {
5120 printf("Device doesn't support NON-Byte Aligned Data.\n");
5124 /* Check if device supports ZUC EIA3 */
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5126 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5128 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5132 /* Create ZUC session */
5133 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5134 tdata->key.data, tdata->key.len,
5135 tdata->auth_iv.len, tdata->digest.len,
5136 RTE_CRYPTO_AUTH_OP_GENERATE,
5137 RTE_CRYPTO_AUTH_ZUC_EIA3);
5141 /* alloc mbuf and set payload */
5142 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5145 rte_pktmbuf_tailroom(ut_params->ibuf));
5147 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5148 /* Append data which is padded to a multiple of */
5149 /* the algorithms block size */
5150 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5151 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5153 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5155 /* Create ZUC operation */
5156 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5157 tdata->auth_iv.data, tdata->auth_iv.len,
5158 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5159 tdata->validAuthLenInBits.len,
5164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5166 ut_params->obuf = ut_params->op->sym->m_src;
5167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5168 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5169 + plaintext_pad_len;
5172 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 "ZUC Generated auth tag not as expected");
5182 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5183 uint8_t op_mode, uint8_t verify)
5185 struct crypto_testsuite_params *ts_params = &testsuite_params;
5186 struct crypto_unittest_params *ut_params = &unittest_params;
5190 uint8_t *plaintext = NULL, *ciphertext = NULL;
5191 unsigned int plaintext_pad_len;
5192 unsigned int plaintext_len;
5193 unsigned int ciphertext_pad_len;
5194 unsigned int ciphertext_len;
5196 struct rte_cryptodev_info dev_info;
5197 struct rte_cryptodev_sym_capability_idx cap_idx;
5199 /* Check if device supports ZUC EIA3 */
5200 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5201 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5207 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5209 uint64_t feat_flags = dev_info.feature_flags;
5211 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5212 printf("Device doesn't support digest encrypted.\n");
5216 /* Create ZUC session */
5217 retval = create_wireless_algo_auth_cipher_session(
5218 ts_params->valid_devs[0],
5219 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5220 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5221 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5222 : RTE_CRYPTO_AUTH_OP_GENERATE),
5223 RTE_CRYPTO_AUTH_ZUC_EIA3,
5224 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5225 tdata->key.data, tdata->key.len,
5226 tdata->auth_iv.len, tdata->digest.len,
5227 tdata->cipher_iv.len);
5232 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5233 if (op_mode == OUT_OF_PLACE)
5234 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5236 /* clear mbuf payload */
5237 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5238 rte_pktmbuf_tailroom(ut_params->ibuf));
5239 if (op_mode == OUT_OF_PLACE)
5240 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5241 rte_pktmbuf_tailroom(ut_params->obuf));
5243 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5244 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5245 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5246 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5249 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5250 ciphertext_pad_len);
5251 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5252 if (op_mode == OUT_OF_PLACE)
5253 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5254 debug_hexdump(stdout, "ciphertext:", ciphertext,
5257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5260 if (op_mode == OUT_OF_PLACE)
5261 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5262 debug_hexdump(stdout, "plaintext:", plaintext,
5266 /* Create ZUC operation */
5267 retval = create_wireless_algo_auth_cipher_operation(
5268 tdata->digest.data, tdata->digest.len,
5269 tdata->cipher_iv.data, tdata->cipher_iv.len,
5270 tdata->auth_iv.data, tdata->auth_iv.len,
5271 (tdata->digest.offset_bytes == 0 ?
5272 (verify ? ciphertext_pad_len : plaintext_pad_len)
5273 : tdata->digest.offset_bytes),
5274 tdata->validCipherLenInBits.len,
5275 tdata->validCipherOffsetInBits.len,
5276 tdata->validAuthLenInBits.len,
5278 op_mode, 0, verify);
5283 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5286 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5288 ut_params->obuf = (op_mode == IN_PLACE ?
5289 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5293 if (ut_params->obuf)
5294 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5297 plaintext = ciphertext;
5299 debug_hexdump(stdout, "plaintext:", plaintext,
5300 (tdata->plaintext.len >> 3) - tdata->digest.len);
5301 debug_hexdump(stdout, "plaintext expected:",
5302 tdata->plaintext.data,
5303 (tdata->plaintext.len >> 3) - tdata->digest.len);
5305 if (ut_params->obuf)
5306 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5309 ciphertext = plaintext;
5311 debug_hexdump(stdout, "ciphertext:", ciphertext,
5313 debug_hexdump(stdout, "ciphertext expected:",
5314 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5316 ut_params->digest = rte_pktmbuf_mtod(
5317 ut_params->obuf, uint8_t *) +
5318 (tdata->digest.offset_bytes == 0 ?
5319 plaintext_pad_len : tdata->digest.offset_bytes);
5321 debug_hexdump(stdout, "digest:", ut_params->digest,
5323 debug_hexdump(stdout, "digest expected:",
5324 tdata->digest.data, tdata->digest.len);
5329 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5331 tdata->plaintext.data,
5332 tdata->plaintext.len >> 3,
5333 "ZUC Plaintext data not as expected");
5335 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5337 tdata->ciphertext.data,
5338 tdata->ciphertext.len >> 3,
5339 "ZUC Ciphertext data not as expected");
5341 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5344 DIGEST_BYTE_LENGTH_KASUMI_F9,
5345 "ZUC Generated auth tag not as expected");
5351 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5352 uint8_t op_mode, uint8_t verify)
5354 struct crypto_testsuite_params *ts_params = &testsuite_params;
5355 struct crypto_unittest_params *ut_params = &unittest_params;
5359 const uint8_t *plaintext = NULL;
5360 const uint8_t *ciphertext = NULL;
5361 const uint8_t *digest = NULL;
5362 unsigned int plaintext_pad_len;
5363 unsigned int plaintext_len;
5364 unsigned int ciphertext_pad_len;
5365 unsigned int ciphertext_len;
5366 uint8_t buffer[10000];
5367 uint8_t digest_buffer[10000];
5369 struct rte_cryptodev_info dev_info;
5370 struct rte_cryptodev_sym_capability_idx cap_idx;
5372 /* Check if device supports ZUC EIA3 */
5373 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5374 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5376 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5380 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5382 uint64_t feat_flags = dev_info.feature_flags;
5384 if (op_mode == IN_PLACE) {
5385 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5386 printf("Device doesn't support in-place scatter-gather "
5387 "in both input and output mbufs.\n");
5391 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5392 printf("Device doesn't support out-of-place scatter-gather "
5393 "in both input and output mbufs.\n");
5396 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5397 printf("Device doesn't support digest encrypted.\n");
5402 /* Create ZUC session */
5403 retval = create_wireless_algo_auth_cipher_session(
5404 ts_params->valid_devs[0],
5405 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5406 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5407 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5408 : RTE_CRYPTO_AUTH_OP_GENERATE),
5409 RTE_CRYPTO_AUTH_ZUC_EIA3,
5410 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5411 tdata->key.data, tdata->key.len,
5412 tdata->auth_iv.len, tdata->digest.len,
5413 tdata->cipher_iv.len);
5418 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5419 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5420 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5421 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5423 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5424 plaintext_pad_len, 15, 0);
5425 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5426 "Failed to allocate input buffer in mempool");
5428 if (op_mode == OUT_OF_PLACE) {
5429 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5430 plaintext_pad_len, 15, 0);
5431 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5432 "Failed to allocate output buffer in mempool");
5436 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5437 tdata->ciphertext.data);
5438 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5439 ciphertext_len, buffer);
5440 debug_hexdump(stdout, "ciphertext:", ciphertext,
5443 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5444 tdata->plaintext.data);
5445 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5446 plaintext_len, buffer);
5447 debug_hexdump(stdout, "plaintext:", plaintext,
5450 memset(buffer, 0, sizeof(buffer));
5452 /* Create ZUC operation */
5453 retval = create_wireless_algo_auth_cipher_operation(
5454 tdata->digest.data, tdata->digest.len,
5455 tdata->cipher_iv.data, tdata->cipher_iv.len,
5457 (tdata->digest.offset_bytes == 0 ?
5458 (verify ? ciphertext_pad_len : plaintext_pad_len)
5459 : tdata->digest.offset_bytes),
5460 tdata->validCipherLenInBits.len,
5461 tdata->validCipherOffsetInBits.len,
5462 tdata->validAuthLenInBits.len,
5464 op_mode, 1, verify);
5469 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5472 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5474 ut_params->obuf = (op_mode == IN_PLACE ?
5475 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5478 if (ut_params->obuf)
5479 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5480 plaintext_len, buffer);
5482 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5483 plaintext_len, buffer);
5485 debug_hexdump(stdout, "plaintext:", plaintext,
5486 (tdata->plaintext.len >> 3) - tdata->digest.len);
5487 debug_hexdump(stdout, "plaintext expected:",
5488 tdata->plaintext.data,
5489 (tdata->plaintext.len >> 3) - tdata->digest.len);
5491 if (ut_params->obuf)
5492 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5493 ciphertext_len, buffer);
5495 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5496 ciphertext_len, buffer);
5498 debug_hexdump(stdout, "ciphertext:", ciphertext,
5500 debug_hexdump(stdout, "ciphertext expected:",
5501 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5503 if (ut_params->obuf)
5504 digest = rte_pktmbuf_read(ut_params->obuf,
5505 (tdata->digest.offset_bytes == 0 ?
5506 plaintext_pad_len : tdata->digest.offset_bytes),
5507 tdata->digest.len, digest_buffer);
5509 digest = rte_pktmbuf_read(ut_params->ibuf,
5510 (tdata->digest.offset_bytes == 0 ?
5511 plaintext_pad_len : tdata->digest.offset_bytes),
5512 tdata->digest.len, digest_buffer);
5514 debug_hexdump(stdout, "digest:", digest,
5516 debug_hexdump(stdout, "digest expected:",
5517 tdata->digest.data, tdata->digest.len);
5522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5524 tdata->plaintext.data,
5525 tdata->plaintext.len >> 3,
5526 "ZUC Plaintext data not as expected");
5528 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5530 tdata->ciphertext.data,
5531 tdata->validDataLenInBits.len,
5532 "ZUC Ciphertext data not as expected");
5534 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5537 DIGEST_BYTE_LENGTH_KASUMI_F9,
5538 "ZUC Generated auth tag not as expected");
5544 test_kasumi_encryption_test_case_1(void)
5546 return test_kasumi_encryption(&kasumi_test_case_1);
5550 test_kasumi_encryption_test_case_1_sgl(void)
5552 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5556 test_kasumi_encryption_test_case_1_oop(void)
5558 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5562 test_kasumi_encryption_test_case_1_oop_sgl(void)
5564 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5568 test_kasumi_encryption_test_case_2(void)
5570 return test_kasumi_encryption(&kasumi_test_case_2);
5574 test_kasumi_encryption_test_case_3(void)
5576 return test_kasumi_encryption(&kasumi_test_case_3);
5580 test_kasumi_encryption_test_case_4(void)
5582 return test_kasumi_encryption(&kasumi_test_case_4);
5586 test_kasumi_encryption_test_case_5(void)
5588 return test_kasumi_encryption(&kasumi_test_case_5);
5592 test_kasumi_decryption_test_case_1(void)
5594 return test_kasumi_decryption(&kasumi_test_case_1);
5598 test_kasumi_decryption_test_case_1_oop(void)
5600 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5604 test_kasumi_decryption_test_case_2(void)
5606 return test_kasumi_decryption(&kasumi_test_case_2);
5610 test_kasumi_decryption_test_case_3(void)
5612 return test_kasumi_decryption(&kasumi_test_case_3);
5616 test_kasumi_decryption_test_case_4(void)
5618 return test_kasumi_decryption(&kasumi_test_case_4);
5622 test_kasumi_decryption_test_case_5(void)
5624 return test_kasumi_decryption(&kasumi_test_case_5);
5627 test_snow3g_encryption_test_case_1(void)
5629 return test_snow3g_encryption(&snow3g_test_case_1);
5633 test_snow3g_encryption_test_case_1_oop(void)
5635 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5639 test_snow3g_encryption_test_case_1_oop_sgl(void)
5641 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5646 test_snow3g_encryption_test_case_1_offset_oop(void)
5648 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5652 test_snow3g_encryption_test_case_2(void)
5654 return test_snow3g_encryption(&snow3g_test_case_2);
5658 test_snow3g_encryption_test_case_3(void)
5660 return test_snow3g_encryption(&snow3g_test_case_3);
5664 test_snow3g_encryption_test_case_4(void)
5666 return test_snow3g_encryption(&snow3g_test_case_4);
5670 test_snow3g_encryption_test_case_5(void)
5672 return test_snow3g_encryption(&snow3g_test_case_5);
5676 test_snow3g_decryption_test_case_1(void)
5678 return test_snow3g_decryption(&snow3g_test_case_1);
5682 test_snow3g_decryption_test_case_1_oop(void)
5684 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5688 test_snow3g_decryption_test_case_2(void)
5690 return test_snow3g_decryption(&snow3g_test_case_2);
5694 test_snow3g_decryption_test_case_3(void)
5696 return test_snow3g_decryption(&snow3g_test_case_3);
5700 test_snow3g_decryption_test_case_4(void)
5702 return test_snow3g_decryption(&snow3g_test_case_4);
5706 test_snow3g_decryption_test_case_5(void)
5708 return test_snow3g_decryption(&snow3g_test_case_5);
5712 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5713 * Pattern digest from snow3g_test_data must be allocated as
5714 * 4 last bytes in plaintext.
5717 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5718 struct snow3g_hash_test_data *output)
5720 if ((pattern != NULL) && (output != NULL)) {
5721 output->key.len = pattern->key.len;
5723 memcpy(output->key.data,
5724 pattern->key.data, pattern->key.len);
5726 output->auth_iv.len = pattern->auth_iv.len;
5728 memcpy(output->auth_iv.data,
5729 pattern->auth_iv.data, pattern->auth_iv.len);
5731 output->plaintext.len = pattern->plaintext.len;
5733 memcpy(output->plaintext.data,
5734 pattern->plaintext.data, pattern->plaintext.len >> 3);
5736 output->digest.len = pattern->digest.len;
5738 memcpy(output->digest.data,
5739 &pattern->plaintext.data[pattern->digest.offset_bytes],
5740 pattern->digest.len);
5742 output->validAuthLenInBits.len =
5743 pattern->validAuthLenInBits.len;
5748 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5751 test_snow3g_decryption_with_digest_test_case_1(void)
5753 struct snow3g_hash_test_data snow3g_hash_data;
5756 * Function prepare data for hash veryfication test case.
5757 * Digest is allocated in 4 last bytes in plaintext, pattern.
5759 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5761 return test_snow3g_decryption(&snow3g_test_case_7) &
5762 test_snow3g_authentication_verify(&snow3g_hash_data);
5766 test_snow3g_cipher_auth_test_case_1(void)
5768 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5772 test_snow3g_auth_cipher_test_case_1(void)
5774 return test_snow3g_auth_cipher(
5775 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5779 test_snow3g_auth_cipher_test_case_2(void)
5781 return test_snow3g_auth_cipher(
5782 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5786 test_snow3g_auth_cipher_test_case_2_oop(void)
5788 return test_snow3g_auth_cipher(
5789 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5793 test_snow3g_auth_cipher_part_digest_enc(void)
5795 return test_snow3g_auth_cipher(
5796 &snow3g_auth_cipher_partial_digest_encryption,
5801 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5803 return test_snow3g_auth_cipher(
5804 &snow3g_auth_cipher_partial_digest_encryption,
5809 test_snow3g_auth_cipher_test_case_3_sgl(void)
5811 return test_snow3g_auth_cipher_sgl(
5812 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5816 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5818 return test_snow3g_auth_cipher_sgl(
5819 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5823 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5825 return test_snow3g_auth_cipher_sgl(
5826 &snow3g_auth_cipher_partial_digest_encryption,
5831 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5833 return test_snow3g_auth_cipher_sgl(
5834 &snow3g_auth_cipher_partial_digest_encryption,
5839 test_snow3g_auth_cipher_verify_test_case_1(void)
5841 return test_snow3g_auth_cipher(
5842 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5846 test_snow3g_auth_cipher_verify_test_case_2(void)
5848 return test_snow3g_auth_cipher(
5849 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5853 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5855 return test_snow3g_auth_cipher(
5856 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5860 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5862 return test_snow3g_auth_cipher(
5863 &snow3g_auth_cipher_partial_digest_encryption,
5868 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5870 return test_snow3g_auth_cipher(
5871 &snow3g_auth_cipher_partial_digest_encryption,
5876 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5878 return test_snow3g_auth_cipher_sgl(
5879 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5883 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5885 return test_snow3g_auth_cipher_sgl(
5886 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5890 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5892 return test_snow3g_auth_cipher_sgl(
5893 &snow3g_auth_cipher_partial_digest_encryption,
5898 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5900 return test_snow3g_auth_cipher_sgl(
5901 &snow3g_auth_cipher_partial_digest_encryption,
5906 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5908 return test_snow3g_auth_cipher(
5909 &snow3g_test_case_7, IN_PLACE, 0);
5913 test_kasumi_auth_cipher_test_case_1(void)
5915 return test_kasumi_auth_cipher(
5916 &kasumi_test_case_3, IN_PLACE, 0);
5920 test_kasumi_auth_cipher_test_case_2(void)
5922 return test_kasumi_auth_cipher(
5923 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5927 test_kasumi_auth_cipher_test_case_2_oop(void)
5929 return test_kasumi_auth_cipher(
5930 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5934 test_kasumi_auth_cipher_test_case_2_sgl(void)
5936 return test_kasumi_auth_cipher_sgl(
5937 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5941 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5943 return test_kasumi_auth_cipher_sgl(
5944 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5948 test_kasumi_auth_cipher_verify_test_case_1(void)
5950 return test_kasumi_auth_cipher(
5951 &kasumi_test_case_3, IN_PLACE, 1);
5955 test_kasumi_auth_cipher_verify_test_case_2(void)
5957 return test_kasumi_auth_cipher(
5958 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5962 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5964 return test_kasumi_auth_cipher(
5965 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5969 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5971 return test_kasumi_auth_cipher_sgl(
5972 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5976 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5978 return test_kasumi_auth_cipher_sgl(
5979 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5983 test_kasumi_cipher_auth_test_case_1(void)
5985 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5989 test_zuc_encryption_test_case_1(void)
5991 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5995 test_zuc_encryption_test_case_2(void)
5997 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6001 test_zuc_encryption_test_case_3(void)
6003 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6007 test_zuc_encryption_test_case_4(void)
6009 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6013 test_zuc_encryption_test_case_5(void)
6015 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6019 test_zuc_encryption_test_case_6_sgl(void)
6021 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6025 test_zuc_hash_generate_test_case_1(void)
6027 return test_zuc_authentication(&zuc_test_case_auth_1b);
6031 test_zuc_hash_generate_test_case_2(void)
6033 return test_zuc_authentication(&zuc_test_case_auth_90b);
6037 test_zuc_hash_generate_test_case_3(void)
6039 return test_zuc_authentication(&zuc_test_case_auth_577b);
6043 test_zuc_hash_generate_test_case_4(void)
6045 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6049 test_zuc_hash_generate_test_case_5(void)
6051 return test_zuc_authentication(&zuc_test_auth_5670b);
6055 test_zuc_hash_generate_test_case_6(void)
6057 return test_zuc_authentication(&zuc_test_case_auth_128b);
6061 test_zuc_hash_generate_test_case_7(void)
6063 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6067 test_zuc_hash_generate_test_case_8(void)
6069 return test_zuc_authentication(&zuc_test_case_auth_584b);
6073 test_zuc_cipher_auth_test_case_1(void)
6075 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6079 test_zuc_cipher_auth_test_case_2(void)
6081 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6085 test_zuc_auth_cipher_test_case_1(void)
6087 return test_zuc_auth_cipher(
6088 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6092 test_zuc_auth_cipher_test_case_1_oop(void)
6094 return test_zuc_auth_cipher(
6095 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6099 test_zuc_auth_cipher_test_case_1_sgl(void)
6101 return test_zuc_auth_cipher_sgl(
6102 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6106 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6108 return test_zuc_auth_cipher_sgl(
6109 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6113 test_zuc_auth_cipher_verify_test_case_1(void)
6115 return test_zuc_auth_cipher(
6116 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6120 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6122 return test_zuc_auth_cipher(
6123 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6127 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6129 return test_zuc_auth_cipher_sgl(
6130 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6134 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6136 return test_zuc_auth_cipher_sgl(
6137 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6141 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6143 uint8_t dev_id = testsuite_params.valid_devs[0];
6145 struct rte_cryptodev_sym_capability_idx cap_idx;
6147 /* Check if device supports particular cipher algorithm */
6148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6149 cap_idx.algo.cipher = tdata->cipher_algo;
6150 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6153 /* Check if device supports particular hash algorithm */
6154 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6155 cap_idx.algo.auth = tdata->auth_algo;
6156 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6163 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6164 uint8_t op_mode, uint8_t verify)
6166 struct crypto_testsuite_params *ts_params = &testsuite_params;
6167 struct crypto_unittest_params *ut_params = &unittest_params;
6171 uint8_t *plaintext = NULL, *ciphertext = NULL;
6172 unsigned int plaintext_pad_len;
6173 unsigned int plaintext_len;
6174 unsigned int ciphertext_pad_len;
6175 unsigned int ciphertext_len;
6177 struct rte_cryptodev_info dev_info;
6178 struct rte_crypto_op *op;
6180 /* Check if device supports particular algorithms separately */
6181 if (test_mixed_check_if_unsupported(tdata))
6184 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6186 uint64_t feat_flags = dev_info.feature_flags;
6188 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6189 printf("Device doesn't support digest encrypted.\n");
6193 /* Create the session */
6195 retval = create_wireless_algo_cipher_auth_session(
6196 ts_params->valid_devs[0],
6197 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6198 RTE_CRYPTO_AUTH_OP_VERIFY,
6201 tdata->auth_key.data, tdata->auth_key.len,
6202 tdata->auth_iv.len, tdata->digest_enc.len,
6203 tdata->cipher_iv.len);
6205 retval = create_wireless_algo_auth_cipher_session(
6206 ts_params->valid_devs[0],
6207 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6208 RTE_CRYPTO_AUTH_OP_GENERATE,
6211 tdata->auth_key.data, tdata->auth_key.len,
6212 tdata->auth_iv.len, tdata->digest_enc.len,
6213 tdata->cipher_iv.len);
6217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6218 if (op_mode == OUT_OF_PLACE)
6219 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6221 /* clear mbuf payload */
6222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6223 rte_pktmbuf_tailroom(ut_params->ibuf));
6224 if (op_mode == OUT_OF_PLACE)
6225 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6226 rte_pktmbuf_tailroom(ut_params->obuf));
6228 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6229 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6230 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6231 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6234 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6235 ciphertext_pad_len);
6236 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6237 if (op_mode == OUT_OF_PLACE)
6238 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6239 debug_hexdump(stdout, "ciphertext:", ciphertext,
6242 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6244 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6245 if (op_mode == OUT_OF_PLACE)
6246 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6247 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6250 /* Create the operation */
6251 retval = create_wireless_algo_auth_cipher_operation(
6252 tdata->digest_enc.data, tdata->digest_enc.len,
6253 tdata->cipher_iv.data, tdata->cipher_iv.len,
6254 tdata->auth_iv.data, tdata->auth_iv.len,
6255 (tdata->digest_enc.offset == 0 ?
6257 : tdata->digest_enc.offset),
6258 tdata->validCipherLen.len_bits,
6259 tdata->cipher.offset_bits,
6260 tdata->validAuthLen.len_bits,
6261 tdata->auth.offset_bits,
6262 op_mode, 0, verify);
6267 op = process_crypto_request(ts_params->valid_devs[0],
6270 /* Check if the op failed because the device doesn't */
6271 /* support this particular combination of algorithms */
6272 if (op == NULL && ut_params->op->status ==
6273 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6274 printf("Device doesn't support this mixed combination. "
6280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6282 ut_params->obuf = (op_mode == IN_PLACE ?
6283 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6286 if (ut_params->obuf)
6287 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6290 plaintext = ciphertext +
6291 (tdata->cipher.offset_bits >> 3);
6293 debug_hexdump(stdout, "plaintext:", plaintext,
6294 tdata->plaintext.len_bits >> 3);
6295 debug_hexdump(stdout, "plaintext expected:",
6296 tdata->plaintext.data,
6297 tdata->plaintext.len_bits >> 3);
6299 if (ut_params->obuf)
6300 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6303 ciphertext = plaintext;
6305 debug_hexdump(stdout, "ciphertext:", ciphertext,
6307 debug_hexdump(stdout, "ciphertext expected:",
6308 tdata->ciphertext.data,
6309 tdata->ciphertext.len_bits >> 3);
6311 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6312 + (tdata->digest_enc.offset == 0 ?
6313 plaintext_pad_len : tdata->digest_enc.offset);
6315 debug_hexdump(stdout, "digest:", ut_params->digest,
6316 tdata->digest_enc.len);
6317 debug_hexdump(stdout, "digest expected:",
6318 tdata->digest_enc.data,
6319 tdata->digest_enc.len);
6324 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6326 tdata->plaintext.data,
6327 tdata->plaintext.len_bits >> 3,
6328 "Plaintext data not as expected");
6330 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6332 tdata->ciphertext.data,
6333 tdata->validDataLen.len_bits,
6334 "Ciphertext data not as expected");
6336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6338 tdata->digest_enc.data,
6339 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6340 "Generated auth tag not as expected");
6343 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6344 "crypto op processing failed");
6350 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6351 uint8_t op_mode, uint8_t verify)
6353 struct crypto_testsuite_params *ts_params = &testsuite_params;
6354 struct crypto_unittest_params *ut_params = &unittest_params;
6358 const uint8_t *plaintext = NULL;
6359 const uint8_t *ciphertext = NULL;
6360 const uint8_t *digest = NULL;
6361 unsigned int plaintext_pad_len;
6362 unsigned int plaintext_len;
6363 unsigned int ciphertext_pad_len;
6364 unsigned int ciphertext_len;
6365 uint8_t buffer[10000];
6366 uint8_t digest_buffer[10000];
6368 struct rte_cryptodev_info dev_info;
6369 struct rte_crypto_op *op;
6371 /* Check if device supports particular algorithms */
6372 if (test_mixed_check_if_unsupported(tdata))
6375 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6377 uint64_t feat_flags = dev_info.feature_flags;
6379 if (op_mode == IN_PLACE) {
6380 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6381 printf("Device doesn't support in-place scatter-gather "
6382 "in both input and output mbufs.\n");
6386 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6387 printf("Device doesn't support out-of-place scatter-gather "
6388 "in both input and output mbufs.\n");
6391 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6392 printf("Device doesn't support digest encrypted.\n");
6397 /* Create the session */
6399 retval = create_wireless_algo_cipher_auth_session(
6400 ts_params->valid_devs[0],
6401 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6402 RTE_CRYPTO_AUTH_OP_VERIFY,
6405 tdata->auth_key.data, tdata->auth_key.len,
6406 tdata->auth_iv.len, tdata->digest_enc.len,
6407 tdata->cipher_iv.len);
6409 retval = create_wireless_algo_auth_cipher_session(
6410 ts_params->valid_devs[0],
6411 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6412 RTE_CRYPTO_AUTH_OP_GENERATE,
6415 tdata->auth_key.data, tdata->auth_key.len,
6416 tdata->auth_iv.len, tdata->digest_enc.len,
6417 tdata->cipher_iv.len);
6421 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6422 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6423 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6424 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6426 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6427 ciphertext_pad_len, 15, 0);
6428 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6429 "Failed to allocate input buffer in mempool");
6431 if (op_mode == OUT_OF_PLACE) {
6432 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6433 plaintext_pad_len, 15, 0);
6434 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6435 "Failed to allocate output buffer in mempool");
6439 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6440 tdata->ciphertext.data);
6441 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6442 ciphertext_len, buffer);
6443 debug_hexdump(stdout, "ciphertext:", ciphertext,
6446 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6447 tdata->plaintext.data);
6448 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6449 plaintext_len, buffer);
6450 debug_hexdump(stdout, "plaintext:", plaintext,
6453 memset(buffer, 0, sizeof(buffer));
6455 /* Create the operation */
6456 retval = create_wireless_algo_auth_cipher_operation(
6457 tdata->digest_enc.data, tdata->digest_enc.len,
6458 tdata->cipher_iv.data, tdata->cipher_iv.len,
6459 tdata->auth_iv.data, tdata->auth_iv.len,
6460 (tdata->digest_enc.offset == 0 ?
6462 : tdata->digest_enc.offset),
6463 tdata->validCipherLen.len_bits,
6464 tdata->cipher.offset_bits,
6465 tdata->validAuthLen.len_bits,
6466 tdata->auth.offset_bits,
6467 op_mode, 1, verify);
6472 op = process_crypto_request(ts_params->valid_devs[0],
6475 /* Check if the op failed because the device doesn't */
6476 /* support this particular combination of algorithms */
6477 if (op == NULL && ut_params->op->status ==
6478 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6479 printf("Device doesn't support this mixed combination. "
6486 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6488 ut_params->obuf = (op_mode == IN_PLACE ?
6489 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6492 if (ut_params->obuf)
6493 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6494 plaintext_len, buffer);
6496 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6497 plaintext_len, buffer);
6499 debug_hexdump(stdout, "plaintext:", plaintext,
6500 (tdata->plaintext.len_bits >> 3) -
6501 tdata->digest_enc.len);
6502 debug_hexdump(stdout, "plaintext expected:",
6503 tdata->plaintext.data,
6504 (tdata->plaintext.len_bits >> 3) -
6505 tdata->digest_enc.len);
6507 if (ut_params->obuf)
6508 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6509 ciphertext_len, buffer);
6511 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6512 ciphertext_len, buffer);
6514 debug_hexdump(stdout, "ciphertext:", ciphertext,
6516 debug_hexdump(stdout, "ciphertext expected:",
6517 tdata->ciphertext.data,
6518 tdata->ciphertext.len_bits >> 3);
6520 if (ut_params->obuf)
6521 digest = rte_pktmbuf_read(ut_params->obuf,
6522 (tdata->digest_enc.offset == 0 ?
6524 tdata->digest_enc.offset),
6525 tdata->digest_enc.len, digest_buffer);
6527 digest = rte_pktmbuf_read(ut_params->ibuf,
6528 (tdata->digest_enc.offset == 0 ?
6530 tdata->digest_enc.offset),
6531 tdata->digest_enc.len, digest_buffer);
6533 debug_hexdump(stdout, "digest:", digest,
6534 tdata->digest_enc.len);
6535 debug_hexdump(stdout, "digest expected:",
6536 tdata->digest_enc.data, tdata->digest_enc.len);
6541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6543 tdata->plaintext.data,
6544 tdata->plaintext.len_bits >> 3,
6545 "Plaintext data not as expected");
6547 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6549 tdata->ciphertext.data,
6550 tdata->validDataLen.len_bits,
6551 "Ciphertext data not as expected");
6552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6554 tdata->digest_enc.data,
6555 tdata->digest_enc.len,
6556 "Generated auth tag not as expected");
6559 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6560 "crypto op processing failed");
6565 /** AUTH AES CMAC + CIPHER AES CTR */
6568 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6570 return test_mixed_auth_cipher(
6571 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6575 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6577 return test_mixed_auth_cipher(
6578 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6582 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6584 return test_mixed_auth_cipher_sgl(
6585 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6589 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6591 return test_mixed_auth_cipher_sgl(
6592 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6596 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6598 return test_mixed_auth_cipher(
6599 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6603 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6605 return test_mixed_auth_cipher(
6606 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6610 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6612 return test_mixed_auth_cipher_sgl(
6613 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6617 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6619 return test_mixed_auth_cipher_sgl(
6620 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6623 /** MIXED AUTH + CIPHER */
6626 test_auth_zuc_cipher_snow_test_case_1(void)
6628 return test_mixed_auth_cipher(
6629 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6633 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6635 return test_mixed_auth_cipher(
6636 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6640 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6642 return test_mixed_auth_cipher(
6643 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6647 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6649 return test_mixed_auth_cipher(
6650 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6654 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6656 return test_mixed_auth_cipher(
6657 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6661 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6663 return test_mixed_auth_cipher(
6664 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6668 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6670 return test_mixed_auth_cipher(
6671 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6675 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6677 return test_mixed_auth_cipher(
6678 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6682 test_auth_snow_cipher_zuc_test_case_1(void)
6684 return test_mixed_auth_cipher(
6685 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6689 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6691 return test_mixed_auth_cipher(
6692 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6696 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6698 return test_mixed_auth_cipher(
6699 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6703 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6705 return test_mixed_auth_cipher(
6706 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6710 test_auth_null_cipher_snow_test_case_1(void)
6712 return test_mixed_auth_cipher(
6713 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6717 test_verify_auth_null_cipher_snow_test_case_1(void)
6719 return test_mixed_auth_cipher(
6720 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6724 test_auth_null_cipher_zuc_test_case_1(void)
6726 return test_mixed_auth_cipher(
6727 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6731 test_verify_auth_null_cipher_zuc_test_case_1(void)
6733 return test_mixed_auth_cipher(
6734 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6738 test_auth_snow_cipher_null_test_case_1(void)
6740 return test_mixed_auth_cipher(
6741 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6745 test_verify_auth_snow_cipher_null_test_case_1(void)
6747 return test_mixed_auth_cipher(
6748 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6752 test_auth_zuc_cipher_null_test_case_1(void)
6754 return test_mixed_auth_cipher(
6755 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6759 test_verify_auth_zuc_cipher_null_test_case_1(void)
6761 return test_mixed_auth_cipher(
6762 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6766 test_auth_null_cipher_aes_ctr_test_case_1(void)
6768 return test_mixed_auth_cipher(
6769 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6773 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6775 return test_mixed_auth_cipher(
6776 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6780 test_auth_aes_cmac_cipher_null_test_case_1(void)
6782 return test_mixed_auth_cipher(
6783 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6787 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6789 return test_mixed_auth_cipher(
6790 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6793 /* ***** AEAD algorithm Tests ***** */
6796 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6797 enum rte_crypto_aead_operation op,
6798 const uint8_t *key, const uint8_t key_len,
6799 const uint16_t aad_len, const uint8_t auth_len,
6802 uint8_t aead_key[key_len];
6804 struct crypto_testsuite_params *ts_params = &testsuite_params;
6805 struct crypto_unittest_params *ut_params = &unittest_params;
6807 memcpy(aead_key, key, key_len);
6809 /* Setup AEAD Parameters */
6810 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6811 ut_params->aead_xform.next = NULL;
6812 ut_params->aead_xform.aead.algo = algo;
6813 ut_params->aead_xform.aead.op = op;
6814 ut_params->aead_xform.aead.key.data = aead_key;
6815 ut_params->aead_xform.aead.key.length = key_len;
6816 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6817 ut_params->aead_xform.aead.iv.length = iv_len;
6818 ut_params->aead_xform.aead.digest_length = auth_len;
6819 ut_params->aead_xform.aead.aad_length = aad_len;
6821 debug_hexdump(stdout, "key:", key, key_len);
6823 /* Create Crypto session*/
6824 ut_params->sess = rte_cryptodev_sym_session_create(
6825 ts_params->session_mpool);
6827 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6828 &ut_params->aead_xform,
6829 ts_params->session_priv_mpool);
6831 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6837 create_aead_xform(struct rte_crypto_op *op,
6838 enum rte_crypto_aead_algorithm algo,
6839 enum rte_crypto_aead_operation aead_op,
6840 uint8_t *key, const uint8_t key_len,
6841 const uint8_t aad_len, const uint8_t auth_len,
6844 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6845 "failed to allocate space for crypto transform");
6847 struct rte_crypto_sym_op *sym_op = op->sym;
6849 /* Setup AEAD Parameters */
6850 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6851 sym_op->xform->next = NULL;
6852 sym_op->xform->aead.algo = algo;
6853 sym_op->xform->aead.op = aead_op;
6854 sym_op->xform->aead.key.data = key;
6855 sym_op->xform->aead.key.length = key_len;
6856 sym_op->xform->aead.iv.offset = IV_OFFSET;
6857 sym_op->xform->aead.iv.length = iv_len;
6858 sym_op->xform->aead.digest_length = auth_len;
6859 sym_op->xform->aead.aad_length = aad_len;
6861 debug_hexdump(stdout, "key:", key, key_len);
6867 create_aead_operation(enum rte_crypto_aead_operation op,
6868 const struct aead_test_data *tdata)
6870 struct crypto_testsuite_params *ts_params = &testsuite_params;
6871 struct crypto_unittest_params *ut_params = &unittest_params;
6873 uint8_t *plaintext, *ciphertext;
6874 unsigned int aad_pad_len, plaintext_pad_len;
6876 /* Generate Crypto op data structure */
6877 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6878 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6879 TEST_ASSERT_NOT_NULL(ut_params->op,
6880 "Failed to allocate symmetric crypto operation struct");
6882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6884 /* Append aad data */
6885 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6886 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6887 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6889 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6890 "no room to append aad");
6892 sym_op->aead.aad.phys_addr =
6893 rte_pktmbuf_iova(ut_params->ibuf);
6894 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6895 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6896 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6899 /* Append IV at the end of the crypto operation*/
6900 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6901 uint8_t *, IV_OFFSET);
6903 /* Copy IV 1 byte after the IV pointer, according to the API */
6904 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6905 debug_hexdump(stdout, "iv:", iv_ptr,
6908 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6909 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6911 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6912 "no room to append aad");
6914 sym_op->aead.aad.phys_addr =
6915 rte_pktmbuf_iova(ut_params->ibuf);
6916 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6917 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6920 /* Append IV at the end of the crypto operation*/
6921 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6922 uint8_t *, IV_OFFSET);
6924 if (tdata->iv.len == 0) {
6925 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6926 debug_hexdump(stdout, "iv:", iv_ptr,
6929 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6930 debug_hexdump(stdout, "iv:", iv_ptr,
6935 /* Append plaintext/ciphertext */
6936 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6937 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6940 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6942 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6943 debug_hexdump(stdout, "plaintext:", plaintext,
6944 tdata->plaintext.len);
6946 if (ut_params->obuf) {
6947 ciphertext = (uint8_t *)rte_pktmbuf_append(
6949 plaintext_pad_len + aad_pad_len);
6950 TEST_ASSERT_NOT_NULL(ciphertext,
6951 "no room to append ciphertext");
6953 memset(ciphertext + aad_pad_len, 0,
6954 tdata->ciphertext.len);
6957 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6958 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6960 TEST_ASSERT_NOT_NULL(ciphertext,
6961 "no room to append ciphertext");
6963 memcpy(ciphertext, tdata->ciphertext.data,
6964 tdata->ciphertext.len);
6965 debug_hexdump(stdout, "ciphertext:", ciphertext,
6966 tdata->ciphertext.len);
6968 if (ut_params->obuf) {
6969 plaintext = (uint8_t *)rte_pktmbuf_append(
6971 plaintext_pad_len + aad_pad_len);
6972 TEST_ASSERT_NOT_NULL(plaintext,
6973 "no room to append plaintext");
6975 memset(plaintext + aad_pad_len, 0,
6976 tdata->plaintext.len);
6980 /* Append digest data */
6981 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6982 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6983 ut_params->obuf ? ut_params->obuf :
6985 tdata->auth_tag.len);
6986 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6987 "no room to append digest");
6988 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6989 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6990 ut_params->obuf ? ut_params->obuf :
6995 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6996 ut_params->ibuf, tdata->auth_tag.len);
6997 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6998 "no room to append digest");
6999 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7001 plaintext_pad_len + aad_pad_len);
7003 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7004 tdata->auth_tag.len);
7005 debug_hexdump(stdout, "digest:",
7006 sym_op->aead.digest.data,
7007 tdata->auth_tag.len);
7010 sym_op->aead.data.length = tdata->plaintext.len;
7011 sym_op->aead.data.offset = aad_pad_len;
7017 test_authenticated_encryption(const struct aead_test_data *tdata)
7019 struct crypto_testsuite_params *ts_params = &testsuite_params;
7020 struct crypto_unittest_params *ut_params = &unittest_params;
7023 uint8_t *ciphertext, *auth_tag;
7024 uint16_t plaintext_pad_len;
7027 /* Verify the capabilities */
7028 struct rte_cryptodev_sym_capability_idx cap_idx;
7029 const struct rte_cryptodev_symmetric_capability *capability;
7030 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7031 cap_idx.algo.aead = tdata->algo;
7032 capability = rte_cryptodev_sym_capability_get(
7033 ts_params->valid_devs[0], &cap_idx);
7034 if (capability == NULL)
7036 if (rte_cryptodev_sym_capability_check_aead(
7037 capability, tdata->key.len, tdata->auth_tag.len,
7038 tdata->aad.len, tdata->iv.len))
7041 /* Create AEAD session */
7042 retval = create_aead_session(ts_params->valid_devs[0],
7044 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7045 tdata->key.data, tdata->key.len,
7046 tdata->aad.len, tdata->auth_tag.len,
7051 if (tdata->aad.len > MBUF_SIZE) {
7052 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7053 /* Populate full size of add data */
7054 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7055 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7057 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7059 /* clear mbuf payload */
7060 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7061 rte_pktmbuf_tailroom(ut_params->ibuf));
7063 /* Create AEAD operation */
7064 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7068 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7070 ut_params->op->sym->m_src = ut_params->ibuf;
7072 /* Process crypto operation */
7073 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7074 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7076 TEST_ASSERT_NOT_NULL(
7077 process_crypto_request(ts_params->valid_devs[0],
7078 ut_params->op), "failed to process sym crypto op");
7080 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7081 "crypto op processing failed");
7083 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7085 if (ut_params->op->sym->m_dst) {
7086 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7088 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7089 uint8_t *, plaintext_pad_len);
7091 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7093 ut_params->op->sym->cipher.data.offset);
7094 auth_tag = ciphertext + plaintext_pad_len;
7097 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7098 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7101 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7103 tdata->ciphertext.data,
7104 tdata->ciphertext.len,
7105 "Ciphertext data not as expected");
7107 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7109 tdata->auth_tag.data,
7110 tdata->auth_tag.len,
7111 "Generated auth tag not as expected");
7117 #ifdef RTE_LIBRTE_SECURITY
7118 /* Basic algorithm run function for async inplace mode.
7119 * Creates a session from input parameters and runs one operation
7120 * on input_vec. Checks the output of the crypto operation against
7124 test_pdcp_proto(int i, int oop,
7125 enum rte_crypto_cipher_operation opc,
7126 enum rte_crypto_auth_operation opa,
7128 unsigned int input_vec_len,
7129 uint8_t *output_vec,
7130 unsigned int output_vec_len)
7132 struct crypto_testsuite_params *ts_params = &testsuite_params;
7133 struct crypto_unittest_params *ut_params = &unittest_params;
7135 int ret = TEST_SUCCESS;
7136 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7137 rte_cryptodev_get_sec_ctx(
7138 ts_params->valid_devs[0]);
7140 /* Verify the capabilities */
7141 struct rte_security_capability_idx sec_cap_idx;
7143 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7144 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7145 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7146 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7149 /* Generate test mbuf data */
7150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7152 /* clear mbuf payload */
7153 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7154 rte_pktmbuf_tailroom(ut_params->ibuf));
7156 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7158 memcpy(plaintext, input_vec, input_vec_len);
7160 /* Out of place support */
7163 * For out-op-place we need to alloc another mbuf
7165 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7166 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7169 /* Set crypto type as IPSEC */
7170 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7172 /* Setup Cipher Parameters */
7173 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7174 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7175 ut_params->cipher_xform.cipher.op = opc;
7176 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7177 ut_params->cipher_xform.cipher.key.length =
7178 pdcp_test_params[i].cipher_key_len;
7179 ut_params->cipher_xform.cipher.iv.length = 0;
7181 /* Setup HMAC Parameters if ICV header is required */
7182 if (pdcp_test_params[i].auth_alg != 0) {
7183 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7184 ut_params->auth_xform.next = NULL;
7185 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7186 ut_params->auth_xform.auth.op = opa;
7187 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7188 ut_params->auth_xform.auth.key.length =
7189 pdcp_test_params[i].auth_key_len;
7191 ut_params->cipher_xform.next = &ut_params->auth_xform;
7193 ut_params->cipher_xform.next = NULL;
7196 struct rte_security_session_conf sess_conf = {
7197 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7198 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7200 .bearer = pdcp_test_bearer[i],
7201 .domain = pdcp_test_params[i].domain,
7202 .pkt_dir = pdcp_test_packet_direction[i],
7203 .sn_size = pdcp_test_data_sn_size[i],
7204 .hfn = pdcp_test_hfn[i],
7205 .hfn_threshold = pdcp_test_hfn_threshold[i],
7207 .crypto_xform = &ut_params->cipher_xform
7210 /* Create security session */
7211 ut_params->sec_session = rte_security_session_create(ctx,
7212 &sess_conf, ts_params->session_priv_mpool);
7214 if (!ut_params->sec_session) {
7215 printf("TestCase %s()-%d line %d failed %s: ",
7216 __func__, i, __LINE__, "Failed to allocate session");
7221 /* Generate crypto op data structure */
7222 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7223 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7224 if (!ut_params->op) {
7225 printf("TestCase %s()-%d line %d failed %s: ",
7226 __func__, i, __LINE__,
7227 "Failed to allocate symmetric crypto operation struct");
7232 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7234 /* set crypto operation source mbuf */
7235 ut_params->op->sym->m_src = ut_params->ibuf;
7237 ut_params->op->sym->m_dst = ut_params->obuf;
7239 /* Process crypto operation */
7240 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7242 printf("TestCase %s()-%d line %d failed %s: ",
7243 __func__, i, __LINE__,
7244 "failed to process sym crypto op");
7249 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7250 printf("TestCase %s()-%d line %d failed %s: ",
7251 __func__, i, __LINE__, "crypto op processing failed");
7257 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7260 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7264 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7265 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7266 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7267 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7273 rte_crypto_op_free(ut_params->op);
7274 ut_params->op = NULL;
7276 if (ut_params->sec_session)
7277 rte_security_session_destroy(ctx, ut_params->sec_session);
7278 ut_params->sec_session = NULL;
7280 rte_pktmbuf_free(ut_params->ibuf);
7281 ut_params->ibuf = NULL;
7283 rte_pktmbuf_free(ut_params->obuf);
7284 ut_params->obuf = NULL;
7291 test_pdcp_proto_SGL(int i, int oop,
7292 enum rte_crypto_cipher_operation opc,
7293 enum rte_crypto_auth_operation opa,
7295 unsigned int input_vec_len,
7296 uint8_t *output_vec,
7297 unsigned int output_vec_len,
7299 uint32_t fragsz_oop)
7301 struct crypto_testsuite_params *ts_params = &testsuite_params;
7302 struct crypto_unittest_params *ut_params = &unittest_params;
7304 struct rte_mbuf *buf, *buf_oop = NULL;
7305 int ret = TEST_SUCCESS;
7309 unsigned int trn_data = 0;
7310 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7311 rte_cryptodev_get_sec_ctx(
7312 ts_params->valid_devs[0]);
7314 /* Verify the capabilities */
7315 struct rte_security_capability_idx sec_cap_idx;
7317 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7318 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7319 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7320 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7323 if (fragsz > input_vec_len)
7324 fragsz = input_vec_len;
7326 uint16_t plaintext_len = fragsz;
7327 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7329 if (fragsz_oop > output_vec_len)
7330 frag_size_oop = output_vec_len;
7333 if (input_vec_len % fragsz != 0) {
7334 if (input_vec_len / fragsz + 1 > 16)
7336 } else if (input_vec_len / fragsz > 16)
7339 /* Out of place support */
7342 * For out-op-place we need to alloc another mbuf
7344 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7345 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7346 buf_oop = ut_params->obuf;
7349 /* Generate test mbuf data */
7350 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7352 /* clear mbuf payload */
7353 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7354 rte_pktmbuf_tailroom(ut_params->ibuf));
7356 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7358 memcpy(plaintext, input_vec, plaintext_len);
7359 trn_data += plaintext_len;
7361 buf = ut_params->ibuf;
7364 * Loop until no more fragments
7367 while (trn_data < input_vec_len) {
7369 to_trn = (input_vec_len - trn_data < fragsz) ?
7370 (input_vec_len - trn_data) : fragsz;
7372 to_trn_tbl[ecx++] = to_trn;
7374 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7377 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7378 rte_pktmbuf_tailroom(buf));
7381 if (oop && !fragsz_oop) {
7383 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7384 buf_oop = buf_oop->next;
7385 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7386 0, rte_pktmbuf_tailroom(buf_oop));
7387 rte_pktmbuf_append(buf_oop, to_trn);
7390 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7393 memcpy(plaintext, input_vec + trn_data, to_trn);
7397 ut_params->ibuf->nb_segs = segs;
7400 if (fragsz_oop && oop) {
7404 trn_data = frag_size_oop;
7405 while (trn_data < output_vec_len) {
7408 (output_vec_len - trn_data <
7410 (output_vec_len - trn_data) :
7413 to_trn_tbl[ecx++] = to_trn;
7416 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7417 buf_oop = buf_oop->next;
7418 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7419 0, rte_pktmbuf_tailroom(buf_oop));
7420 rte_pktmbuf_append(buf_oop, to_trn);
7424 ut_params->obuf->nb_segs = segs;
7427 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7429 /* Setup Cipher Parameters */
7430 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7431 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7432 ut_params->cipher_xform.cipher.op = opc;
7433 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7434 ut_params->cipher_xform.cipher.key.length =
7435 pdcp_test_params[i].cipher_key_len;
7436 ut_params->cipher_xform.cipher.iv.length = 0;
7438 /* Setup HMAC Parameters if ICV header is required */
7439 if (pdcp_test_params[i].auth_alg != 0) {
7440 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7441 ut_params->auth_xform.next = NULL;
7442 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7443 ut_params->auth_xform.auth.op = opa;
7444 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7445 ut_params->auth_xform.auth.key.length =
7446 pdcp_test_params[i].auth_key_len;
7448 ut_params->cipher_xform.next = &ut_params->auth_xform;
7450 ut_params->cipher_xform.next = NULL;
7453 struct rte_security_session_conf sess_conf = {
7454 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7455 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7457 .bearer = pdcp_test_bearer[i],
7458 .domain = pdcp_test_params[i].domain,
7459 .pkt_dir = pdcp_test_packet_direction[i],
7460 .sn_size = pdcp_test_data_sn_size[i],
7461 .hfn = pdcp_test_hfn[i],
7462 .hfn_threshold = pdcp_test_hfn_threshold[i],
7464 .crypto_xform = &ut_params->cipher_xform
7467 /* Create security session */
7468 ut_params->sec_session = rte_security_session_create(ctx,
7469 &sess_conf, ts_params->session_priv_mpool);
7471 if (!ut_params->sec_session) {
7472 printf("TestCase %s()-%d line %d failed %s: ",
7473 __func__, i, __LINE__, "Failed to allocate session");
7478 /* Generate crypto op data structure */
7479 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7480 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7481 if (!ut_params->op) {
7482 printf("TestCase %s()-%d line %d failed %s: ",
7483 __func__, i, __LINE__,
7484 "Failed to allocate symmetric crypto operation struct");
7489 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7491 /* set crypto operation source mbuf */
7492 ut_params->op->sym->m_src = ut_params->ibuf;
7494 ut_params->op->sym->m_dst = ut_params->obuf;
7496 /* Process crypto operation */
7497 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7499 printf("TestCase %s()-%d line %d failed %s: ",
7500 __func__, i, __LINE__,
7501 "failed to process sym crypto op");
7506 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7507 printf("TestCase %s()-%d line %d failed %s: ",
7508 __func__, i, __LINE__, "crypto op processing failed");
7514 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7517 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7521 fragsz = frag_size_oop;
7522 if (memcmp(ciphertext, output_vec, fragsz)) {
7523 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7524 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7525 rte_hexdump(stdout, "reference", output_vec, fragsz);
7530 buf = ut_params->op->sym->m_src->next;
7532 buf = ut_params->op->sym->m_dst->next;
7534 unsigned int off = fragsz;
7538 ciphertext = rte_pktmbuf_mtod(buf,
7540 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7541 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7542 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7543 rte_hexdump(stdout, "reference", output_vec + off,
7548 off += to_trn_tbl[ecx++];
7552 rte_crypto_op_free(ut_params->op);
7553 ut_params->op = NULL;
7555 if (ut_params->sec_session)
7556 rte_security_session_destroy(ctx, ut_params->sec_session);
7557 ut_params->sec_session = NULL;
7559 rte_pktmbuf_free(ut_params->ibuf);
7560 ut_params->ibuf = NULL;
7562 rte_pktmbuf_free(ut_params->obuf);
7563 ut_params->obuf = NULL;
7570 test_pdcp_proto_cplane_encap(int i)
7572 return test_pdcp_proto(i, 0,
7573 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7574 RTE_CRYPTO_AUTH_OP_GENERATE,
7575 pdcp_test_data_in[i],
7576 pdcp_test_data_in_len[i],
7577 pdcp_test_data_out[i],
7578 pdcp_test_data_in_len[i]+4);
7582 test_pdcp_proto_uplane_encap(int i)
7584 return test_pdcp_proto(i, 0,
7585 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7586 RTE_CRYPTO_AUTH_OP_GENERATE,
7587 pdcp_test_data_in[i],
7588 pdcp_test_data_in_len[i],
7589 pdcp_test_data_out[i],
7590 pdcp_test_data_in_len[i]);
7595 test_pdcp_proto_uplane_encap_with_int(int i)
7597 return test_pdcp_proto(i, 0,
7598 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7599 RTE_CRYPTO_AUTH_OP_GENERATE,
7600 pdcp_test_data_in[i],
7601 pdcp_test_data_in_len[i],
7602 pdcp_test_data_out[i],
7603 pdcp_test_data_in_len[i] + 4);
7607 test_pdcp_proto_cplane_decap(int i)
7609 return test_pdcp_proto(i, 0,
7610 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7611 RTE_CRYPTO_AUTH_OP_VERIFY,
7612 pdcp_test_data_out[i],
7613 pdcp_test_data_in_len[i] + 4,
7614 pdcp_test_data_in[i],
7615 pdcp_test_data_in_len[i]);
7619 test_pdcp_proto_uplane_decap(int i)
7621 return test_pdcp_proto(i, 0,
7622 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7623 RTE_CRYPTO_AUTH_OP_VERIFY,
7624 pdcp_test_data_out[i],
7625 pdcp_test_data_in_len[i],
7626 pdcp_test_data_in[i],
7627 pdcp_test_data_in_len[i]);
7631 test_pdcp_proto_uplane_decap_with_int(int i)
7633 return test_pdcp_proto(i, 0,
7634 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7635 RTE_CRYPTO_AUTH_OP_VERIFY,
7636 pdcp_test_data_out[i],
7637 pdcp_test_data_in_len[i] + 4,
7638 pdcp_test_data_in[i],
7639 pdcp_test_data_in_len[i]);
7643 test_PDCP_PROTO_SGL_in_place_32B(void)
7645 /* i can be used for running any PDCP case
7646 * In this case it is uplane 12-bit AES-SNOW DL encap
7648 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7649 return test_pdcp_proto_SGL(i, IN_PLACE,
7650 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7651 RTE_CRYPTO_AUTH_OP_GENERATE,
7652 pdcp_test_data_in[i],
7653 pdcp_test_data_in_len[i],
7654 pdcp_test_data_out[i],
7655 pdcp_test_data_in_len[i]+4,
7659 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7661 /* i can be used for running any PDCP case
7662 * In this case it is uplane 18-bit NULL-NULL DL encap
7664 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7665 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7666 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7667 RTE_CRYPTO_AUTH_OP_GENERATE,
7668 pdcp_test_data_in[i],
7669 pdcp_test_data_in_len[i],
7670 pdcp_test_data_out[i],
7671 pdcp_test_data_in_len[i]+4,
7675 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7677 /* i can be used for running any PDCP case
7678 * In this case it is uplane 18-bit AES DL encap
7680 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7682 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7683 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7684 RTE_CRYPTO_AUTH_OP_GENERATE,
7685 pdcp_test_data_in[i],
7686 pdcp_test_data_in_len[i],
7687 pdcp_test_data_out[i],
7688 pdcp_test_data_in_len[i],
7692 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7694 /* i can be used for running any PDCP case
7695 * In this case it is cplane 12-bit AES-ZUC DL encap
7697 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7698 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7699 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7700 RTE_CRYPTO_AUTH_OP_GENERATE,
7701 pdcp_test_data_in[i],
7702 pdcp_test_data_in_len[i],
7703 pdcp_test_data_out[i],
7704 pdcp_test_data_in_len[i]+4,
7710 test_AES_GCM_authenticated_encryption_test_case_1(void)
7712 return test_authenticated_encryption(&gcm_test_case_1);
7716 test_AES_GCM_authenticated_encryption_test_case_2(void)
7718 return test_authenticated_encryption(&gcm_test_case_2);
7722 test_AES_GCM_authenticated_encryption_test_case_3(void)
7724 return test_authenticated_encryption(&gcm_test_case_3);
7728 test_AES_GCM_authenticated_encryption_test_case_4(void)
7730 return test_authenticated_encryption(&gcm_test_case_4);
7734 test_AES_GCM_authenticated_encryption_test_case_5(void)
7736 return test_authenticated_encryption(&gcm_test_case_5);
7740 test_AES_GCM_authenticated_encryption_test_case_6(void)
7742 return test_authenticated_encryption(&gcm_test_case_6);
7746 test_AES_GCM_authenticated_encryption_test_case_7(void)
7748 return test_authenticated_encryption(&gcm_test_case_7);
7752 test_AES_GCM_authenticated_encryption_test_case_8(void)
7754 return test_authenticated_encryption(&gcm_test_case_8);
7758 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7760 return test_authenticated_encryption(&gcm_J0_test_case_1);
7764 test_AES_GCM_auth_encryption_test_case_192_1(void)
7766 return test_authenticated_encryption(&gcm_test_case_192_1);
7770 test_AES_GCM_auth_encryption_test_case_192_2(void)
7772 return test_authenticated_encryption(&gcm_test_case_192_2);
7776 test_AES_GCM_auth_encryption_test_case_192_3(void)
7778 return test_authenticated_encryption(&gcm_test_case_192_3);
7782 test_AES_GCM_auth_encryption_test_case_192_4(void)
7784 return test_authenticated_encryption(&gcm_test_case_192_4);
7788 test_AES_GCM_auth_encryption_test_case_192_5(void)
7790 return test_authenticated_encryption(&gcm_test_case_192_5);
7794 test_AES_GCM_auth_encryption_test_case_192_6(void)
7796 return test_authenticated_encryption(&gcm_test_case_192_6);
7800 test_AES_GCM_auth_encryption_test_case_192_7(void)
7802 return test_authenticated_encryption(&gcm_test_case_192_7);
7806 test_AES_GCM_auth_encryption_test_case_256_1(void)
7808 return test_authenticated_encryption(&gcm_test_case_256_1);
7812 test_AES_GCM_auth_encryption_test_case_256_2(void)
7814 return test_authenticated_encryption(&gcm_test_case_256_2);
7818 test_AES_GCM_auth_encryption_test_case_256_3(void)
7820 return test_authenticated_encryption(&gcm_test_case_256_3);
7824 test_AES_GCM_auth_encryption_test_case_256_4(void)
7826 return test_authenticated_encryption(&gcm_test_case_256_4);
7830 test_AES_GCM_auth_encryption_test_case_256_5(void)
7832 return test_authenticated_encryption(&gcm_test_case_256_5);
7836 test_AES_GCM_auth_encryption_test_case_256_6(void)
7838 return test_authenticated_encryption(&gcm_test_case_256_6);
7842 test_AES_GCM_auth_encryption_test_case_256_7(void)
7844 return test_authenticated_encryption(&gcm_test_case_256_7);
7848 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7850 return test_authenticated_encryption(&gcm_test_case_aad_1);
7854 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7856 return test_authenticated_encryption(&gcm_test_case_aad_2);
7860 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7862 struct aead_test_data tdata;
7865 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7866 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7867 tdata.iv.data[0] += 1;
7868 res = test_authenticated_encryption(&tdata);
7869 if (res == -ENOTSUP)
7871 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7872 return TEST_SUCCESS;
7876 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7878 struct aead_test_data tdata;
7881 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7882 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7883 tdata.plaintext.data[0] += 1;
7884 res = test_authenticated_encryption(&tdata);
7885 if (res == -ENOTSUP)
7887 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7888 return TEST_SUCCESS;
7892 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7894 struct aead_test_data tdata;
7897 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7898 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7899 tdata.ciphertext.data[0] += 1;
7900 res = test_authenticated_encryption(&tdata);
7901 if (res == -ENOTSUP)
7903 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7904 return TEST_SUCCESS;
7908 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7910 struct aead_test_data tdata;
7913 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7914 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7916 res = test_authenticated_encryption(&tdata);
7917 if (res == -ENOTSUP)
7919 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7920 return TEST_SUCCESS;
7924 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7926 struct aead_test_data tdata;
7927 uint8_t aad[gcm_test_case_7.aad.len];
7930 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7931 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7932 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7934 tdata.aad.data = aad;
7935 res = test_authenticated_encryption(&tdata);
7936 if (res == -ENOTSUP)
7938 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7939 return TEST_SUCCESS;
7943 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7945 struct aead_test_data tdata;
7948 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7949 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7950 tdata.auth_tag.data[0] += 1;
7951 res = test_authenticated_encryption(&tdata);
7952 if (res == -ENOTSUP)
7954 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7955 return TEST_SUCCESS;
7959 test_authenticated_decryption(const struct aead_test_data *tdata)
7961 struct crypto_testsuite_params *ts_params = &testsuite_params;
7962 struct crypto_unittest_params *ut_params = &unittest_params;
7968 /* Verify the capabilities */
7969 struct rte_cryptodev_sym_capability_idx cap_idx;
7970 const struct rte_cryptodev_symmetric_capability *capability;
7971 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7972 cap_idx.algo.aead = tdata->algo;
7973 capability = rte_cryptodev_sym_capability_get(
7974 ts_params->valid_devs[0], &cap_idx);
7975 if (capability == NULL)
7977 if (rte_cryptodev_sym_capability_check_aead(
7978 capability, tdata->key.len, tdata->auth_tag.len,
7979 tdata->aad.len, tdata->iv.len))
7982 /* Create AEAD session */
7983 retval = create_aead_session(ts_params->valid_devs[0],
7985 RTE_CRYPTO_AEAD_OP_DECRYPT,
7986 tdata->key.data, tdata->key.len,
7987 tdata->aad.len, tdata->auth_tag.len,
7992 /* alloc mbuf and set payload */
7993 if (tdata->aad.len > MBUF_SIZE) {
7994 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7995 /* Populate full size of add data */
7996 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7997 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7999 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8002 rte_pktmbuf_tailroom(ut_params->ibuf));
8004 /* Create AEAD operation */
8005 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8009 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8011 ut_params->op->sym->m_src = ut_params->ibuf;
8013 /* Process crypto operation */
8014 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8015 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8017 TEST_ASSERT_NOT_NULL(
8018 process_crypto_request(ts_params->valid_devs[0],
8019 ut_params->op), "failed to process sym crypto op");
8021 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8022 "crypto op processing failed");
8024 if (ut_params->op->sym->m_dst)
8025 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8028 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8030 ut_params->op->sym->cipher.data.offset);
8032 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8035 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8037 tdata->plaintext.data,
8038 tdata->plaintext.len,
8039 "Plaintext data not as expected");
8041 TEST_ASSERT_EQUAL(ut_params->op->status,
8042 RTE_CRYPTO_OP_STATUS_SUCCESS,
8043 "Authentication failed");
8049 test_AES_GCM_authenticated_decryption_test_case_1(void)
8051 return test_authenticated_decryption(&gcm_test_case_1);
8055 test_AES_GCM_authenticated_decryption_test_case_2(void)
8057 return test_authenticated_decryption(&gcm_test_case_2);
8061 test_AES_GCM_authenticated_decryption_test_case_3(void)
8063 return test_authenticated_decryption(&gcm_test_case_3);
8067 test_AES_GCM_authenticated_decryption_test_case_4(void)
8069 return test_authenticated_decryption(&gcm_test_case_4);
8073 test_AES_GCM_authenticated_decryption_test_case_5(void)
8075 return test_authenticated_decryption(&gcm_test_case_5);
8079 test_AES_GCM_authenticated_decryption_test_case_6(void)
8081 return test_authenticated_decryption(&gcm_test_case_6);
8085 test_AES_GCM_authenticated_decryption_test_case_7(void)
8087 return test_authenticated_decryption(&gcm_test_case_7);
8091 test_AES_GCM_authenticated_decryption_test_case_8(void)
8093 return test_authenticated_decryption(&gcm_test_case_8);
8097 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8099 return test_authenticated_decryption(&gcm_J0_test_case_1);
8103 test_AES_GCM_auth_decryption_test_case_192_1(void)
8105 return test_authenticated_decryption(&gcm_test_case_192_1);
8109 test_AES_GCM_auth_decryption_test_case_192_2(void)
8111 return test_authenticated_decryption(&gcm_test_case_192_2);
8115 test_AES_GCM_auth_decryption_test_case_192_3(void)
8117 return test_authenticated_decryption(&gcm_test_case_192_3);
8121 test_AES_GCM_auth_decryption_test_case_192_4(void)
8123 return test_authenticated_decryption(&gcm_test_case_192_4);
8127 test_AES_GCM_auth_decryption_test_case_192_5(void)
8129 return test_authenticated_decryption(&gcm_test_case_192_5);
8133 test_AES_GCM_auth_decryption_test_case_192_6(void)
8135 return test_authenticated_decryption(&gcm_test_case_192_6);
8139 test_AES_GCM_auth_decryption_test_case_192_7(void)
8141 return test_authenticated_decryption(&gcm_test_case_192_7);
8145 test_AES_GCM_auth_decryption_test_case_256_1(void)
8147 return test_authenticated_decryption(&gcm_test_case_256_1);
8151 test_AES_GCM_auth_decryption_test_case_256_2(void)
8153 return test_authenticated_decryption(&gcm_test_case_256_2);
8157 test_AES_GCM_auth_decryption_test_case_256_3(void)
8159 return test_authenticated_decryption(&gcm_test_case_256_3);
8163 test_AES_GCM_auth_decryption_test_case_256_4(void)
8165 return test_authenticated_decryption(&gcm_test_case_256_4);
8169 test_AES_GCM_auth_decryption_test_case_256_5(void)
8171 return test_authenticated_decryption(&gcm_test_case_256_5);
8175 test_AES_GCM_auth_decryption_test_case_256_6(void)
8177 return test_authenticated_decryption(&gcm_test_case_256_6);
8181 test_AES_GCM_auth_decryption_test_case_256_7(void)
8183 return test_authenticated_decryption(&gcm_test_case_256_7);
8187 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8189 return test_authenticated_decryption(&gcm_test_case_aad_1);
8193 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8195 return test_authenticated_decryption(&gcm_test_case_aad_2);
8199 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8201 struct aead_test_data tdata;
8204 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8205 tdata.iv.data[0] += 1;
8206 res = test_authenticated_decryption(&tdata);
8207 if (res == -ENOTSUP)
8209 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8210 return TEST_SUCCESS;
8214 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8216 struct aead_test_data tdata;
8219 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8220 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8221 tdata.plaintext.data[0] += 1;
8222 res = test_authenticated_decryption(&tdata);
8223 if (res == -ENOTSUP)
8225 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8226 return TEST_SUCCESS;
8230 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8232 struct aead_test_data tdata;
8235 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8236 tdata.ciphertext.data[0] += 1;
8237 res = test_authenticated_decryption(&tdata);
8238 if (res == -ENOTSUP)
8240 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8241 return TEST_SUCCESS;
8245 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8247 struct aead_test_data tdata;
8250 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8252 res = test_authenticated_decryption(&tdata);
8253 if (res == -ENOTSUP)
8255 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8256 return TEST_SUCCESS;
8260 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8262 struct aead_test_data tdata;
8263 uint8_t aad[gcm_test_case_7.aad.len];
8266 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8267 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8269 tdata.aad.data = aad;
8270 res = test_authenticated_decryption(&tdata);
8271 if (res == -ENOTSUP)
8273 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8274 return TEST_SUCCESS;
8278 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8280 struct aead_test_data tdata;
8283 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8284 tdata.auth_tag.data[0] += 1;
8285 res = test_authenticated_decryption(&tdata);
8286 if (res == -ENOTSUP)
8288 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8289 return TEST_SUCCESS;
8293 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8295 struct crypto_testsuite_params *ts_params = &testsuite_params;
8296 struct crypto_unittest_params *ut_params = &unittest_params;
8299 uint8_t *ciphertext, *auth_tag;
8300 uint16_t plaintext_pad_len;
8302 /* Verify the capabilities */
8303 struct rte_cryptodev_sym_capability_idx cap_idx;
8304 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8305 cap_idx.algo.aead = tdata->algo;
8306 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8310 /* not supported with CPU crypto */
8311 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8314 /* Create AEAD session */
8315 retval = create_aead_session(ts_params->valid_devs[0],
8317 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8318 tdata->key.data, tdata->key.len,
8319 tdata->aad.len, tdata->auth_tag.len,
8324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8325 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8327 /* clear mbuf payload */
8328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8329 rte_pktmbuf_tailroom(ut_params->ibuf));
8330 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8331 rte_pktmbuf_tailroom(ut_params->obuf));
8333 /* Create AEAD operation */
8334 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8338 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8340 ut_params->op->sym->m_src = ut_params->ibuf;
8341 ut_params->op->sym->m_dst = ut_params->obuf;
8343 /* Process crypto operation */
8344 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8345 ut_params->op), "failed to process sym crypto op");
8347 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8348 "crypto op processing failed");
8350 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8352 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8353 ut_params->op->sym->cipher.data.offset);
8354 auth_tag = ciphertext + plaintext_pad_len;
8356 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8357 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8362 tdata->ciphertext.data,
8363 tdata->ciphertext.len,
8364 "Ciphertext data not as expected");
8366 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8368 tdata->auth_tag.data,
8369 tdata->auth_tag.len,
8370 "Generated auth tag not as expected");
8377 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8379 return test_authenticated_encryption_oop(&gcm_test_case_5);
8383 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8385 struct crypto_testsuite_params *ts_params = &testsuite_params;
8386 struct crypto_unittest_params *ut_params = &unittest_params;
8391 /* Verify the capabilities */
8392 struct rte_cryptodev_sym_capability_idx cap_idx;
8393 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8394 cap_idx.algo.aead = tdata->algo;
8395 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8399 /* not supported with CPU crypto */
8400 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8403 /* Create AEAD session */
8404 retval = create_aead_session(ts_params->valid_devs[0],
8406 RTE_CRYPTO_AEAD_OP_DECRYPT,
8407 tdata->key.data, tdata->key.len,
8408 tdata->aad.len, tdata->auth_tag.len,
8413 /* alloc mbuf and set payload */
8414 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8415 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8417 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8418 rte_pktmbuf_tailroom(ut_params->ibuf));
8419 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8420 rte_pktmbuf_tailroom(ut_params->obuf));
8422 /* Create AEAD operation */
8423 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8427 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8429 ut_params->op->sym->m_src = ut_params->ibuf;
8430 ut_params->op->sym->m_dst = ut_params->obuf;
8432 /* Process crypto operation */
8433 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8434 ut_params->op), "failed to process sym crypto op");
8436 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8437 "crypto op processing failed");
8439 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8440 ut_params->op->sym->cipher.data.offset);
8442 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8445 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8447 tdata->plaintext.data,
8448 tdata->plaintext.len,
8449 "Plaintext data not as expected");
8451 TEST_ASSERT_EQUAL(ut_params->op->status,
8452 RTE_CRYPTO_OP_STATUS_SUCCESS,
8453 "Authentication failed");
8458 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8460 return test_authenticated_decryption_oop(&gcm_test_case_5);
8464 test_authenticated_encryption_sessionless(
8465 const struct aead_test_data *tdata)
8467 struct crypto_testsuite_params *ts_params = &testsuite_params;
8468 struct crypto_unittest_params *ut_params = &unittest_params;
8471 uint8_t *ciphertext, *auth_tag;
8472 uint16_t plaintext_pad_len;
8473 uint8_t key[tdata->key.len + 1];
8475 /* This test is for AESNI MB and AESNI GCM PMDs only */
8476 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8477 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8478 (gbl_driver_id != rte_cryptodev_driver_id_get(
8479 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8482 /* not supported with CPU crypto */
8483 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8486 /* Verify the capabilities */
8487 struct rte_cryptodev_sym_capability_idx cap_idx;
8488 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8489 cap_idx.algo.aead = tdata->algo;
8490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8494 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8496 /* clear mbuf payload */
8497 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8498 rte_pktmbuf_tailroom(ut_params->ibuf));
8500 /* Create AEAD operation */
8501 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8505 /* Create GCM xform */
8506 memcpy(key, tdata->key.data, tdata->key.len);
8507 retval = create_aead_xform(ut_params->op,
8509 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8510 key, tdata->key.len,
8511 tdata->aad.len, tdata->auth_tag.len,
8516 ut_params->op->sym->m_src = ut_params->ibuf;
8518 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8519 RTE_CRYPTO_OP_SESSIONLESS,
8520 "crypto op session type not sessionless");
8522 /* Process crypto operation */
8523 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8524 ut_params->op), "failed to process sym crypto op");
8526 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8528 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8529 "crypto op status not success");
8531 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8533 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8534 ut_params->op->sym->cipher.data.offset);
8535 auth_tag = ciphertext + plaintext_pad_len;
8537 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8538 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8541 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8543 tdata->ciphertext.data,
8544 tdata->ciphertext.len,
8545 "Ciphertext data not as expected");
8547 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8549 tdata->auth_tag.data,
8550 tdata->auth_tag.len,
8551 "Generated auth tag not as expected");
8558 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8560 return test_authenticated_encryption_sessionless(
8565 test_authenticated_decryption_sessionless(
8566 const struct aead_test_data *tdata)
8568 struct crypto_testsuite_params *ts_params = &testsuite_params;
8569 struct crypto_unittest_params *ut_params = &unittest_params;
8573 uint8_t key[tdata->key.len + 1];
8575 /* This test is for AESNI MB and AESNI GCM PMDs only */
8576 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8577 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8578 (gbl_driver_id != rte_cryptodev_driver_id_get(
8579 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8582 /* not supported with CPU crypto */
8583 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8586 /* Verify the capabilities */
8587 struct rte_cryptodev_sym_capability_idx cap_idx;
8588 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8589 cap_idx.algo.aead = tdata->algo;
8590 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8594 /* alloc mbuf and set payload */
8595 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8597 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8598 rte_pktmbuf_tailroom(ut_params->ibuf));
8600 /* Create AEAD operation */
8601 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8605 /* Create AEAD xform */
8606 memcpy(key, tdata->key.data, tdata->key.len);
8607 retval = create_aead_xform(ut_params->op,
8609 RTE_CRYPTO_AEAD_OP_DECRYPT,
8610 key, tdata->key.len,
8611 tdata->aad.len, tdata->auth_tag.len,
8616 ut_params->op->sym->m_src = ut_params->ibuf;
8618 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8619 RTE_CRYPTO_OP_SESSIONLESS,
8620 "crypto op session type not sessionless");
8622 /* Process crypto operation */
8623 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8624 ut_params->op), "failed to process sym crypto op");
8626 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8628 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8629 "crypto op status not success");
8631 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8632 ut_params->op->sym->cipher.data.offset);
8634 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8637 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8639 tdata->plaintext.data,
8640 tdata->plaintext.len,
8641 "Plaintext data not as expected");
8643 TEST_ASSERT_EQUAL(ut_params->op->status,
8644 RTE_CRYPTO_OP_STATUS_SUCCESS,
8645 "Authentication failed");
8650 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8652 return test_authenticated_decryption_sessionless(
8657 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8659 return test_authenticated_encryption(&ccm_test_case_128_1);
8663 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8665 return test_authenticated_encryption(&ccm_test_case_128_2);
8669 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8671 return test_authenticated_encryption(&ccm_test_case_128_3);
8675 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8677 return test_authenticated_decryption(&ccm_test_case_128_1);
8681 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8683 return test_authenticated_decryption(&ccm_test_case_128_2);
8687 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8689 return test_authenticated_decryption(&ccm_test_case_128_3);
8693 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8695 return test_authenticated_encryption(&ccm_test_case_192_1);
8699 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8701 return test_authenticated_encryption(&ccm_test_case_192_2);
8705 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8707 return test_authenticated_encryption(&ccm_test_case_192_3);
8711 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8713 return test_authenticated_decryption(&ccm_test_case_192_1);
8717 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8719 return test_authenticated_decryption(&ccm_test_case_192_2);
8723 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8725 return test_authenticated_decryption(&ccm_test_case_192_3);
8729 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8731 return test_authenticated_encryption(&ccm_test_case_256_1);
8735 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8737 return test_authenticated_encryption(&ccm_test_case_256_2);
8741 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8743 return test_authenticated_encryption(&ccm_test_case_256_3);
8747 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8749 return test_authenticated_decryption(&ccm_test_case_256_1);
8753 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8755 return test_authenticated_decryption(&ccm_test_case_256_2);
8759 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8761 return test_authenticated_decryption(&ccm_test_case_256_3);
8767 struct crypto_testsuite_params *ts_params = &testsuite_params;
8768 struct rte_cryptodev_stats stats;
8769 struct rte_cryptodev *dev;
8770 cryptodev_stats_get_t temp_pfn;
8772 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8775 /* Verify the capabilities */
8776 struct rte_cryptodev_sym_capability_idx cap_idx;
8777 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8778 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8779 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8782 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8783 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8784 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8788 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8789 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8790 &stats) == -ENODEV),
8791 "rte_cryptodev_stats_get invalid dev failed");
8792 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8793 "rte_cryptodev_stats_get invalid Param failed");
8794 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8795 temp_pfn = dev->dev_ops->stats_get;
8796 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8797 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8799 "rte_cryptodev_stats_get invalid Param failed");
8800 dev->dev_ops->stats_get = temp_pfn;
8802 /* Test expected values */
8804 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8806 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8808 "rte_cryptodev_stats_get failed");
8809 TEST_ASSERT((stats.enqueued_count == 1),
8810 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8811 TEST_ASSERT((stats.dequeued_count == 1),
8812 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8813 TEST_ASSERT((stats.enqueue_err_count == 0),
8814 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8815 TEST_ASSERT((stats.dequeue_err_count == 0),
8816 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8818 /* invalid device but should ignore and not reset device stats*/
8819 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8820 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8822 "rte_cryptodev_stats_get failed");
8823 TEST_ASSERT((stats.enqueued_count == 1),
8824 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8826 /* check that a valid reset clears stats */
8827 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8828 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8830 "rte_cryptodev_stats_get failed");
8831 TEST_ASSERT((stats.enqueued_count == 0),
8832 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8833 TEST_ASSERT((stats.dequeued_count == 0),
8834 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8836 return TEST_SUCCESS;
8839 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8840 struct crypto_unittest_params *ut_params,
8841 enum rte_crypto_auth_operation op,
8842 const struct HMAC_MD5_vector *test_case)
8846 memcpy(key, test_case->key.data, test_case->key.len);
8848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8849 ut_params->auth_xform.next = NULL;
8850 ut_params->auth_xform.auth.op = op;
8852 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8854 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8855 ut_params->auth_xform.auth.key.length = test_case->key.len;
8856 ut_params->auth_xform.auth.key.data = key;
8858 ut_params->sess = rte_cryptodev_sym_session_create(
8859 ts_params->session_mpool);
8861 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8862 ut_params->sess, &ut_params->auth_xform,
8863 ts_params->session_priv_mpool);
8865 if (ut_params->sess == NULL)
8868 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8870 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8871 rte_pktmbuf_tailroom(ut_params->ibuf));
8876 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8877 const struct HMAC_MD5_vector *test_case,
8878 uint8_t **plaintext)
8880 uint16_t plaintext_pad_len;
8882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8884 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8887 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8889 memcpy(*plaintext, test_case->plaintext.data,
8890 test_case->plaintext.len);
8892 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8893 ut_params->ibuf, MD5_DIGEST_LEN);
8894 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8895 "no room to append digest");
8896 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8897 ut_params->ibuf, plaintext_pad_len);
8899 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8900 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8901 test_case->auth_tag.len);
8904 sym_op->auth.data.offset = 0;
8905 sym_op->auth.data.length = test_case->plaintext.len;
8907 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8908 ut_params->op->sym->m_src = ut_params->ibuf;
8914 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8916 uint16_t plaintext_pad_len;
8917 uint8_t *plaintext, *auth_tag;
8919 struct crypto_testsuite_params *ts_params = &testsuite_params;
8920 struct crypto_unittest_params *ut_params = &unittest_params;
8922 /* Verify the capabilities */
8923 struct rte_cryptodev_sym_capability_idx cap_idx;
8924 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8925 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8926 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8930 if (MD5_HMAC_create_session(ts_params, ut_params,
8931 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8934 /* Generate Crypto op data structure */
8935 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8936 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8937 TEST_ASSERT_NOT_NULL(ut_params->op,
8938 "Failed to allocate symmetric crypto operation struct");
8940 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8943 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8946 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8947 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8950 TEST_ASSERT_NOT_NULL(
8951 process_crypto_request(ts_params->valid_devs[0],
8953 "failed to process sym crypto op");
8955 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8956 "crypto op processing failed");
8958 if (ut_params->op->sym->m_dst) {
8959 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8960 uint8_t *, plaintext_pad_len);
8962 auth_tag = plaintext + plaintext_pad_len;
8965 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8967 test_case->auth_tag.data,
8968 test_case->auth_tag.len,
8969 "HMAC_MD5 generated tag not as expected");
8971 return TEST_SUCCESS;
8975 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8979 struct crypto_testsuite_params *ts_params = &testsuite_params;
8980 struct crypto_unittest_params *ut_params = &unittest_params;
8982 /* Verify the capabilities */
8983 struct rte_cryptodev_sym_capability_idx cap_idx;
8984 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8985 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8986 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8990 if (MD5_HMAC_create_session(ts_params, ut_params,
8991 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8995 /* Generate Crypto op data structure */
8996 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8997 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8998 TEST_ASSERT_NOT_NULL(ut_params->op,
8999 "Failed to allocate symmetric crypto operation struct");
9001 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9004 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9005 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9008 TEST_ASSERT_NOT_NULL(
9009 process_crypto_request(ts_params->valid_devs[0],
9011 "failed to process sym crypto op");
9013 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9014 "HMAC_MD5 crypto op processing failed");
9016 return TEST_SUCCESS;
9020 test_MD5_HMAC_generate_case_1(void)
9022 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9026 test_MD5_HMAC_verify_case_1(void)
9028 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9032 test_MD5_HMAC_generate_case_2(void)
9034 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9038 test_MD5_HMAC_verify_case_2(void)
9040 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9044 test_multi_session(void)
9046 struct crypto_testsuite_params *ts_params = &testsuite_params;
9047 struct crypto_unittest_params *ut_params = &unittest_params;
9049 struct rte_cryptodev_info dev_info;
9050 struct rte_cryptodev_sym_session **sessions;
9054 /* Verify the capabilities */
9055 struct rte_cryptodev_sym_capability_idx cap_idx;
9056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9057 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9061 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9062 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9063 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9067 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9068 aes_cbc_key, hmac_sha512_key);
9071 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9073 sessions = rte_malloc(NULL,
9074 (sizeof(struct rte_cryptodev_sym_session *) *
9075 MAX_NB_SESSIONS) + 1, 0);
9077 /* Create multiple crypto sessions*/
9078 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9080 sessions[i] = rte_cryptodev_sym_session_create(
9081 ts_params->session_mpool);
9083 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9084 sessions[i], &ut_params->auth_xform,
9085 ts_params->session_priv_mpool);
9086 TEST_ASSERT_NOT_NULL(sessions[i],
9087 "Session creation failed at session number %u",
9090 /* Attempt to send a request on each session */
9091 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9095 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9096 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9098 "Failed to perform decrypt on request number %u.", i);
9099 /* free crypto operation structure */
9101 rte_crypto_op_free(ut_params->op);
9104 * free mbuf - both obuf and ibuf are usually the same,
9105 * so check if they point at the same address is necessary,
9106 * to avoid freeing the mbuf twice.
9108 if (ut_params->obuf) {
9109 rte_pktmbuf_free(ut_params->obuf);
9110 if (ut_params->ibuf == ut_params->obuf)
9111 ut_params->ibuf = 0;
9112 ut_params->obuf = 0;
9114 if (ut_params->ibuf) {
9115 rte_pktmbuf_free(ut_params->ibuf);
9116 ut_params->ibuf = 0;
9120 /* Next session create should fail */
9121 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9122 sessions[i], &ut_params->auth_xform,
9123 ts_params->session_priv_mpool);
9124 TEST_ASSERT_NULL(sessions[i],
9125 "Session creation succeeded unexpectedly!");
9127 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9128 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9130 rte_cryptodev_sym_session_free(sessions[i]);
9135 return TEST_SUCCESS;
9138 struct multi_session_params {
9139 struct crypto_unittest_params ut_params;
9140 uint8_t *cipher_key;
9142 const uint8_t *cipher;
9143 const uint8_t *digest;
9147 #define MB_SESSION_NUMBER 3
9150 test_multi_session_random_usage(void)
9152 struct crypto_testsuite_params *ts_params = &testsuite_params;
9153 struct rte_cryptodev_info dev_info;
9154 struct rte_cryptodev_sym_session **sessions;
9156 struct multi_session_params ut_paramz[] = {
9159 .cipher_key = ms_aes_cbc_key0,
9160 .hmac_key = ms_hmac_key0,
9161 .cipher = ms_aes_cbc_cipher0,
9162 .digest = ms_hmac_digest0,
9163 .iv = ms_aes_cbc_iv0
9166 .cipher_key = ms_aes_cbc_key1,
9167 .hmac_key = ms_hmac_key1,
9168 .cipher = ms_aes_cbc_cipher1,
9169 .digest = ms_hmac_digest1,
9170 .iv = ms_aes_cbc_iv1
9173 .cipher_key = ms_aes_cbc_key2,
9174 .hmac_key = ms_hmac_key2,
9175 .cipher = ms_aes_cbc_cipher2,
9176 .digest = ms_hmac_digest2,
9177 .iv = ms_aes_cbc_iv2
9182 /* Verify the capabilities */
9183 struct rte_cryptodev_sym_capability_idx cap_idx;
9184 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9185 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9186 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9189 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9190 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9191 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9195 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9197 sessions = rte_malloc(NULL,
9198 (sizeof(struct rte_cryptodev_sym_session *)
9199 * MAX_NB_SESSIONS) + 1, 0);
9201 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9202 sessions[i] = rte_cryptodev_sym_session_create(
9203 ts_params->session_mpool);
9205 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9206 sizeof(struct crypto_unittest_params));
9208 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9209 &ut_paramz[i].ut_params,
9210 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9212 /* Create multiple crypto sessions*/
9213 rte_cryptodev_sym_session_init(
9214 ts_params->valid_devs[0],
9216 &ut_paramz[i].ut_params.auth_xform,
9217 ts_params->session_priv_mpool);
9219 TEST_ASSERT_NOT_NULL(sessions[i],
9220 "Session creation failed at session number %u",
9226 for (i = 0; i < 40000; i++) {
9228 j = rand() % MB_SESSION_NUMBER;
9230 TEST_ASSERT_SUCCESS(
9231 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9233 &ut_paramz[j].ut_params,
9234 ts_params, ut_paramz[j].cipher,
9235 ut_paramz[j].digest,
9237 "Failed to perform decrypt on request number %u.", i);
9239 if (ut_paramz[j].ut_params.op)
9240 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9243 * free mbuf - both obuf and ibuf are usually the same,
9244 * so check if they point at the same address is necessary,
9245 * to avoid freeing the mbuf twice.
9247 if (ut_paramz[j].ut_params.obuf) {
9248 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9249 if (ut_paramz[j].ut_params.ibuf
9250 == ut_paramz[j].ut_params.obuf)
9251 ut_paramz[j].ut_params.ibuf = 0;
9252 ut_paramz[j].ut_params.obuf = 0;
9254 if (ut_paramz[j].ut_params.ibuf) {
9255 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9256 ut_paramz[j].ut_params.ibuf = 0;
9260 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9261 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9263 rte_cryptodev_sym_session_free(sessions[i]);
9268 return TEST_SUCCESS;
9272 test_null_cipher_only_operation(void)
9274 struct crypto_testsuite_params *ts_params = &testsuite_params;
9275 struct crypto_unittest_params *ut_params = &unittest_params;
9277 /* Verify the capabilities */
9278 struct rte_cryptodev_sym_capability_idx cap_idx;
9279 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9280 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9285 /* Generate test mbuf data and space for digest */
9286 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9287 catch_22_quote, QUOTE_512_BYTES, 0);
9289 /* Setup Cipher Parameters */
9290 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9291 ut_params->cipher_xform.next = NULL;
9293 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9294 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9296 ut_params->sess = rte_cryptodev_sym_session_create(
9297 ts_params->session_mpool);
9299 /* Create Crypto session*/
9300 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9302 &ut_params->cipher_xform,
9303 ts_params->session_priv_mpool);
9304 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9306 /* Generate Crypto op data structure */
9307 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9308 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9309 TEST_ASSERT_NOT_NULL(ut_params->op,
9310 "Failed to allocate symmetric crypto operation struct");
9312 /* Set crypto operation data parameters */
9313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9315 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9317 /* set crypto operation source mbuf */
9318 sym_op->m_src = ut_params->ibuf;
9320 sym_op->cipher.data.offset = 0;
9321 sym_op->cipher.data.length = QUOTE_512_BYTES;
9323 /* Process crypto operation */
9324 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9326 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9329 "crypto operation processing failed");
9332 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9333 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9336 "Ciphertext data not as expected");
9338 return TEST_SUCCESS;
9340 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9341 0xab, 0xab, 0xab, 0xab,
9342 0xab, 0xab, 0xab, 0xab,
9343 0xab, 0xab, 0xab, 0xab};
9345 test_null_auth_only_operation(void)
9347 struct crypto_testsuite_params *ts_params = &testsuite_params;
9348 struct crypto_unittest_params *ut_params = &unittest_params;
9351 /* Verify the capabilities */
9352 struct rte_cryptodev_sym_capability_idx cap_idx;
9353 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9354 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9355 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9359 /* Generate test mbuf data and space for digest */
9360 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9361 catch_22_quote, QUOTE_512_BYTES, 0);
9363 /* create a pointer for digest, but don't expect anything to be written
9364 * here in a NULL auth algo so no mbuf append done.
9366 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9368 /* prefill the memory pointed to by digest */
9369 memcpy(digest, orig_data, sizeof(orig_data));
9371 /* Setup HMAC Parameters */
9372 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9373 ut_params->auth_xform.next = NULL;
9375 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9376 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9378 ut_params->sess = rte_cryptodev_sym_session_create(
9379 ts_params->session_mpool);
9381 /* Create Crypto session*/
9382 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9383 ut_params->sess, &ut_params->auth_xform,
9384 ts_params->session_priv_mpool);
9385 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9387 /* Generate Crypto op data structure */
9388 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9389 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9390 TEST_ASSERT_NOT_NULL(ut_params->op,
9391 "Failed to allocate symmetric crypto operation struct");
9393 /* Set crypto operation data parameters */
9394 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9396 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9398 sym_op->m_src = ut_params->ibuf;
9400 sym_op->auth.data.offset = 0;
9401 sym_op->auth.data.length = QUOTE_512_BYTES;
9402 sym_op->auth.digest.data = digest;
9403 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9406 /* Process crypto operation */
9407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9409 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9411 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9412 "crypto operation processing failed");
9413 /* Make sure memory pointed to by digest hasn't been overwritten */
9414 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9418 "Memory at digest ptr overwritten unexpectedly");
9420 return TEST_SUCCESS;
9425 test_null_cipher_auth_operation(void)
9427 struct crypto_testsuite_params *ts_params = &testsuite_params;
9428 struct crypto_unittest_params *ut_params = &unittest_params;
9431 /* Verify the capabilities */
9432 struct rte_cryptodev_sym_capability_idx cap_idx;
9433 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9434 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9435 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9438 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9439 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9440 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9444 /* Generate test mbuf data and space for digest */
9445 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9446 catch_22_quote, QUOTE_512_BYTES, 0);
9448 /* create a pointer for digest, but don't expect anything to be written
9449 * here in a NULL auth algo so no mbuf append done.
9451 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9453 /* prefill the memory pointed to by digest */
9454 memcpy(digest, orig_data, sizeof(orig_data));
9456 /* Setup Cipher Parameters */
9457 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9458 ut_params->cipher_xform.next = &ut_params->auth_xform;
9460 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9461 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9463 /* Setup HMAC Parameters */
9464 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9465 ut_params->auth_xform.next = NULL;
9467 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9468 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9470 ut_params->sess = rte_cryptodev_sym_session_create(
9471 ts_params->session_mpool);
9473 /* Create Crypto session*/
9474 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9475 ut_params->sess, &ut_params->cipher_xform,
9476 ts_params->session_priv_mpool);
9477 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9479 /* Generate Crypto op data structure */
9480 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9481 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9482 TEST_ASSERT_NOT_NULL(ut_params->op,
9483 "Failed to allocate symmetric crypto operation struct");
9485 /* Set crypto operation data parameters */
9486 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9488 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9490 sym_op->m_src = ut_params->ibuf;
9492 sym_op->cipher.data.offset = 0;
9493 sym_op->cipher.data.length = QUOTE_512_BYTES;
9495 sym_op->auth.data.offset = 0;
9496 sym_op->auth.data.length = QUOTE_512_BYTES;
9497 sym_op->auth.digest.data = digest;
9498 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9501 /* Process crypto operation */
9502 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9504 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9506 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9507 "crypto operation processing failed");
9510 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9511 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9514 "Ciphertext data not as expected");
9515 /* Make sure memory pointed to by digest hasn't been overwritten */
9516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9520 "Memory at digest ptr overwritten unexpectedly");
9522 return TEST_SUCCESS;
9526 test_null_auth_cipher_operation(void)
9528 struct crypto_testsuite_params *ts_params = &testsuite_params;
9529 struct crypto_unittest_params *ut_params = &unittest_params;
9532 /* Verify the capabilities */
9533 struct rte_cryptodev_sym_capability_idx cap_idx;
9534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9535 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9540 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9541 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9545 /* Generate test mbuf data */
9546 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9547 catch_22_quote, QUOTE_512_BYTES, 0);
9549 /* create a pointer for digest, but don't expect anything to be written
9550 * here in a NULL auth algo so no mbuf append done.
9552 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9554 /* prefill the memory pointed to by digest */
9555 memcpy(digest, orig_data, sizeof(orig_data));
9557 /* Setup Cipher Parameters */
9558 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9559 ut_params->cipher_xform.next = NULL;
9561 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9562 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9564 /* Setup HMAC Parameters */
9565 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9566 ut_params->auth_xform.next = &ut_params->cipher_xform;
9568 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9569 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9571 ut_params->sess = rte_cryptodev_sym_session_create(
9572 ts_params->session_mpool);
9574 /* Create Crypto session*/
9575 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9576 ut_params->sess, &ut_params->cipher_xform,
9577 ts_params->session_priv_mpool);
9578 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9580 /* Generate Crypto op data structure */
9581 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9582 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9583 TEST_ASSERT_NOT_NULL(ut_params->op,
9584 "Failed to allocate symmetric crypto operation struct");
9586 /* Set crypto operation data parameters */
9587 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9589 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9591 sym_op->m_src = ut_params->ibuf;
9593 sym_op->cipher.data.offset = 0;
9594 sym_op->cipher.data.length = QUOTE_512_BYTES;
9596 sym_op->auth.data.offset = 0;
9597 sym_op->auth.data.length = QUOTE_512_BYTES;
9598 sym_op->auth.digest.data = digest;
9599 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9602 /* Process crypto operation */
9603 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9605 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9607 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9608 "crypto operation processing failed");
9611 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9612 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9615 "Ciphertext data not as expected");
9616 /* Make sure memory pointed to by digest hasn't been overwritten */
9617 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9621 "Memory at digest ptr overwritten unexpectedly");
9623 return TEST_SUCCESS;
9628 test_null_invalid_operation(void)
9630 struct crypto_testsuite_params *ts_params = &testsuite_params;
9631 struct crypto_unittest_params *ut_params = &unittest_params;
9634 /* This test is for NULL PMD only */
9635 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9636 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9639 /* Setup Cipher Parameters */
9640 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9641 ut_params->cipher_xform.next = NULL;
9643 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9644 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9646 ut_params->sess = rte_cryptodev_sym_session_create(
9647 ts_params->session_mpool);
9649 /* Create Crypto session*/
9650 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9651 ut_params->sess, &ut_params->cipher_xform,
9652 ts_params->session_priv_mpool);
9653 TEST_ASSERT(ret < 0,
9654 "Session creation succeeded unexpectedly");
9657 /* Setup HMAC Parameters */
9658 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9659 ut_params->auth_xform.next = NULL;
9661 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9662 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9664 ut_params->sess = rte_cryptodev_sym_session_create(
9665 ts_params->session_mpool);
9667 /* Create Crypto session*/
9668 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9669 ut_params->sess, &ut_params->auth_xform,
9670 ts_params->session_priv_mpool);
9671 TEST_ASSERT(ret < 0,
9672 "Session creation succeeded unexpectedly");
9674 return TEST_SUCCESS;
9678 #define NULL_BURST_LENGTH (32)
9681 test_null_burst_operation(void)
9683 struct crypto_testsuite_params *ts_params = &testsuite_params;
9684 struct crypto_unittest_params *ut_params = &unittest_params;
9686 unsigned i, burst_len = NULL_BURST_LENGTH;
9688 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9689 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9691 /* This test is for NULL PMD only */
9692 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9693 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9696 /* Setup Cipher Parameters */
9697 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9698 ut_params->cipher_xform.next = &ut_params->auth_xform;
9700 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9701 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9703 /* Setup HMAC Parameters */
9704 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9705 ut_params->auth_xform.next = NULL;
9707 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9708 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9710 ut_params->sess = rte_cryptodev_sym_session_create(
9711 ts_params->session_mpool);
9713 /* Create Crypto session*/
9714 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9715 ut_params->sess, &ut_params->cipher_xform,
9716 ts_params->session_priv_mpool);
9717 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9719 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9720 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9721 burst_len, "failed to generate burst of crypto ops");
9723 /* Generate an operation for each mbuf in burst */
9724 for (i = 0; i < burst_len; i++) {
9725 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9727 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9729 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9733 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9735 burst[i]->sym->m_src = m;
9738 /* Process crypto operation */
9739 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9740 0, burst, burst_len),
9742 "Error enqueuing burst");
9744 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9745 0, burst_dequeued, burst_len),
9747 "Error dequeuing burst");
9750 for (i = 0; i < burst_len; i++) {
9752 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9753 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9755 "data not as expected");
9757 rte_pktmbuf_free(burst[i]->sym->m_src);
9758 rte_crypto_op_free(burst[i]);
9761 return TEST_SUCCESS;
9765 generate_gmac_large_plaintext(uint8_t *data)
9769 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9770 memcpy(&data[i], &data[0], 32);
9774 create_gmac_operation(enum rte_crypto_auth_operation op,
9775 const struct gmac_test_data *tdata)
9777 struct crypto_testsuite_params *ts_params = &testsuite_params;
9778 struct crypto_unittest_params *ut_params = &unittest_params;
9779 struct rte_crypto_sym_op *sym_op;
9781 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9783 /* Generate Crypto op data structure */
9784 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9785 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9786 TEST_ASSERT_NOT_NULL(ut_params->op,
9787 "Failed to allocate symmetric crypto operation struct");
9789 sym_op = ut_params->op->sym;
9791 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9792 ut_params->ibuf, tdata->gmac_tag.len);
9793 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9794 "no room to append digest");
9796 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9797 ut_params->ibuf, plaintext_pad_len);
9799 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9800 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9801 tdata->gmac_tag.len);
9802 debug_hexdump(stdout, "digest:",
9803 sym_op->auth.digest.data,
9804 tdata->gmac_tag.len);
9807 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9808 uint8_t *, IV_OFFSET);
9810 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9812 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9814 sym_op->cipher.data.length = 0;
9815 sym_op->cipher.data.offset = 0;
9817 sym_op->auth.data.offset = 0;
9818 sym_op->auth.data.length = tdata->plaintext.len;
9823 static int create_gmac_session(uint8_t dev_id,
9824 const struct gmac_test_data *tdata,
9825 enum rte_crypto_auth_operation auth_op)
9827 uint8_t auth_key[tdata->key.len];
9829 struct crypto_testsuite_params *ts_params = &testsuite_params;
9830 struct crypto_unittest_params *ut_params = &unittest_params;
9832 memcpy(auth_key, tdata->key.data, tdata->key.len);
9834 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9835 ut_params->auth_xform.next = NULL;
9837 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9838 ut_params->auth_xform.auth.op = auth_op;
9839 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9840 ut_params->auth_xform.auth.key.length = tdata->key.len;
9841 ut_params->auth_xform.auth.key.data = auth_key;
9842 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9843 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9846 ut_params->sess = rte_cryptodev_sym_session_create(
9847 ts_params->session_mpool);
9849 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9850 &ut_params->auth_xform,
9851 ts_params->session_priv_mpool);
9853 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9859 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9861 struct crypto_testsuite_params *ts_params = &testsuite_params;
9862 struct crypto_unittest_params *ut_params = &unittest_params;
9866 uint8_t *auth_tag, *plaintext;
9867 uint16_t plaintext_pad_len;
9869 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9870 "No GMAC length in the source data");
9872 /* Verify the capabilities */
9873 struct rte_cryptodev_sym_capability_idx cap_idx;
9874 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9875 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9876 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9880 retval = create_gmac_session(ts_params->valid_devs[0],
9881 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9886 if (tdata->plaintext.len > MBUF_SIZE)
9887 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9889 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9890 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9891 "Failed to allocate input buffer in mempool");
9893 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9894 rte_pktmbuf_tailroom(ut_params->ibuf));
9896 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9898 * Runtime generate the large plain text instead of use hard code
9899 * plain text vector. It is done to avoid create huge source file
9900 * with the test vector.
9902 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9903 generate_gmac_large_plaintext(tdata->plaintext.data);
9905 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9907 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9909 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9910 debug_hexdump(stdout, "plaintext:", plaintext,
9911 tdata->plaintext.len);
9913 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9919 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9921 ut_params->op->sym->m_src = ut_params->ibuf;
9923 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9924 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9927 TEST_ASSERT_NOT_NULL(
9928 process_crypto_request(ts_params->valid_devs[0],
9929 ut_params->op), "failed to process sym crypto op");
9931 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9932 "crypto op processing failed");
9934 if (ut_params->op->sym->m_dst) {
9935 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9936 uint8_t *, plaintext_pad_len);
9938 auth_tag = plaintext + plaintext_pad_len;
9941 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9943 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9945 tdata->gmac_tag.data,
9946 tdata->gmac_tag.len,
9947 "GMAC Generated auth tag not as expected");
9953 test_AES_GMAC_authentication_test_case_1(void)
9955 return test_AES_GMAC_authentication(&gmac_test_case_1);
9959 test_AES_GMAC_authentication_test_case_2(void)
9961 return test_AES_GMAC_authentication(&gmac_test_case_2);
9965 test_AES_GMAC_authentication_test_case_3(void)
9967 return test_AES_GMAC_authentication(&gmac_test_case_3);
9971 test_AES_GMAC_authentication_test_case_4(void)
9973 return test_AES_GMAC_authentication(&gmac_test_case_4);
9977 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9979 struct crypto_testsuite_params *ts_params = &testsuite_params;
9980 struct crypto_unittest_params *ut_params = &unittest_params;
9982 uint32_t plaintext_pad_len;
9985 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9986 "No GMAC length in the source data");
9988 /* Verify the capabilities */
9989 struct rte_cryptodev_sym_capability_idx cap_idx;
9990 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9991 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9992 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9996 retval = create_gmac_session(ts_params->valid_devs[0],
9997 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10002 if (tdata->plaintext.len > MBUF_SIZE)
10003 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10006 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10007 "Failed to allocate input buffer in mempool");
10009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10010 rte_pktmbuf_tailroom(ut_params->ibuf));
10012 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10015 * Runtime generate the large plain text instead of use hard code
10016 * plain text vector. It is done to avoid create huge source file
10017 * with the test vector.
10019 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10020 generate_gmac_large_plaintext(tdata->plaintext.data);
10022 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10023 plaintext_pad_len);
10024 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10026 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10027 debug_hexdump(stdout, "plaintext:", plaintext,
10028 tdata->plaintext.len);
10030 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10036 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10038 ut_params->op->sym->m_src = ut_params->ibuf;
10040 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10041 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10044 TEST_ASSERT_NOT_NULL(
10045 process_crypto_request(ts_params->valid_devs[0],
10046 ut_params->op), "failed to process sym crypto op");
10048 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10049 "crypto op processing failed");
10056 test_AES_GMAC_authentication_verify_test_case_1(void)
10058 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10062 test_AES_GMAC_authentication_verify_test_case_2(void)
10064 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10068 test_AES_GMAC_authentication_verify_test_case_3(void)
10070 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10074 test_AES_GMAC_authentication_verify_test_case_4(void)
10076 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10079 struct test_crypto_vector {
10080 enum rte_crypto_cipher_algorithm crypto_algo;
10081 unsigned int cipher_offset;
10082 unsigned int cipher_len;
10095 const uint8_t *data;
10100 const uint8_t *data;
10104 enum rte_crypto_auth_algorithm auth_algo;
10105 unsigned int auth_offset;
10113 const uint8_t *data;
10123 static const struct test_crypto_vector
10124 hmac_sha1_test_crypto_vector = {
10125 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10127 .data = plaintext_hash,
10132 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10133 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10134 0xDE, 0xF4, 0xDE, 0xAD
10140 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10141 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10142 0x3F, 0x91, 0x64, 0x59
10148 static const struct test_crypto_vector
10149 aes128_gmac_test_vector = {
10150 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10152 .data = plaintext_hash,
10157 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10158 0x08, 0x09, 0x0A, 0x0B
10164 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10165 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10171 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10172 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10178 static const struct test_crypto_vector
10179 aes128cbc_hmac_sha1_test_vector = {
10180 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10181 .cipher_offset = 0,
10185 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10186 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10192 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10193 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10198 .data = plaintext_hash,
10202 .data = ciphertext512_aes128cbc,
10205 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10209 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10210 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10211 0xDE, 0xF4, 0xDE, 0xAD
10217 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10218 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10219 0x18, 0x8C, 0x1D, 0x32
10225 static const struct test_crypto_vector
10226 aes128cbc_hmac_sha1_aad_test_vector = {
10227 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10228 .cipher_offset = 12,
10232 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10233 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10239 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10240 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10245 .data = plaintext_hash,
10249 .data = ciphertext512_aes128cbc_aad,
10252 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10256 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10257 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10258 0xDE, 0xF4, 0xDE, 0xAD
10264 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10265 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10266 0x62, 0x8D, 0x62, 0x65
10273 data_corruption(uint8_t *data)
10279 tag_corruption(uint8_t *data, unsigned int tag_offset)
10281 data[tag_offset] += 1;
10285 create_auth_session(struct crypto_unittest_params *ut_params,
10287 const struct test_crypto_vector *reference,
10288 enum rte_crypto_auth_operation auth_op)
10290 struct crypto_testsuite_params *ts_params = &testsuite_params;
10291 uint8_t auth_key[reference->auth_key.len + 1];
10293 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10295 /* Setup Authentication Parameters */
10296 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10297 ut_params->auth_xform.auth.op = auth_op;
10298 ut_params->auth_xform.next = NULL;
10299 ut_params->auth_xform.auth.algo = reference->auth_algo;
10300 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10301 ut_params->auth_xform.auth.key.data = auth_key;
10302 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10304 /* Create Crypto session*/
10305 ut_params->sess = rte_cryptodev_sym_session_create(
10306 ts_params->session_mpool);
10308 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10309 &ut_params->auth_xform,
10310 ts_params->session_priv_mpool);
10312 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10318 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10320 const struct test_crypto_vector *reference,
10321 enum rte_crypto_auth_operation auth_op,
10322 enum rte_crypto_cipher_operation cipher_op)
10324 struct crypto_testsuite_params *ts_params = &testsuite_params;
10325 uint8_t cipher_key[reference->cipher_key.len + 1];
10326 uint8_t auth_key[reference->auth_key.len + 1];
10328 memcpy(cipher_key, reference->cipher_key.data,
10329 reference->cipher_key.len);
10330 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10332 /* Setup Authentication Parameters */
10333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10334 ut_params->auth_xform.auth.op = auth_op;
10335 ut_params->auth_xform.auth.algo = reference->auth_algo;
10336 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10337 ut_params->auth_xform.auth.key.data = auth_key;
10338 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10340 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10341 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10342 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10344 ut_params->auth_xform.next = &ut_params->cipher_xform;
10346 /* Setup Cipher Parameters */
10347 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10348 ut_params->cipher_xform.next = NULL;
10349 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10350 ut_params->cipher_xform.cipher.op = cipher_op;
10351 ut_params->cipher_xform.cipher.key.data = cipher_key;
10352 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10353 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10354 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10357 /* Create Crypto session*/
10358 ut_params->sess = rte_cryptodev_sym_session_create(
10359 ts_params->session_mpool);
10361 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10362 &ut_params->auth_xform,
10363 ts_params->session_priv_mpool);
10365 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10371 create_auth_operation(struct crypto_testsuite_params *ts_params,
10372 struct crypto_unittest_params *ut_params,
10373 const struct test_crypto_vector *reference,
10374 unsigned int auth_generate)
10376 /* Generate Crypto op data structure */
10377 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10378 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10379 TEST_ASSERT_NOT_NULL(ut_params->op,
10380 "Failed to allocate pktmbuf offload");
10382 /* Set crypto operation data parameters */
10383 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10385 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10387 /* set crypto operation source mbuf */
10388 sym_op->m_src = ut_params->ibuf;
10391 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10392 ut_params->ibuf, reference->digest.len);
10394 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10395 "no room to append auth tag");
10397 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10398 ut_params->ibuf, reference->plaintext.len);
10401 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10403 memcpy(sym_op->auth.digest.data,
10404 reference->digest.data,
10405 reference->digest.len);
10407 debug_hexdump(stdout, "digest:",
10408 sym_op->auth.digest.data,
10409 reference->digest.len);
10411 sym_op->auth.data.length = reference->plaintext.len;
10412 sym_op->auth.data.offset = 0;
10418 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10419 struct crypto_unittest_params *ut_params,
10420 const struct test_crypto_vector *reference,
10421 unsigned int auth_generate)
10423 /* Generate Crypto op data structure */
10424 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10425 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10426 TEST_ASSERT_NOT_NULL(ut_params->op,
10427 "Failed to allocate pktmbuf offload");
10429 /* Set crypto operation data parameters */
10430 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10432 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10434 /* set crypto operation source mbuf */
10435 sym_op->m_src = ut_params->ibuf;
10438 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10439 ut_params->ibuf, reference->digest.len);
10441 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10442 "no room to append auth tag");
10444 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10445 ut_params->ibuf, reference->ciphertext.len);
10448 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10450 memcpy(sym_op->auth.digest.data,
10451 reference->digest.data,
10452 reference->digest.len);
10454 debug_hexdump(stdout, "digest:",
10455 sym_op->auth.digest.data,
10456 reference->digest.len);
10458 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10459 reference->iv.data, reference->iv.len);
10461 sym_op->cipher.data.length = 0;
10462 sym_op->cipher.data.offset = 0;
10464 sym_op->auth.data.length = reference->plaintext.len;
10465 sym_op->auth.data.offset = 0;
10471 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10472 struct crypto_unittest_params *ut_params,
10473 const struct test_crypto_vector *reference,
10474 unsigned int auth_generate)
10476 /* Generate Crypto op data structure */
10477 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10478 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10479 TEST_ASSERT_NOT_NULL(ut_params->op,
10480 "Failed to allocate pktmbuf offload");
10482 /* Set crypto operation data parameters */
10483 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10485 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10487 /* set crypto operation source mbuf */
10488 sym_op->m_src = ut_params->ibuf;
10491 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10492 ut_params->ibuf, reference->digest.len);
10494 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10495 "no room to append auth tag");
10497 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10498 ut_params->ibuf, reference->ciphertext.len);
10501 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10503 memcpy(sym_op->auth.digest.data,
10504 reference->digest.data,
10505 reference->digest.len);
10507 debug_hexdump(stdout, "digest:",
10508 sym_op->auth.digest.data,
10509 reference->digest.len);
10511 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10512 reference->iv.data, reference->iv.len);
10514 sym_op->cipher.data.length = reference->cipher_len;
10515 sym_op->cipher.data.offset = reference->cipher_offset;
10517 sym_op->auth.data.length = reference->plaintext.len;
10518 sym_op->auth.data.offset = reference->auth_offset;
10524 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10525 struct crypto_unittest_params *ut_params,
10526 const struct test_crypto_vector *reference)
10528 return create_auth_operation(ts_params, ut_params, reference, 0);
10532 create_auth_verify_GMAC_operation(
10533 struct crypto_testsuite_params *ts_params,
10534 struct crypto_unittest_params *ut_params,
10535 const struct test_crypto_vector *reference)
10537 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10541 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10542 struct crypto_unittest_params *ut_params,
10543 const struct test_crypto_vector *reference)
10545 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10549 test_authentication_verify_fail_when_data_corruption(
10550 struct crypto_testsuite_params *ts_params,
10551 struct crypto_unittest_params *ut_params,
10552 const struct test_crypto_vector *reference,
10553 unsigned int data_corrupted)
10557 uint8_t *plaintext;
10559 /* Verify the capabilities */
10560 struct rte_cryptodev_sym_capability_idx cap_idx;
10561 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10562 cap_idx.algo.auth = reference->auth_algo;
10563 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10567 /* Create session */
10568 retval = create_auth_session(ut_params,
10569 ts_params->valid_devs[0],
10571 RTE_CRYPTO_AUTH_OP_VERIFY);
10575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10576 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10577 "Failed to allocate input buffer in mempool");
10579 /* clear mbuf payload */
10580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10581 rte_pktmbuf_tailroom(ut_params->ibuf));
10583 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10584 reference->plaintext.len);
10585 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10586 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10588 debug_hexdump(stdout, "plaintext:", plaintext,
10589 reference->plaintext.len);
10591 /* Create operation */
10592 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10597 if (data_corrupted)
10598 data_corruption(plaintext);
10600 tag_corruption(plaintext, reference->plaintext.len);
10602 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10603 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10605 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10606 RTE_CRYPTO_OP_STATUS_SUCCESS,
10607 "authentication not failed");
10609 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10611 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10618 test_authentication_verify_GMAC_fail_when_corruption(
10619 struct crypto_testsuite_params *ts_params,
10620 struct crypto_unittest_params *ut_params,
10621 const struct test_crypto_vector *reference,
10622 unsigned int data_corrupted)
10625 uint8_t *plaintext;
10627 /* Verify the capabilities */
10628 struct rte_cryptodev_sym_capability_idx cap_idx;
10629 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10630 cap_idx.algo.auth = reference->auth_algo;
10631 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10635 /* Create session */
10636 retval = create_auth_cipher_session(ut_params,
10637 ts_params->valid_devs[0],
10639 RTE_CRYPTO_AUTH_OP_VERIFY,
10640 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10644 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10645 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10646 "Failed to allocate input buffer in mempool");
10648 /* clear mbuf payload */
10649 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10650 rte_pktmbuf_tailroom(ut_params->ibuf));
10652 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10653 reference->plaintext.len);
10654 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10655 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10657 debug_hexdump(stdout, "plaintext:", plaintext,
10658 reference->plaintext.len);
10660 /* Create operation */
10661 retval = create_auth_verify_GMAC_operation(ts_params,
10668 if (data_corrupted)
10669 data_corruption(plaintext);
10671 tag_corruption(plaintext, reference->aad.len);
10673 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10674 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10676 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10677 RTE_CRYPTO_OP_STATUS_SUCCESS,
10678 "authentication not failed");
10680 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10682 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10689 test_authenticated_decryption_fail_when_corruption(
10690 struct crypto_testsuite_params *ts_params,
10691 struct crypto_unittest_params *ut_params,
10692 const struct test_crypto_vector *reference,
10693 unsigned int data_corrupted)
10697 uint8_t *ciphertext;
10699 /* Verify the capabilities */
10700 struct rte_cryptodev_sym_capability_idx cap_idx;
10701 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10702 cap_idx.algo.auth = reference->auth_algo;
10703 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10706 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10707 cap_idx.algo.cipher = reference->crypto_algo;
10708 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10712 /* Create session */
10713 retval = create_auth_cipher_session(ut_params,
10714 ts_params->valid_devs[0],
10716 RTE_CRYPTO_AUTH_OP_VERIFY,
10717 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10722 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10723 "Failed to allocate input buffer in mempool");
10725 /* clear mbuf payload */
10726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10727 rte_pktmbuf_tailroom(ut_params->ibuf));
10729 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10730 reference->ciphertext.len);
10731 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10732 memcpy(ciphertext, reference->ciphertext.data,
10733 reference->ciphertext.len);
10735 /* Create operation */
10736 retval = create_cipher_auth_verify_operation(ts_params,
10743 if (data_corrupted)
10744 data_corruption(ciphertext);
10746 tag_corruption(ciphertext, reference->ciphertext.len);
10748 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10749 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10751 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10752 RTE_CRYPTO_OP_STATUS_SUCCESS,
10753 "authentication not failed");
10755 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10757 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10764 test_authenticated_encryt_with_esn(
10765 struct crypto_testsuite_params *ts_params,
10766 struct crypto_unittest_params *ut_params,
10767 const struct test_crypto_vector *reference)
10771 uint8_t *authciphertext, *plaintext, *auth_tag;
10772 uint16_t plaintext_pad_len;
10773 uint8_t cipher_key[reference->cipher_key.len + 1];
10774 uint8_t auth_key[reference->auth_key.len + 1];
10776 /* Verify the capabilities */
10777 struct rte_cryptodev_sym_capability_idx cap_idx;
10778 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10779 cap_idx.algo.auth = reference->auth_algo;
10780 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10783 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10784 cap_idx.algo.cipher = reference->crypto_algo;
10785 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10789 /* Create session */
10790 memcpy(cipher_key, reference->cipher_key.data,
10791 reference->cipher_key.len);
10792 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10794 /* Setup Cipher Parameters */
10795 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10796 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10797 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10798 ut_params->cipher_xform.cipher.key.data = cipher_key;
10799 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10800 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10801 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10803 ut_params->cipher_xform.next = &ut_params->auth_xform;
10805 /* Setup Authentication Parameters */
10806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10807 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10808 ut_params->auth_xform.auth.algo = reference->auth_algo;
10809 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10810 ut_params->auth_xform.auth.key.data = auth_key;
10811 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10812 ut_params->auth_xform.next = NULL;
10814 /* Create Crypto session*/
10815 ut_params->sess = rte_cryptodev_sym_session_create(
10816 ts_params->session_mpool);
10818 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10820 &ut_params->cipher_xform,
10821 ts_params->session_priv_mpool);
10823 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10826 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10827 "Failed to allocate input buffer in mempool");
10829 /* clear mbuf payload */
10830 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10831 rte_pktmbuf_tailroom(ut_params->ibuf));
10833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10834 reference->plaintext.len);
10835 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10836 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10838 /* Create operation */
10839 retval = create_cipher_auth_operation(ts_params,
10846 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10847 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10850 ut_params->op = process_crypto_request(
10851 ts_params->valid_devs[0], ut_params->op);
10853 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10855 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10856 "crypto op processing failed");
10858 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10860 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10861 ut_params->op->sym->auth.data.offset);
10862 auth_tag = authciphertext + plaintext_pad_len;
10863 debug_hexdump(stdout, "ciphertext:", authciphertext,
10864 reference->ciphertext.len);
10865 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10867 /* Validate obuf */
10868 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10870 reference->ciphertext.data,
10871 reference->ciphertext.len,
10872 "Ciphertext data not as expected");
10874 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10876 reference->digest.data,
10877 reference->digest.len,
10878 "Generated digest not as expected");
10880 return TEST_SUCCESS;
10885 test_authenticated_decrypt_with_esn(
10886 struct crypto_testsuite_params *ts_params,
10887 struct crypto_unittest_params *ut_params,
10888 const struct test_crypto_vector *reference)
10892 uint8_t *ciphertext;
10893 uint8_t cipher_key[reference->cipher_key.len + 1];
10894 uint8_t auth_key[reference->auth_key.len + 1];
10896 /* Verify the capabilities */
10897 struct rte_cryptodev_sym_capability_idx cap_idx;
10898 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10899 cap_idx.algo.auth = reference->auth_algo;
10900 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10904 cap_idx.algo.cipher = reference->crypto_algo;
10905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10909 /* Create session */
10910 memcpy(cipher_key, reference->cipher_key.data,
10911 reference->cipher_key.len);
10912 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10914 /* Setup Authentication Parameters */
10915 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10916 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10917 ut_params->auth_xform.auth.algo = reference->auth_algo;
10918 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10919 ut_params->auth_xform.auth.key.data = auth_key;
10920 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10921 ut_params->auth_xform.next = &ut_params->cipher_xform;
10923 /* Setup Cipher Parameters */
10924 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10925 ut_params->cipher_xform.next = NULL;
10926 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10927 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10928 ut_params->cipher_xform.cipher.key.data = cipher_key;
10929 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10930 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10931 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10933 /* Create Crypto session*/
10934 ut_params->sess = rte_cryptodev_sym_session_create(
10935 ts_params->session_mpool);
10937 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10939 &ut_params->auth_xform,
10940 ts_params->session_priv_mpool);
10942 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10945 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10946 "Failed to allocate input buffer in mempool");
10948 /* clear mbuf payload */
10949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10950 rte_pktmbuf_tailroom(ut_params->ibuf));
10952 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10953 reference->ciphertext.len);
10954 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10955 memcpy(ciphertext, reference->ciphertext.data,
10956 reference->ciphertext.len);
10958 /* Create operation */
10959 retval = create_cipher_auth_verify_operation(ts_params,
10966 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10967 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10970 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10974 TEST_ASSERT_EQUAL(ut_params->op->status,
10975 RTE_CRYPTO_OP_STATUS_SUCCESS,
10976 "crypto op processing passed");
10978 ut_params->obuf = ut_params->op->sym->m_src;
10979 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10985 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10986 const struct aead_test_data *tdata,
10987 void *digest_mem, uint64_t digest_phys)
10989 struct crypto_testsuite_params *ts_params = &testsuite_params;
10990 struct crypto_unittest_params *ut_params = &unittest_params;
10992 const unsigned int auth_tag_len = tdata->auth_tag.len;
10993 const unsigned int iv_len = tdata->iv.len;
10994 unsigned int aad_len = tdata->aad.len;
10995 unsigned int aad_len_pad = 0;
10997 /* Generate Crypto op data structure */
10998 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10999 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11000 TEST_ASSERT_NOT_NULL(ut_params->op,
11001 "Failed to allocate symmetric crypto operation struct");
11003 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11005 sym_op->aead.digest.data = digest_mem;
11007 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11008 "no room to append digest");
11010 sym_op->aead.digest.phys_addr = digest_phys;
11012 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11013 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11015 debug_hexdump(stdout, "digest:",
11016 sym_op->aead.digest.data,
11020 /* Append aad data */
11021 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11022 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11023 uint8_t *, IV_OFFSET);
11025 /* Copy IV 1 byte after the IV pointer, according to the API */
11026 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11028 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11030 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11031 ut_params->ibuf, aad_len);
11032 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11033 "no room to prepend aad");
11034 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11037 memset(sym_op->aead.aad.data, 0, aad_len);
11038 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
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);
11045 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11046 uint8_t *, IV_OFFSET);
11048 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11050 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11052 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11053 ut_params->ibuf, aad_len_pad);
11054 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11055 "no room to prepend aad");
11056 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11059 memset(sym_op->aead.aad.data, 0, aad_len);
11060 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11062 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11063 debug_hexdump(stdout, "aad:",
11064 sym_op->aead.aad.data, aad_len);
11067 sym_op->aead.data.length = tdata->plaintext.len;
11068 sym_op->aead.data.offset = aad_len_pad;
11073 #define SGL_MAX_NO 16
11076 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11077 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11079 struct crypto_testsuite_params *ts_params = &testsuite_params;
11080 struct crypto_unittest_params *ut_params = &unittest_params;
11081 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11084 int to_trn_tbl[SGL_MAX_NO];
11086 unsigned int trn_data = 0;
11087 uint8_t *plaintext, *ciphertext, *auth_tag;
11088 struct rte_cryptodev_info dev_info;
11090 /* Verify the capabilities */
11091 struct rte_cryptodev_sym_capability_idx cap_idx;
11092 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11093 cap_idx.algo.aead = tdata->algo;
11094 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11098 /* OOP not supported with CPU crypto */
11099 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11102 /* Detailed check for the particular SGL support flag */
11103 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11105 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11106 if (sgl_in && (!(dev_info.feature_flags &
11107 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11110 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11111 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11112 tdata->plaintext.len;
11113 if (sgl_in && !sgl_out) {
11114 if (!(dev_info.feature_flags &
11115 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11117 } else if (!sgl_in && sgl_out) {
11118 if (!(dev_info.feature_flags &
11119 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11121 } else if (sgl_in && sgl_out) {
11122 if (!(dev_info.feature_flags &
11123 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11128 if (fragsz > tdata->plaintext.len)
11129 fragsz = tdata->plaintext.len;
11131 uint16_t plaintext_len = fragsz;
11132 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11134 if (fragsz_oop > tdata->plaintext.len)
11135 frag_size_oop = tdata->plaintext.len;
11138 void *digest_mem = NULL;
11140 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11142 if (tdata->plaintext.len % fragsz != 0) {
11143 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11146 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11151 * For out-op-place we need to alloc another mbuf
11154 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11155 rte_pktmbuf_append(ut_params->obuf,
11156 frag_size_oop + prepend_len);
11157 buf_oop = ut_params->obuf;
11160 /* Create AEAD session */
11161 retval = create_aead_session(ts_params->valid_devs[0],
11163 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11164 tdata->key.data, tdata->key.len,
11165 tdata->aad.len, tdata->auth_tag.len,
11170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11172 /* clear mbuf payload */
11173 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11174 rte_pktmbuf_tailroom(ut_params->ibuf));
11176 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11179 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11181 trn_data += plaintext_len;
11183 buf = ut_params->ibuf;
11186 * Loop until no more fragments
11189 while (trn_data < tdata->plaintext.len) {
11191 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11192 (tdata->plaintext.len - trn_data) : fragsz;
11194 to_trn_tbl[ecx++] = to_trn;
11196 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11199 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11200 rte_pktmbuf_tailroom(buf));
11203 if (oop && !fragsz_oop) {
11204 buf_last_oop = buf_oop->next =
11205 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11206 buf_oop = buf_oop->next;
11207 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11208 0, rte_pktmbuf_tailroom(buf_oop));
11209 rte_pktmbuf_append(buf_oop, to_trn);
11212 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11215 memcpy(plaintext, tdata->plaintext.data + trn_data,
11217 trn_data += to_trn;
11218 if (trn_data == tdata->plaintext.len) {
11221 digest_mem = rte_pktmbuf_append(buf_oop,
11222 tdata->auth_tag.len);
11224 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11225 tdata->auth_tag.len);
11229 uint64_t digest_phys = 0;
11231 ut_params->ibuf->nb_segs = segs;
11234 if (fragsz_oop && oop) {
11238 if (frag_size_oop == tdata->plaintext.len) {
11239 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11240 tdata->auth_tag.len);
11242 digest_phys = rte_pktmbuf_iova_offset(
11244 tdata->plaintext.len + prepend_len);
11247 trn_data = frag_size_oop;
11248 while (trn_data < tdata->plaintext.len) {
11251 (tdata->plaintext.len - trn_data <
11253 (tdata->plaintext.len - trn_data) :
11256 to_trn_tbl[ecx++] = to_trn;
11258 buf_last_oop = buf_oop->next =
11259 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11260 buf_oop = buf_oop->next;
11261 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11262 0, rte_pktmbuf_tailroom(buf_oop));
11263 rte_pktmbuf_append(buf_oop, to_trn);
11265 trn_data += to_trn;
11267 if (trn_data == tdata->plaintext.len) {
11268 digest_mem = rte_pktmbuf_append(buf_oop,
11269 tdata->auth_tag.len);
11273 ut_params->obuf->nb_segs = segs;
11277 * Place digest at the end of the last buffer
11280 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11281 if (oop && buf_last_oop)
11282 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11284 if (!digest_mem && !oop) {
11285 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11286 + tdata->auth_tag.len);
11287 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11288 tdata->plaintext.len);
11291 /* Create AEAD operation */
11292 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11293 tdata, digest_mem, digest_phys);
11298 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11300 ut_params->op->sym->m_src = ut_params->ibuf;
11302 ut_params->op->sym->m_dst = ut_params->obuf;
11304 /* Process crypto operation */
11305 if (oop == IN_PLACE &&
11306 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11307 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11309 TEST_ASSERT_NOT_NULL(
11310 process_crypto_request(ts_params->valid_devs[0],
11311 ut_params->op), "failed to process sym crypto op");
11313 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11314 "crypto op processing failed");
11317 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11318 uint8_t *, prepend_len);
11320 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11321 uint8_t *, prepend_len);
11325 fragsz = fragsz_oop;
11327 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11329 tdata->ciphertext.data,
11331 "Ciphertext data not as expected");
11333 buf = ut_params->op->sym->m_src->next;
11335 buf = ut_params->op->sym->m_dst->next;
11337 unsigned int off = fragsz;
11341 ciphertext = rte_pktmbuf_mtod(buf,
11344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11346 tdata->ciphertext.data + off,
11348 "Ciphertext data not as expected");
11350 off += to_trn_tbl[ecx++];
11354 auth_tag = digest_mem;
11355 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11357 tdata->auth_tag.data,
11358 tdata->auth_tag.len,
11359 "Generated auth tag not as expected");
11365 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11367 return test_authenticated_encryption_SGL(
11368 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11372 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11374 return test_authenticated_encryption_SGL(
11375 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11379 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11381 return test_authenticated_encryption_SGL(
11382 &gcm_test_case_8, OUT_OF_PLACE, 400,
11383 gcm_test_case_8.plaintext.len);
11387 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11389 /* This test is not for OPENSSL PMD */
11390 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11391 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11394 return test_authenticated_encryption_SGL(
11395 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11399 test_authentication_verify_fail_when_data_corrupted(
11400 struct crypto_testsuite_params *ts_params,
11401 struct crypto_unittest_params *ut_params,
11402 const struct test_crypto_vector *reference)
11404 return test_authentication_verify_fail_when_data_corruption(
11405 ts_params, ut_params, reference, 1);
11409 test_authentication_verify_fail_when_tag_corrupted(
11410 struct crypto_testsuite_params *ts_params,
11411 struct crypto_unittest_params *ut_params,
11412 const struct test_crypto_vector *reference)
11414 return test_authentication_verify_fail_when_data_corruption(
11415 ts_params, ut_params, reference, 0);
11419 test_authentication_verify_GMAC_fail_when_data_corrupted(
11420 struct crypto_testsuite_params *ts_params,
11421 struct crypto_unittest_params *ut_params,
11422 const struct test_crypto_vector *reference)
11424 return test_authentication_verify_GMAC_fail_when_corruption(
11425 ts_params, ut_params, reference, 1);
11429 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11430 struct crypto_testsuite_params *ts_params,
11431 struct crypto_unittest_params *ut_params,
11432 const struct test_crypto_vector *reference)
11434 return test_authentication_verify_GMAC_fail_when_corruption(
11435 ts_params, ut_params, reference, 0);
11439 test_authenticated_decryption_fail_when_data_corrupted(
11440 struct crypto_testsuite_params *ts_params,
11441 struct crypto_unittest_params *ut_params,
11442 const struct test_crypto_vector *reference)
11444 return test_authenticated_decryption_fail_when_corruption(
11445 ts_params, ut_params, reference, 1);
11449 test_authenticated_decryption_fail_when_tag_corrupted(
11450 struct crypto_testsuite_params *ts_params,
11451 struct crypto_unittest_params *ut_params,
11452 const struct test_crypto_vector *reference)
11454 return test_authenticated_decryption_fail_when_corruption(
11455 ts_params, ut_params, reference, 0);
11459 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11461 return test_authentication_verify_fail_when_data_corrupted(
11462 &testsuite_params, &unittest_params,
11463 &hmac_sha1_test_crypto_vector);
11467 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11469 return test_authentication_verify_fail_when_tag_corrupted(
11470 &testsuite_params, &unittest_params,
11471 &hmac_sha1_test_crypto_vector);
11475 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11477 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11478 &testsuite_params, &unittest_params,
11479 &aes128_gmac_test_vector);
11483 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11485 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11486 &testsuite_params, &unittest_params,
11487 &aes128_gmac_test_vector);
11491 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11493 return test_authenticated_decryption_fail_when_data_corrupted(
11496 &aes128cbc_hmac_sha1_test_vector);
11500 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11502 return test_authenticated_decryption_fail_when_tag_corrupted(
11505 &aes128cbc_hmac_sha1_test_vector);
11509 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11511 return test_authenticated_encryt_with_esn(
11514 &aes128cbc_hmac_sha1_aad_test_vector);
11518 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11520 return test_authenticated_decrypt_with_esn(
11523 &aes128cbc_hmac_sha1_aad_test_vector);
11526 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11528 /* global AESNI slave IDs for the scheduler test */
11529 uint8_t aesni_ids[2];
11532 test_scheduler_attach_slave_op(void)
11534 struct crypto_testsuite_params *ts_params = &testsuite_params;
11535 uint8_t sched_id = ts_params->valid_devs[0];
11536 uint32_t nb_devs, i, nb_devs_attached = 0;
11538 char vdev_name[32];
11540 /* create 2 AESNI_MB if necessary */
11541 nb_devs = rte_cryptodev_device_count_by_driver(
11542 rte_cryptodev_driver_id_get(
11543 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11545 for (i = nb_devs; i < 2; i++) {
11546 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11547 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11549 ret = rte_vdev_init(vdev_name, NULL);
11551 TEST_ASSERT(ret == 0,
11552 "Failed to create instance %u of"
11554 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11558 /* attach 2 AESNI_MB cdevs */
11559 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11561 struct rte_cryptodev_info info;
11562 unsigned int session_size;
11564 rte_cryptodev_info_get(i, &info);
11565 if (info.driver_id != rte_cryptodev_driver_id_get(
11566 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11569 session_size = rte_cryptodev_sym_get_private_session_size(i);
11571 * Create the session mempool again, since now there are new devices
11572 * to use the mempool.
11574 if (ts_params->session_mpool) {
11575 rte_mempool_free(ts_params->session_mpool);
11576 ts_params->session_mpool = NULL;
11578 if (ts_params->session_priv_mpool) {
11579 rte_mempool_free(ts_params->session_priv_mpool);
11580 ts_params->session_priv_mpool = NULL;
11583 if (info.sym.max_nb_sessions != 0 &&
11584 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11585 RTE_LOG(ERR, USER1,
11586 "Device does not support "
11587 "at least %u sessions\n",
11589 return TEST_FAILED;
11592 * Create mempool with maximum number of sessions,
11593 * to include the session headers
11595 if (ts_params->session_mpool == NULL) {
11596 ts_params->session_mpool =
11597 rte_cryptodev_sym_session_pool_create(
11599 MAX_NB_SESSIONS, 0, 0, 0,
11601 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11602 "session mempool allocation failed");
11606 * Create mempool with maximum number of sessions,
11607 * to include device specific session private data
11609 if (ts_params->session_priv_mpool == NULL) {
11610 ts_params->session_priv_mpool = rte_mempool_create(
11611 "test_sess_mp_priv",
11614 0, 0, NULL, NULL, NULL,
11615 NULL, SOCKET_ID_ANY,
11618 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11619 "session mempool allocation failed");
11622 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11623 ts_params->qp_conf.mp_session_private =
11624 ts_params->session_priv_mpool;
11626 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11629 TEST_ASSERT(ret == 0,
11630 "Failed to attach device %u of pmd : %s", i,
11631 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11633 aesni_ids[nb_devs_attached] = (uint8_t)i;
11635 nb_devs_attached++;
11642 test_scheduler_detach_slave_op(void)
11644 struct crypto_testsuite_params *ts_params = &testsuite_params;
11645 uint8_t sched_id = ts_params->valid_devs[0];
11649 for (i = 0; i < 2; i++) {
11650 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11652 TEST_ASSERT(ret == 0,
11653 "Failed to detach device %u", aesni_ids[i]);
11660 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11662 struct crypto_testsuite_params *ts_params = &testsuite_params;
11663 uint8_t sched_id = ts_params->valid_devs[0];
11665 return rte_cryptodev_scheduler_mode_set(sched_id,
11670 test_scheduler_mode_roundrobin_op(void)
11672 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11673 0, "Failed to set roundrobin mode");
11679 test_scheduler_mode_multicore_op(void)
11681 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11682 0, "Failed to set multicore mode");
11688 test_scheduler_mode_failover_op(void)
11690 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11691 0, "Failed to set failover mode");
11697 test_scheduler_mode_pkt_size_distr_op(void)
11699 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11700 0, "Failed to set pktsize mode");
11705 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11706 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11707 .setup = testsuite_setup,
11708 .teardown = testsuite_teardown,
11709 .unit_test_cases = {
11711 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11712 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11713 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11714 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11715 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11716 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11719 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11720 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11721 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11722 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11723 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11724 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11727 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11728 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11729 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11730 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11731 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11732 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11735 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11736 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11737 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11738 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11739 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11740 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11742 TEST_CASES_END() /**< NULL terminate unit test array */
11746 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11748 static struct unit_test_suite cryptodev_testsuite = {
11749 .suite_name = "Crypto Unit Test Suite",
11750 .setup = testsuite_setup,
11751 .teardown = testsuite_teardown,
11752 .unit_test_cases = {
11753 TEST_CASE_ST(ut_setup, ut_teardown,
11754 test_device_configure_invalid_dev_id),
11755 TEST_CASE_ST(ut_setup, ut_teardown,
11756 test_device_configure_invalid_queue_pair_ids),
11757 TEST_CASE_ST(ut_setup, ut_teardown,
11758 test_queue_pair_descriptor_setup),
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_multi_session),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_multi_session_random_usage),
11765 TEST_CASE_ST(ut_setup, ut_teardown,
11766 test_null_invalid_operation),
11767 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11769 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11770 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11771 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11772 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11773 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11774 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11775 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11776 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11777 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11779 /** AES CCM Authenticated Encryption 128 bits key */
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_CCM_authenticated_encryption_test_case_128_1),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_CCM_authenticated_encryption_test_case_128_2),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_CCM_authenticated_encryption_test_case_128_3),
11787 /** AES CCM Authenticated Decryption 128 bits key*/
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_CCM_authenticated_decryption_test_case_128_1),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_CCM_authenticated_decryption_test_case_128_2),
11792 TEST_CASE_ST(ut_setup, ut_teardown,
11793 test_AES_CCM_authenticated_decryption_test_case_128_3),
11795 /** AES CCM Authenticated Encryption 192 bits key */
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_CCM_authenticated_encryption_test_case_192_1),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_CCM_authenticated_encryption_test_case_192_2),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_AES_CCM_authenticated_encryption_test_case_192_3),
11803 /** AES CCM Authenticated Decryption 192 bits key*/
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_CCM_authenticated_decryption_test_case_192_1),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_CCM_authenticated_decryption_test_case_192_2),
11808 TEST_CASE_ST(ut_setup, ut_teardown,
11809 test_AES_CCM_authenticated_decryption_test_case_192_3),
11811 /** AES CCM Authenticated Encryption 256 bits key */
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_CCM_authenticated_encryption_test_case_256_1),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_CCM_authenticated_encryption_test_case_256_2),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_CCM_authenticated_encryption_test_case_256_3),
11819 /** AES CCM Authenticated Decryption 256 bits key*/
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_CCM_authenticated_decryption_test_case_256_1),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_CCM_authenticated_decryption_test_case_256_2),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_AES_CCM_authenticated_decryption_test_case_256_3),
11827 /** AES GCM Authenticated Encryption */
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_GCM_authenticated_encryption_test_case_1),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_AES_GCM_authenticated_encryption_test_case_2),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_AES_GCM_authenticated_encryption_test_case_3),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_authenticated_encryption_test_case_4),
11844 TEST_CASE_ST(ut_setup, ut_teardown,
11845 test_AES_GCM_authenticated_encryption_test_case_5),
11846 TEST_CASE_ST(ut_setup, ut_teardown,
11847 test_AES_GCM_authenticated_encryption_test_case_6),
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GCM_authenticated_encryption_test_case_7),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GCM_authenticated_encryption_test_case_8),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11855 /** AES GCM Authenticated Decryption */
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_AES_GCM_authenticated_decryption_test_case_1),
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_AES_GCM_authenticated_decryption_test_case_2),
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_GCM_authenticated_decryption_test_case_3),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_AES_GCM_authenticated_decryption_test_case_4),
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_AES_GCM_authenticated_decryption_test_case_5),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_AES_GCM_authenticated_decryption_test_case_6),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_AES_GCM_authenticated_decryption_test_case_7),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_GCM_authenticated_decryption_test_case_8),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11875 /** AES GCM Authenticated Encryption 192 bits key */
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_GCM_auth_encryption_test_case_192_1),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_GCM_auth_encryption_test_case_192_2),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_AES_GCM_auth_encryption_test_case_192_3),
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_AES_GCM_auth_encryption_test_case_192_4),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_AES_GCM_auth_encryption_test_case_192_5),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_AES_GCM_auth_encryption_test_case_192_6),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_AES_GCM_auth_encryption_test_case_192_7),
11891 /** AES GCM Authenticated Decryption 192 bits key */
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_AES_GCM_auth_decryption_test_case_192_1),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_GCM_auth_decryption_test_case_192_2),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_GCM_auth_decryption_test_case_192_3),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_GCM_auth_decryption_test_case_192_4),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_GCM_auth_decryption_test_case_192_5),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_GCM_auth_decryption_test_case_192_6),
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_AES_GCM_auth_decryption_test_case_192_7),
11907 /** AES GCM Authenticated Encryption 256 bits key */
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_AES_GCM_auth_encryption_test_case_256_1),
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_AES_GCM_auth_encryption_test_case_256_2),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_GCM_auth_encryption_test_case_256_3),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_AES_GCM_auth_encryption_test_case_256_4),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 test_AES_GCM_auth_encryption_test_case_256_5),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_AES_GCM_auth_encryption_test_case_256_6),
11920 TEST_CASE_ST(ut_setup, ut_teardown,
11921 test_AES_GCM_auth_encryption_test_case_256_7),
11923 /** AES GCM Authenticated Decryption 256 bits key */
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_AES_GCM_auth_decryption_test_case_256_1),
11926 TEST_CASE_ST(ut_setup, ut_teardown,
11927 test_AES_GCM_auth_decryption_test_case_256_2),
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_AES_GCM_auth_decryption_test_case_256_3),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_AES_GCM_auth_decryption_test_case_256_4),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_AES_GCM_auth_decryption_test_case_256_5),
11934 TEST_CASE_ST(ut_setup, ut_teardown,
11935 test_AES_GCM_auth_decryption_test_case_256_6),
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_AES_GCM_auth_decryption_test_case_256_7),
11939 /** AES GCM Authenticated Encryption big aad size */
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_AES_GCM_auth_encryption_test_case_aad_1),
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_AES_GCM_auth_encryption_test_case_aad_2),
11945 /** AES GCM Authenticated Decryption big aad size */
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_AES_GCM_auth_decryption_test_case_aad_1),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GCM_auth_decryption_test_case_aad_2),
11951 /** Out of place tests */
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11957 /** Session-less tests */
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11963 /** AES GMAC Authentication */
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_AES_GMAC_authentication_test_case_1),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_AES_GMAC_authentication_verify_test_case_1),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_AES_GMAC_authentication_test_case_2),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_AES_GMAC_authentication_verify_test_case_2),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_AES_GMAC_authentication_test_case_3),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_AES_GMAC_authentication_verify_test_case_3),
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_AES_GMAC_authentication_test_case_4),
11978 TEST_CASE_ST(ut_setup, ut_teardown,
11979 test_AES_GMAC_authentication_verify_test_case_4),
11981 /** SNOW 3G encrypt only (UEA2) */
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_snow3g_encryption_test_case_1),
11984 TEST_CASE_ST(ut_setup, ut_teardown,
11985 test_snow3g_encryption_test_case_2),
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_snow3g_encryption_test_case_3),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_snow3g_encryption_test_case_4),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_snow3g_encryption_test_case_5),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_snow3g_encryption_test_case_1_oop),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_snow3g_encryption_test_case_1_oop_sgl),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_snow3g_encryption_test_case_1_offset_oop),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_decryption_test_case_1_oop),
12002 /** SNOW 3G generate auth, then encrypt (UEA2) */
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_auth_cipher_test_case_1),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_snow3g_auth_cipher_test_case_2),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_auth_cipher_test_case_2_oop),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_snow3g_auth_cipher_part_digest_enc),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_snow3g_auth_cipher_part_digest_enc_oop),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_snow3g_auth_cipher_test_case_3_sgl),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_snow3g_auth_cipher_part_digest_enc_sgl),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12022 /** SNOW 3G decrypt (UEA2), then verify auth */
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_snow3g_auth_cipher_verify_test_case_1),
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_snow3g_auth_cipher_verify_test_case_2),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_snow3g_auth_cipher_verify_test_case_2_oop),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_snow3g_auth_cipher_verify_part_digest_enc),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12042 /** SNOW 3G decrypt only (UEA2) */
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_snow3g_decryption_test_case_1),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_snow3g_decryption_test_case_2),
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_snow3g_decryption_test_case_3),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_snow3g_decryption_test_case_4),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_snow3g_decryption_test_case_5),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_snow3g_decryption_with_digest_test_case_1),
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_snow3g_hash_generate_test_case_1),
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_snow3g_hash_generate_test_case_2),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_snow3g_hash_generate_test_case_3),
12061 /* Tests with buffers which length is not byte-aligned */
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_hash_generate_test_case_4),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_hash_generate_test_case_5),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_hash_generate_test_case_6),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_hash_verify_test_case_1),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_hash_verify_test_case_2),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_hash_verify_test_case_3),
12074 /* Tests with buffers which length is not byte-aligned */
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_snow3g_hash_verify_test_case_4),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_snow3g_hash_verify_test_case_5),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_snow3g_hash_verify_test_case_6),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_cipher_auth_test_case_1),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_auth_cipher_with_digest_test_case_1),
12086 /** ZUC encrypt only (EEA3) */
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_zuc_encryption_test_case_1),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_zuc_encryption_test_case_2),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_zuc_encryption_test_case_3),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_zuc_encryption_test_case_4),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_zuc_encryption_test_case_5),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_zuc_encryption_test_case_6_sgl),
12100 /** ZUC authenticate (EIA3) */
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_zuc_hash_generate_test_case_1),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_zuc_hash_generate_test_case_2),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_zuc_hash_generate_test_case_3),
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_zuc_hash_generate_test_case_4),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_zuc_hash_generate_test_case_5),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_zuc_hash_generate_test_case_6),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_zuc_hash_generate_test_case_7),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_zuc_hash_generate_test_case_8),
12118 /** ZUC alg-chain (EEA3/EIA3) */
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_zuc_cipher_auth_test_case_1),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_zuc_cipher_auth_test_case_2),
12124 /** ZUC generate auth, then encrypt (EEA3) */
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_zuc_auth_cipher_test_case_1),
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_zuc_auth_cipher_test_case_1_oop),
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_zuc_auth_cipher_test_case_1_sgl),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_zuc_auth_cipher_test_case_1_oop_sgl),
12134 /** ZUC decrypt (EEA3), then verify auth */
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_zuc_auth_cipher_verify_test_case_1),
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_zuc_auth_cipher_verify_test_case_1_oop),
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_zuc_auth_cipher_verify_test_case_1_sgl),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12144 /** HMAC_MD5 Authentication */
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_MD5_HMAC_generate_case_1),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_MD5_HMAC_verify_case_1),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_MD5_HMAC_generate_case_2),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_MD5_HMAC_verify_case_2),
12154 /** KASUMI hash only (UIA1) */
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_kasumi_hash_generate_test_case_1),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_kasumi_hash_generate_test_case_2),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_kasumi_hash_generate_test_case_3),
12161 TEST_CASE_ST(ut_setup, ut_teardown,
12162 test_kasumi_hash_generate_test_case_4),
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_kasumi_hash_generate_test_case_5),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_kasumi_hash_generate_test_case_6),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_kasumi_hash_verify_test_case_1),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_kasumi_hash_verify_test_case_2),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_hash_verify_test_case_3),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_hash_verify_test_case_4),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_hash_verify_test_case_5),
12179 /** KASUMI encrypt only (UEA1) */
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_kasumi_encryption_test_case_1),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_encryption_test_case_1_sgl),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_kasumi_encryption_test_case_1_oop),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_kasumi_encryption_test_case_1_oop_sgl),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_kasumi_encryption_test_case_2),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_kasumi_encryption_test_case_3),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_kasumi_encryption_test_case_4),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_kasumi_encryption_test_case_5),
12197 /** KASUMI decrypt only (UEA1) */
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_kasumi_decryption_test_case_1),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_kasumi_decryption_test_case_2),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_kasumi_decryption_test_case_3),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_kasumi_decryption_test_case_4),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_kasumi_decryption_test_case_5),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_kasumi_decryption_test_case_1_oop),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_cipher_auth_test_case_1),
12214 /** KASUMI generate auth, then encrypt (F8) */
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_auth_cipher_test_case_1),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_auth_cipher_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_auth_cipher_test_case_2_oop),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_auth_cipher_test_case_2_sgl),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12226 /** KASUMI decrypt (F8), then verify auth */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_auth_cipher_verify_test_case_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_kasumi_auth_cipher_verify_test_case_2),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_auth_cipher_verify_test_case_2_oop),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12238 /** ESN Testcase */
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12244 /** Negative tests */
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 authentication_verify_AES128_GMAC_fail_data_corrupt),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12282 /** Mixed CIPHER + HASH algorithms */
12283 /** AUTH AES CMAC + CIPHER AES CTR */
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12301 /** AUTH ZUC + CIPHER SNOW3G */
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_auth_zuc_cipher_snow_test_case_1),
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 test_verify_auth_zuc_cipher_snow_test_case_1),
12306 /** AUTH AES CMAC + CIPHER SNOW3G */
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_auth_aes_cmac_cipher_snow_test_case_1),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12311 /** AUTH ZUC + CIPHER AES CTR */
12312 TEST_CASE_ST(ut_setup, ut_teardown,
12313 test_auth_zuc_cipher_aes_ctr_test_case_1),
12314 TEST_CASE_ST(ut_setup, ut_teardown,
12315 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12316 /** AUTH SNOW3G + CIPHER AES CTR */
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_auth_snow_cipher_aes_ctr_test_case_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12321 /** AUTH SNOW3G + CIPHER ZUC */
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 test_auth_snow_cipher_zuc_test_case_1),
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 test_verify_auth_snow_cipher_zuc_test_case_1),
12326 /** AUTH AES CMAC + CIPHER ZUC */
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_auth_aes_cmac_cipher_zuc_test_case_1),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12332 /** AUTH NULL + CIPHER SNOW3G */
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_auth_null_cipher_snow_test_case_1),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_verify_auth_null_cipher_snow_test_case_1),
12337 /** AUTH NULL + CIPHER ZUC */
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_auth_null_cipher_zuc_test_case_1),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_verify_auth_null_cipher_zuc_test_case_1),
12342 /** AUTH SNOW3G + CIPHER NULL */
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_auth_snow_cipher_null_test_case_1),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_verify_auth_snow_cipher_null_test_case_1),
12347 /** AUTH ZUC + CIPHER NULL */
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_auth_zuc_cipher_null_test_case_1),
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_verify_auth_zuc_cipher_null_test_case_1),
12352 /** AUTH NULL + CIPHER AES CTR */
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_auth_null_cipher_aes_ctr_test_case_1),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12357 /** AUTH AES CMAC + CIPHER NULL */
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_auth_aes_cmac_cipher_null_test_case_1),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12363 TEST_CASES_END() /**< NULL terminate unit test array */
12367 static struct unit_test_suite cryptodev_virtio_testsuite = {
12368 .suite_name = "Crypto VIRTIO Unit Test Suite",
12369 .setup = testsuite_setup,
12370 .teardown = testsuite_teardown,
12371 .unit_test_cases = {
12372 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12374 TEST_CASES_END() /**< NULL terminate unit test array */
12378 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12379 .suite_name = "Crypto CAAM JR Unit Test Suite",
12380 .setup = testsuite_setup,
12381 .teardown = testsuite_teardown,
12382 .unit_test_cases = {
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_device_configure_invalid_dev_id),
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_multi_session),
12388 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12389 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12390 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12391 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12392 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12394 TEST_CASES_END() /**< NULL terminate unit test array */
12398 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12399 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12400 .setup = testsuite_setup,
12401 .teardown = testsuite_teardown,
12402 .unit_test_cases = {
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_device_configure_invalid_dev_id),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_multi_session),
12408 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12409 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12410 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12411 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12412 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12414 #ifdef RTE_LIBRTE_SECURITY
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_PDCP_PROTO_cplane_encap_all),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_PDCP_PROTO_cplane_decap_all),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_PDCP_PROTO_uplane_encap_all),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_PDCP_PROTO_uplane_decap_all),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_PDCP_PROTO_SGL_in_place_32B),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_PDCP_PROTO_SGL_oop_32B_128B),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_PDCP_PROTO_SGL_oop_32B_40B),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_PDCP_PROTO_SGL_oop_128B_32B),
12436 /** AES GCM Authenticated Encryption */
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_AES_GCM_authenticated_encryption_test_case_1),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_AES_GCM_authenticated_encryption_test_case_2),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_AES_GCM_authenticated_encryption_test_case_3),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_AES_GCM_authenticated_encryption_test_case_4),
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_AES_GCM_authenticated_encryption_test_case_5),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_AES_GCM_authenticated_encryption_test_case_6),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_AES_GCM_authenticated_encryption_test_case_7),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_GCM_authenticated_encryption_test_case_8),
12462 /** AES GCM Authenticated Decryption */
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_AES_GCM_authenticated_decryption_test_case_1),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_AES_GCM_authenticated_decryption_test_case_2),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_AES_GCM_authenticated_decryption_test_case_3),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_AES_GCM_authenticated_decryption_test_case_4),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_GCM_authenticated_decryption_test_case_5),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_AES_GCM_authenticated_decryption_test_case_6),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_AES_GCM_authenticated_decryption_test_case_7),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_AES_GCM_authenticated_decryption_test_case_8),
12480 /** AES GCM Authenticated Encryption 192 bits key */
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_AES_GCM_auth_encryption_test_case_192_1),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_AES_GCM_auth_encryption_test_case_192_2),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_AES_GCM_auth_encryption_test_case_192_3),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_AES_GCM_auth_encryption_test_case_192_4),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_AES_GCM_auth_encryption_test_case_192_5),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_AES_GCM_auth_encryption_test_case_192_6),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_AES_GCM_auth_encryption_test_case_192_7),
12496 /** AES GCM Authenticated Decryption 192 bits key */
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_AES_GCM_auth_decryption_test_case_192_1),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_AES_GCM_auth_decryption_test_case_192_2),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_AES_GCM_auth_decryption_test_case_192_3),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_GCM_auth_decryption_test_case_192_4),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_AES_GCM_auth_decryption_test_case_192_5),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_GCM_auth_decryption_test_case_192_6),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_AES_GCM_auth_decryption_test_case_192_7),
12512 /** AES GCM Authenticated Encryption 256 bits key */
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_AES_GCM_auth_encryption_test_case_256_1),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_AES_GCM_auth_encryption_test_case_256_2),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_AES_GCM_auth_encryption_test_case_256_3),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_AES_GCM_auth_encryption_test_case_256_4),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_AES_GCM_auth_encryption_test_case_256_5),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_AES_GCM_auth_encryption_test_case_256_6),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_AES_GCM_auth_encryption_test_case_256_7),
12528 /** AES GCM Authenticated Decryption 256 bits key */
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_AES_GCM_auth_decryption_test_case_256_1),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_AES_GCM_auth_decryption_test_case_256_2),
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_AES_GCM_auth_decryption_test_case_256_3),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_AES_GCM_auth_decryption_test_case_256_4),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_AES_GCM_auth_decryption_test_case_256_5),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_AES_GCM_auth_decryption_test_case_256_6),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_AES_GCM_auth_decryption_test_case_256_7),
12544 /** Out of place tests */
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12550 /** SNOW 3G encrypt only (UEA2) */
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_snow3g_encryption_test_case_1),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_snow3g_encryption_test_case_2),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_snow3g_encryption_test_case_3),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_snow3g_encryption_test_case_4),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_snow3g_encryption_test_case_5),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_snow3g_encryption_test_case_1_oop),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_snow3g_encryption_test_case_1_oop_sgl),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_snow3g_decryption_test_case_1_oop),
12569 /** SNOW 3G decrypt only (UEA2) */
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_snow3g_decryption_test_case_1),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_decryption_test_case_2),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_decryption_test_case_3),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_decryption_test_case_4),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_snow3g_decryption_test_case_5),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_snow3g_hash_generate_test_case_1),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_snow3g_hash_generate_test_case_2),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_snow3g_hash_generate_test_case_3),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_snow3g_hash_verify_test_case_1),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_snow3g_hash_verify_test_case_2),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_snow3g_hash_verify_test_case_3),
12594 /** ZUC encrypt only (EEA3) */
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_zuc_encryption_test_case_1),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_zuc_encryption_test_case_2),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_zuc_encryption_test_case_3),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_zuc_encryption_test_case_4),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_zuc_encryption_test_case_5),
12606 /** ZUC authenticate (EIA3) */
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_zuc_hash_generate_test_case_6),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_zuc_hash_generate_test_case_7),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_zuc_hash_generate_test_case_8),
12614 /** Negative tests */
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12621 TEST_CASE_ST(ut_setup, ut_teardown,
12622 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12654 TEST_CASES_END() /**< NULL terminate unit test array */
12658 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12659 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12660 .setup = testsuite_setup,
12661 .teardown = testsuite_teardown,
12662 .unit_test_cases = {
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_device_configure_invalid_dev_id),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_multi_session),
12667 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12668 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12669 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12670 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12671 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12673 #ifdef RTE_LIBRTE_SECURITY
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 test_PDCP_PROTO_cplane_encap_all),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_PDCP_PROTO_cplane_decap_all),
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_PDCP_PROTO_uplane_encap_all),
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 test_PDCP_PROTO_uplane_decap_all),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_PDCP_PROTO_SGL_in_place_32B),
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_PDCP_PROTO_SGL_oop_32B_128B),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_PDCP_PROTO_SGL_oop_32B_40B),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_PDCP_PROTO_SGL_oop_128B_32B),
12695 /** AES GCM Authenticated Encryption */
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_authenticated_encryption_test_case_1),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_authenticated_encryption_test_case_2),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_authenticated_encryption_test_case_3),
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_AES_GCM_authenticated_encryption_test_case_4),
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_AES_GCM_authenticated_encryption_test_case_5),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_authenticated_encryption_test_case_6),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_authenticated_encryption_test_case_7),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_AES_GCM_authenticated_encryption_test_case_8),
12721 /** AES GCM Authenticated Decryption */
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_authenticated_decryption_test_case_1),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_AES_GCM_authenticated_decryption_test_case_2),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 test_AES_GCM_authenticated_decryption_test_case_3),
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 test_AES_GCM_authenticated_decryption_test_case_4),
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 test_AES_GCM_authenticated_decryption_test_case_5),
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_AES_GCM_authenticated_decryption_test_case_6),
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_AES_GCM_authenticated_decryption_test_case_7),
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_AES_GCM_authenticated_decryption_test_case_8),
12739 /** AES GCM Authenticated Encryption 192 bits key */
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_AES_GCM_auth_encryption_test_case_192_1),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_AES_GCM_auth_encryption_test_case_192_2),
12744 TEST_CASE_ST(ut_setup, ut_teardown,
12745 test_AES_GCM_auth_encryption_test_case_192_3),
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_AES_GCM_auth_encryption_test_case_192_4),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_AES_GCM_auth_encryption_test_case_192_5),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_AES_GCM_auth_encryption_test_case_192_6),
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_AES_GCM_auth_encryption_test_case_192_7),
12755 /** AES GCM Authenticated Decryption 192 bits key */
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_AES_GCM_auth_decryption_test_case_192_1),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_AES_GCM_auth_decryption_test_case_192_2),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_AES_GCM_auth_decryption_test_case_192_3),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_AES_GCM_auth_decryption_test_case_192_4),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_AES_GCM_auth_decryption_test_case_192_5),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_AES_GCM_auth_decryption_test_case_192_6),
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_AES_GCM_auth_decryption_test_case_192_7),
12771 /** AES GCM Authenticated Encryption 256 bits key */
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_AES_GCM_auth_encryption_test_case_256_1),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GCM_auth_encryption_test_case_256_2),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_AES_GCM_auth_encryption_test_case_256_3),
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_AES_GCM_auth_encryption_test_case_256_4),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GCM_auth_encryption_test_case_256_5),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_AES_GCM_auth_encryption_test_case_256_6),
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_AES_GCM_auth_encryption_test_case_256_7),
12787 /** AES GCM Authenticated Decryption 256 bits key */
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_AES_GCM_auth_decryption_test_case_256_1),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_AES_GCM_auth_decryption_test_case_256_2),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_GCM_auth_decryption_test_case_256_3),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_AES_GCM_auth_decryption_test_case_256_4),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_AES_GCM_auth_decryption_test_case_256_5),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_AES_GCM_auth_decryption_test_case_256_6),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_AES_GCM_auth_decryption_test_case_256_7),
12803 /** Out of place tests */
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12809 /** SNOW 3G encrypt only (UEA2) */
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_snow3g_encryption_test_case_1),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_snow3g_encryption_test_case_2),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_snow3g_encryption_test_case_3),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_snow3g_encryption_test_case_4),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_snow3g_encryption_test_case_5),
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 test_snow3g_encryption_test_case_1_oop),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_snow3g_encryption_test_case_1_oop_sgl),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_snow3g_decryption_test_case_1_oop),
12828 /** SNOW 3G decrypt only (UEA2) */
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_decryption_test_case_1),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_snow3g_decryption_test_case_2),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_snow3g_decryption_test_case_3),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_snow3g_decryption_test_case_4),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_snow3g_decryption_test_case_5),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_snow3g_hash_generate_test_case_1),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_snow3g_hash_generate_test_case_2),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_snow3g_hash_generate_test_case_3),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_snow3g_hash_verify_test_case_1),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_snow3g_hash_verify_test_case_2),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_snow3g_hash_verify_test_case_3),
12853 /** ZUC encrypt only (EEA3) */
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_zuc_encryption_test_case_1),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_zuc_encryption_test_case_2),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_zuc_encryption_test_case_3),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_zuc_encryption_test_case_4),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_zuc_encryption_test_case_5),
12865 /** ZUC authenticate (EIA3) */
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_zuc_hash_generate_test_case_6),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_zuc_hash_generate_test_case_7),
12870 TEST_CASE_ST(ut_setup, ut_teardown,
12871 test_zuc_hash_generate_test_case_8),
12873 /** HMAC_MD5 Authentication */
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_MD5_HMAC_generate_case_1),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_MD5_HMAC_verify_case_1),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_MD5_HMAC_generate_case_2),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_MD5_HMAC_verify_case_2),
12883 /** Negative tests */
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12924 TEST_CASES_END() /**< NULL terminate unit test array */
12928 static struct unit_test_suite cryptodev_armv8_testsuite = {
12929 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12930 .setup = testsuite_setup,
12931 .teardown = testsuite_teardown,
12932 .unit_test_cases = {
12933 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12935 /** Negative tests */
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12938 TEST_CASE_ST(ut_setup, ut_teardown,
12939 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12941 TEST_CASES_END() /**< NULL terminate unit test array */
12945 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12946 .suite_name = "Crypto Device Marvell Component Test Suite",
12947 .setup = testsuite_setup,
12948 .teardown = testsuite_teardown,
12949 .unit_test_cases = {
12950 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_multi_session_random_usage),
12953 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12954 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12955 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12956 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12957 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12959 /** Negative tests */
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12969 TEST_CASES_END() /**< NULL terminate unit test array */
12973 static struct unit_test_suite cryptodev_ccp_testsuite = {
12974 .suite_name = "Crypto Device CCP Unit Test Suite",
12975 .setup = testsuite_setup,
12976 .teardown = testsuite_teardown,
12977 .unit_test_cases = {
12978 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_multi_session_random_usage),
12981 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12982 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12983 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12984 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12985 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12987 /** Negative tests */
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12997 TEST_CASES_END() /**< NULL terminate unit test array */
13001 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13002 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13003 .setup = testsuite_setup,
13004 .teardown = testsuite_teardown,
13005 .unit_test_cases = {
13006 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13007 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13008 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13009 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13010 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13012 /** AES GCM Authenticated Encryption */
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_AES_GCM_authenticated_encryption_test_case_1),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_authenticated_encryption_test_case_2),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_authenticated_encryption_test_case_3),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_authenticated_encryption_test_case_4),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_authenticated_encryption_test_case_5),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_authenticated_encryption_test_case_6),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_AES_GCM_authenticated_encryption_test_case_7),
13028 /** AES GCM Authenticated Decryption */
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_AES_GCM_authenticated_decryption_test_case_1),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_AES_GCM_authenticated_decryption_test_case_2),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_AES_GCM_authenticated_decryption_test_case_3),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_AES_GCM_authenticated_decryption_test_case_4),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_AES_GCM_authenticated_decryption_test_case_5),
13039 TEST_CASE_ST(ut_setup, ut_teardown,
13040 test_AES_GCM_authenticated_decryption_test_case_6),
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_AES_GCM_authenticated_decryption_test_case_7),
13043 /** AES GMAC Authentication */
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GMAC_authentication_test_case_1),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_AES_GMAC_authentication_verify_test_case_1),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GMAC_authentication_test_case_2),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GMAC_authentication_verify_test_case_2),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GMAC_authentication_test_case_3),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GMAC_authentication_verify_test_case_3),
13057 /** SNOW 3G encrypt only (UEA2) */
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_snow3g_encryption_test_case_1),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_snow3g_encryption_test_case_2),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_snow3g_encryption_test_case_3),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_snow3g_encryption_test_case_4),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_snow3g_encryption_test_case_5),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_snow3g_encryption_test_case_1_oop),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_snow3g_decryption_test_case_1_oop),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_snow3g_encryption_test_case_1_oop_sgl),
13076 /** SNOW 3G decrypt only (UEA2) */
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_snow3g_decryption_test_case_1),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_decryption_test_case_2),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_snow3g_decryption_test_case_3),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_snow3g_decryption_test_case_4),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_snow3g_decryption_test_case_5),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_snow3g_hash_generate_test_case_1),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_snow3g_hash_generate_test_case_2),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_snow3g_hash_generate_test_case_3),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_snow3g_hash_verify_test_case_1),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_snow3g_hash_verify_test_case_2),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_snow3g_hash_verify_test_case_3),
13101 /** ZUC encrypt only (EEA3) */
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_zuc_encryption_test_case_1),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_zuc_encryption_test_case_2),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_zuc_encryption_test_case_3),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_zuc_encryption_test_case_4),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_zuc_encryption_test_case_5),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_zuc_hash_generate_test_case_1),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_zuc_hash_generate_test_case_2),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_zuc_hash_generate_test_case_3),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_zuc_hash_generate_test_case_4),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_zuc_hash_generate_test_case_5),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_zuc_encryption_test_case_6_sgl),
13125 /** KASUMI encrypt only (UEA1) */
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_kasumi_encryption_test_case_1),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_kasumi_encryption_test_case_2),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_kasumi_encryption_test_case_3),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_kasumi_encryption_test_case_4),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_kasumi_encryption_test_case_5),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_kasumi_encryption_test_case_1_sgl),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_kasumi_encryption_test_case_1_oop_sgl),
13140 /** KASUMI decrypt only (UEA1) */
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_kasumi_decryption_test_case_1),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_kasumi_decryption_test_case_2),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_kasumi_decryption_test_case_3),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_kasumi_decryption_test_case_4),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_kasumi_decryption_test_case_5),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_kasumi_encryption_test_case_1_oop),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_kasumi_decryption_test_case_1_oop),
13157 /** KASUMI hash only (UIA1) */
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_kasumi_hash_generate_test_case_1),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_hash_generate_test_case_2),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_kasumi_hash_generate_test_case_3),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_kasumi_hash_generate_test_case_4),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_kasumi_hash_generate_test_case_5),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_kasumi_hash_generate_test_case_6),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_kasumi_hash_verify_test_case_1),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_kasumi_hash_verify_test_case_2),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_kasumi_hash_verify_test_case_3),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_kasumi_hash_verify_test_case_4),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_kasumi_hash_verify_test_case_5),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_null_cipher_only_operation),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_null_auth_only_operation),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_null_cipher_auth_operation),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_null_auth_cipher_operation),
13191 /** Negative tests */
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 authentication_verify_AES128_GMAC_fail_data_corrupt),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13204 TEST_CASES_END() /**< NULL terminate unit test array */
13208 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13209 .suite_name = "Crypto NITROX Unit Test Suite",
13210 .setup = testsuite_setup,
13211 .teardown = testsuite_teardown,
13212 .unit_test_cases = {
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_device_configure_invalid_dev_id),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 test_device_configure_invalid_queue_pair_ids),
13217 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13218 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13220 TEST_CASES_END() /**< NULL terminate unit test array */
13224 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13225 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13226 .setup = testsuite_setup,
13227 .teardown = testsuite_teardown,
13228 .unit_test_cases = {
13229 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13230 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13231 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13232 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13233 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13235 /** AES GCM Authenticated Encryption */
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_AES_GCM_authenticated_encryption_test_case_1),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_AES_GCM_authenticated_encryption_test_case_2),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_AES_GCM_authenticated_encryption_test_case_3),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_AES_GCM_authenticated_encryption_test_case_4),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_AES_GCM_authenticated_encryption_test_case_5),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_AES_GCM_authenticated_encryption_test_case_6),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_AES_GCM_authenticated_encryption_test_case_7),
13251 /** AES GCM Authenticated Decryption */
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_AES_GCM_authenticated_decryption_test_case_1),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_AES_GCM_authenticated_decryption_test_case_2),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_AES_GCM_authenticated_decryption_test_case_3),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_AES_GCM_authenticated_decryption_test_case_4),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_AES_GCM_authenticated_decryption_test_case_5),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_AES_GCM_authenticated_decryption_test_case_6),
13264 TEST_CASE_ST(ut_setup, ut_teardown,
13265 test_AES_GCM_authenticated_decryption_test_case_7),
13266 /** AES GMAC Authentication */
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_AES_GMAC_authentication_test_case_1),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_AES_GMAC_authentication_verify_test_case_1),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_AES_GMAC_authentication_test_case_2),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_AES_GMAC_authentication_verify_test_case_2),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_AES_GMAC_authentication_test_case_3),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_AES_GMAC_authentication_verify_test_case_3),
13280 /** SNOW 3G encrypt only (UEA2) */
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_snow3g_encryption_test_case_1),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_snow3g_encryption_test_case_2),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_snow3g_encryption_test_case_3),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_snow3g_encryption_test_case_4),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_encryption_test_case_5),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_snow3g_encryption_test_case_1_oop),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_decryption_test_case_1_oop),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_snow3g_encryption_test_case_1_oop_sgl),
13299 /** SNOW 3G decrypt only (UEA2) */
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_decryption_test_case_1),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_decryption_test_case_2),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_decryption_test_case_3),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_snow3g_decryption_test_case_4),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_snow3g_decryption_test_case_5),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_snow3g_hash_generate_test_case_1),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_snow3g_hash_generate_test_case_2),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_snow3g_hash_generate_test_case_3),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_snow3g_hash_verify_test_case_1),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_snow3g_hash_verify_test_case_2),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_snow3g_hash_verify_test_case_3),
13324 /** ZUC encrypt only (EEA3) */
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_zuc_encryption_test_case_1),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_zuc_encryption_test_case_2),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_zuc_encryption_test_case_3),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_zuc_encryption_test_case_4),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_zuc_encryption_test_case_5),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_zuc_hash_generate_test_case_1),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_zuc_hash_generate_test_case_2),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_zuc_hash_generate_test_case_3),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_zuc_hash_generate_test_case_4),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_zuc_hash_generate_test_case_5),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_zuc_encryption_test_case_6_sgl),
13348 /** KASUMI encrypt only (UEA1) */
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_kasumi_encryption_test_case_1),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_kasumi_encryption_test_case_2),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_kasumi_encryption_test_case_3),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 test_kasumi_encryption_test_case_4),
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 test_kasumi_encryption_test_case_5),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 test_kasumi_encryption_test_case_1_sgl),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 test_kasumi_encryption_test_case_1_oop_sgl),
13363 /** KASUMI decrypt only (UEA1) */
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_kasumi_decryption_test_case_1),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_kasumi_decryption_test_case_2),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_kasumi_decryption_test_case_3),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_kasumi_decryption_test_case_4),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_decryption_test_case_5),
13375 TEST_CASE_ST(ut_setup, ut_teardown,
13376 test_kasumi_encryption_test_case_1_oop),
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_kasumi_decryption_test_case_1_oop),
13380 /** KASUMI hash only (UIA1) */
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_kasumi_hash_generate_test_case_1),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_kasumi_hash_generate_test_case_2),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_kasumi_hash_generate_test_case_3),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_kasumi_hash_generate_test_case_4),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_kasumi_hash_generate_test_case_5),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_kasumi_hash_generate_test_case_6),
13393 TEST_CASE_ST(ut_setup, ut_teardown,
13394 test_kasumi_hash_verify_test_case_1),
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_kasumi_hash_verify_test_case_2),
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_kasumi_hash_verify_test_case_3),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_kasumi_hash_verify_test_case_4),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_kasumi_hash_verify_test_case_5),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_null_cipher_only_operation),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_null_auth_only_operation),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_null_cipher_auth_operation),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_null_auth_cipher_operation),
13414 /** Negative tests */
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 authentication_verify_AES128_GMAC_fail_data_corrupt),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13427 TEST_CASES_END() /**< NULL terminate unit test array */
13432 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13434 gbl_driver_id = rte_cryptodev_driver_id_get(
13435 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13437 if (gbl_driver_id == -1) {
13438 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13439 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13440 "are enabled in config file to run this testsuite.\n");
13441 return TEST_SKIPPED;
13444 return unit_test_suite_runner(&cryptodev_testsuite);
13448 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13450 gbl_driver_id = rte_cryptodev_driver_id_get(
13451 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13453 if (gbl_driver_id == -1) {
13454 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13455 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13456 "in config file to run this testsuite.\n");
13457 return TEST_FAILED;
13460 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13464 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13466 gbl_driver_id = rte_cryptodev_driver_id_get(
13467 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13469 if (gbl_driver_id == -1) {
13470 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13471 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13472 "in config file to run this testsuite.\n");
13473 return TEST_SKIPPED;
13476 return unit_test_suite_runner(&cryptodev_testsuite);
13480 test_cryptodev_cpu_aesni_mb(void)
13483 enum rte_security_session_action_type at;
13485 gbl_driver_id = rte_cryptodev_driver_id_get(
13486 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13488 if (gbl_driver_id == -1) {
13489 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13490 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13491 "in config file to run this testsuite.\n");
13492 return TEST_SKIPPED;
13495 at = gbl_action_type;
13496 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13497 rc = unit_test_suite_runner(&cryptodev_testsuite);
13498 gbl_action_type = at;
13503 test_cryptodev_openssl(void)
13505 gbl_driver_id = rte_cryptodev_driver_id_get(
13506 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13508 if (gbl_driver_id == -1) {
13509 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13510 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13511 "in config file to run this testsuite.\n");
13512 return TEST_SKIPPED;
13515 return unit_test_suite_runner(&cryptodev_testsuite);
13519 test_cryptodev_aesni_gcm(void)
13521 gbl_driver_id = rte_cryptodev_driver_id_get(
13522 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13524 if (gbl_driver_id == -1) {
13525 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13526 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13527 "in config file to run this testsuite.\n");
13528 return TEST_SKIPPED;
13531 return unit_test_suite_runner(&cryptodev_testsuite);
13535 test_cryptodev_cpu_aesni_gcm(void)
13538 enum rte_security_session_action_type at;
13540 gbl_driver_id = rte_cryptodev_driver_id_get(
13541 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13543 if (gbl_driver_id == -1) {
13544 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13545 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13546 "in config file to run this testsuite.\n");
13547 return TEST_SKIPPED;
13550 at = gbl_action_type;
13551 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13552 rc = unit_test_suite_runner(&cryptodev_testsuite);
13553 gbl_action_type = at;
13558 test_cryptodev_null(void)
13560 gbl_driver_id = rte_cryptodev_driver_id_get(
13561 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13563 if (gbl_driver_id == -1) {
13564 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13565 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13566 "in config file to run this testsuite.\n");
13567 return TEST_SKIPPED;
13570 return unit_test_suite_runner(&cryptodev_testsuite);
13574 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13576 gbl_driver_id = rte_cryptodev_driver_id_get(
13577 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13579 if (gbl_driver_id == -1) {
13580 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13581 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13582 "in config file to run this testsuite.\n");
13583 return TEST_SKIPPED;
13586 return unit_test_suite_runner(&cryptodev_testsuite);
13590 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13592 gbl_driver_id = rte_cryptodev_driver_id_get(
13593 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13595 if (gbl_driver_id == -1) {
13596 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13597 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13598 "in config file to run this testsuite.\n");
13599 return TEST_SKIPPED;
13602 return unit_test_suite_runner(&cryptodev_testsuite);
13606 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13608 gbl_driver_id = rte_cryptodev_driver_id_get(
13609 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13611 if (gbl_driver_id == -1) {
13612 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13613 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13614 "in config file to run this testsuite.\n");
13615 return TEST_SKIPPED;
13618 return unit_test_suite_runner(&cryptodev_testsuite);
13622 test_cryptodev_armv8(void)
13624 gbl_driver_id = rte_cryptodev_driver_id_get(
13625 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13627 if (gbl_driver_id == -1) {
13628 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13629 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13630 "in config file to run this testsuite.\n");
13631 return TEST_SKIPPED;
13634 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13638 test_cryptodev_mrvl(void)
13640 gbl_driver_id = rte_cryptodev_driver_id_get(
13641 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13643 if (gbl_driver_id == -1) {
13644 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13645 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13646 "in config file to run this testsuite.\n");
13647 return TEST_SKIPPED;
13650 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13653 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13656 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13658 gbl_driver_id = rte_cryptodev_driver_id_get(
13659 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13661 if (gbl_driver_id == -1) {
13662 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13663 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13664 "in config file to run this testsuite.\n");
13665 return TEST_SKIPPED;
13668 if (rte_cryptodev_driver_id_get(
13669 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13670 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13671 " enabled in config file to run this testsuite.\n");
13672 return TEST_SKIPPED;
13674 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13677 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13682 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13684 gbl_driver_id = rte_cryptodev_driver_id_get(
13685 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13687 if (gbl_driver_id == -1) {
13688 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13689 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13690 "in config file to run this testsuite.\n");
13691 return TEST_SKIPPED;
13694 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13698 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13700 gbl_driver_id = rte_cryptodev_driver_id_get(
13701 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13703 if (gbl_driver_id == -1) {
13704 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13705 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13706 "in config file to run this testsuite.\n");
13707 return TEST_SKIPPED;
13710 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13714 test_cryptodev_ccp(void)
13716 gbl_driver_id = rte_cryptodev_driver_id_get(
13717 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13719 if (gbl_driver_id == -1) {
13720 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13721 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13722 "in config file to run this testsuite.\n");
13723 return TEST_FAILED;
13726 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13730 test_cryptodev_octeontx(void)
13732 gbl_driver_id = rte_cryptodev_driver_id_get(
13733 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13734 if (gbl_driver_id == -1) {
13735 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13736 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13737 "enabled in config file to run this "
13739 return TEST_FAILED;
13741 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13745 test_cryptodev_octeontx2(void)
13747 gbl_driver_id = rte_cryptodev_driver_id_get(
13748 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13749 if (gbl_driver_id == -1) {
13750 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13751 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13752 "enabled in config file to run this "
13754 return TEST_FAILED;
13756 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13760 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13762 gbl_driver_id = rte_cryptodev_driver_id_get(
13763 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13765 if (gbl_driver_id == -1) {
13766 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13767 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13768 "in config file to run this testsuite.\n");
13769 return TEST_FAILED;
13772 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13776 test_cryptodev_nitrox(void)
13778 gbl_driver_id = rte_cryptodev_driver_id_get(
13779 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13781 if (gbl_driver_id == -1) {
13782 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13783 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13784 "in config file to run this testsuite.\n");
13785 return TEST_FAILED;
13788 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13791 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13792 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13793 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13794 test_cryptodev_cpu_aesni_mb);
13795 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13796 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13797 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13798 test_cryptodev_cpu_aesni_gcm);
13799 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13800 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13801 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13802 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13803 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13804 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13805 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13806 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13807 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13808 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13809 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13810 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13811 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13812 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);