1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* This test is for QAT and NITROX PMDs only */
771 if (gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
773 gbl_driver_id != rte_cryptodev_driver_id_get(
774 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
777 /* Stop the device in case it's started so it can be configured */
778 rte_cryptodev_stop(ts_params->valid_devs[0]);
780 /* valid - one queue pairs */
781 ts_params->conf.nb_queue_pairs = 1;
783 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
785 "Failed to configure cryptodev: dev_id %u, qp_id %u",
786 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
789 /* valid - max value queue pairs */
790 ts_params->conf.nb_queue_pairs = orig_nb_qps;
792 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
794 "Failed to configure cryptodev: dev_id %u, qp_id %u",
795 ts_params->valid_devs[0],
796 ts_params->conf.nb_queue_pairs);
799 /* invalid - zero queue pairs */
800 ts_params->conf.nb_queue_pairs = 0;
802 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
804 "Failed test for rte_cryptodev_configure, dev_id %u,"
806 ts_params->valid_devs[0],
807 ts_params->conf.nb_queue_pairs);
810 /* invalid - max value supported by field queue pairs */
811 ts_params->conf.nb_queue_pairs = UINT16_MAX;
813 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
815 "Failed test for rte_cryptodev_configure, dev_id %u,"
817 ts_params->valid_devs[0],
818 ts_params->conf.nb_queue_pairs);
821 /* invalid - max value + 1 queue pairs */
822 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
824 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
826 "Failed test for rte_cryptodev_configure, dev_id %u,"
828 ts_params->valid_devs[0],
829 ts_params->conf.nb_queue_pairs);
831 /* revert to original testsuite value */
832 ts_params->conf.nb_queue_pairs = orig_nb_qps;
838 test_queue_pair_descriptor_setup(void)
840 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 struct rte_cryptodev_info dev_info;
842 struct rte_cryptodev_qp_conf qp_conf = {
843 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
848 /* This test is for QAT PMD only */
849 if (gbl_driver_id != rte_cryptodev_driver_id_get(
850 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
853 /* Stop the device in case it's started so it can be configured */
854 rte_cryptodev_stop(ts_params->valid_devs[0]);
857 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
859 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
861 "Failed to configure cryptodev %u",
862 ts_params->valid_devs[0]);
865 * Test various ring sizes on this device. memzones can't be
866 * freed so are re-used if ring is released and re-created.
868 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
869 qp_conf.mp_session = ts_params->session_mpool;
870 qp_conf.mp_session_private = ts_params->session_priv_mpool;
872 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
873 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
874 ts_params->valid_devs[0], qp_id, &qp_conf,
875 rte_cryptodev_socket_id(
876 ts_params->valid_devs[0])),
878 "rte_cryptodev_queue_pair_setup: num_inflights "
879 "%u on qp %u on cryptodev %u",
880 qp_conf.nb_descriptors, qp_id,
881 ts_params->valid_devs[0]);
884 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
886 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
887 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
888 ts_params->valid_devs[0], qp_id, &qp_conf,
889 rte_cryptodev_socket_id(
890 ts_params->valid_devs[0])),
892 " rte_cryptodev_queue_pair_setup: num_inflights"
893 " %u on qp %u on cryptodev %u",
894 qp_conf.nb_descriptors, qp_id,
895 ts_params->valid_devs[0]);
898 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
900 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
901 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
902 ts_params->valid_devs[0], qp_id, &qp_conf,
903 rte_cryptodev_socket_id(
904 ts_params->valid_devs[0])),
906 "rte_cryptodev_queue_pair_setup: num_inflights"
907 " %u on qp %u on cryptodev %u",
908 qp_conf.nb_descriptors, qp_id,
909 ts_params->valid_devs[0]);
912 /* invalid number of descriptors - max supported + 2 */
913 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
915 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
916 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
917 ts_params->valid_devs[0], qp_id, &qp_conf,
918 rte_cryptodev_socket_id(
919 ts_params->valid_devs[0])),
920 "Unexpectedly passed test for "
921 "rte_cryptodev_queue_pair_setup:"
922 "num_inflights %u on qp %u on cryptodev %u",
923 qp_conf.nb_descriptors, qp_id,
924 ts_params->valid_devs[0]);
927 /* invalid number of descriptors - max value of parameter */
928 qp_conf.nb_descriptors = UINT32_MAX-1;
930 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
931 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
932 ts_params->valid_devs[0], qp_id, &qp_conf,
933 rte_cryptodev_socket_id(
934 ts_params->valid_devs[0])),
935 "Unexpectedly passed test for "
936 "rte_cryptodev_queue_pair_setup:"
937 "num_inflights %u on qp %u on cryptodev %u",
938 qp_conf.nb_descriptors, qp_id,
939 ts_params->valid_devs[0]);
942 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
944 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
945 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
946 ts_params->valid_devs[0], qp_id, &qp_conf,
947 rte_cryptodev_socket_id(
948 ts_params->valid_devs[0])),
950 " rte_cryptodev_queue_pair_setup:"
951 "num_inflights %u on qp %u on cryptodev %u",
952 qp_conf.nb_descriptors, qp_id,
953 ts_params->valid_devs[0]);
956 /* invalid number of descriptors - max supported + 1 */
957 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
959 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
960 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
961 ts_params->valid_devs[0], qp_id, &qp_conf,
962 rte_cryptodev_socket_id(
963 ts_params->valid_devs[0])),
964 "Unexpectedly passed test for "
965 "rte_cryptodev_queue_pair_setup:"
966 "num_inflights %u on qp %u on cryptodev %u",
967 qp_conf.nb_descriptors, qp_id,
968 ts_params->valid_devs[0]);
971 /* test invalid queue pair id */
972 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
974 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
976 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
977 ts_params->valid_devs[0],
979 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
980 "Failed test for rte_cryptodev_queue_pair_setup:"
981 "invalid qp %u on cryptodev %u",
982 qp_id, ts_params->valid_devs[0]);
984 qp_id = 0xffff; /*invalid*/
986 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
987 ts_params->valid_devs[0],
989 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
990 "Failed test for rte_cryptodev_queue_pair_setup:"
991 "invalid qp %u on cryptodev %u",
992 qp_id, ts_params->valid_devs[0]);
997 /* ***** Plaintext data for tests ***** */
999 const char catch_22_quote_1[] =
1000 "There was only one catch and that was Catch-22, which "
1001 "specified that a concern for one's safety in the face of "
1002 "dangers that were real and immediate was the process of a "
1003 "rational mind. Orr was crazy and could be grounded. All he "
1004 "had to do was ask; and as soon as he did, he would no longer "
1005 "be crazy and would have to fly more missions. Orr would be "
1006 "crazy to fly more missions and sane if he didn't, but if he "
1007 "was sane he had to fly them. If he flew them he was crazy "
1008 "and didn't have to; but if he didn't want to he was sane and "
1009 "had to. Yossarian was moved very deeply by the absolute "
1010 "simplicity of this clause of Catch-22 and let out a "
1011 "respectful whistle. \"That's some catch, that Catch-22\", he "
1012 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1014 const char catch_22_quote[] =
1015 "What a lousy earth! He wondered how many people were "
1016 "destitute that same night even in his own prosperous country, "
1017 "how many homes were shanties, how many husbands were drunk "
1018 "and wives socked, and how many children were bullied, abused, "
1019 "or abandoned. How many families hungered for food they could "
1020 "not afford to buy? How many hearts were broken? How many "
1021 "suicides would take place that same night, how many people "
1022 "would go insane? How many cockroaches and landlords would "
1023 "triumph? How many winners were losers, successes failures, "
1024 "and rich men poor men? How many wise guys were stupid? How "
1025 "many happy endings were unhappy endings? How many honest men "
1026 "were liars, brave men cowards, loyal men traitors, how many "
1027 "sainted men were corrupt, how many people in positions of "
1028 "trust had sold their souls to bodyguards, how many had never "
1029 "had souls? How many straight-and-narrow paths were crooked "
1030 "paths? How many best families were worst families and how "
1031 "many good people were bad people? When you added them all up "
1032 "and then subtracted, you might be left with only the children, "
1033 "and perhaps with Albert Einstein and an old violinist or "
1034 "sculptor somewhere.";
1036 #define QUOTE_480_BYTES (480)
1037 #define QUOTE_512_BYTES (512)
1038 #define QUOTE_768_BYTES (768)
1039 #define QUOTE_1024_BYTES (1024)
1043 /* ***** SHA1 Hash Tests ***** */
1045 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1047 static uint8_t hmac_sha1_key[] = {
1048 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1049 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1050 0xDE, 0xF4, 0xDE, 0xAD };
1052 /* ***** SHA224 Hash Tests ***** */
1054 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1057 /* ***** AES-CBC Cipher Tests ***** */
1059 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1060 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1062 static uint8_t aes_cbc_key[] = {
1063 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1064 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1066 static uint8_t aes_cbc_iv[] = {
1067 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1068 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1071 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1073 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1074 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1075 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1076 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1077 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1078 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1079 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1080 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1081 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1082 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1083 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1084 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1085 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1086 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1087 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1088 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1089 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1090 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1091 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1092 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1093 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1094 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1095 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1096 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1097 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1098 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1099 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1100 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1101 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1102 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1103 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1104 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1105 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1106 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1107 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1108 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1109 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1110 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1111 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1112 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1113 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1114 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1115 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1116 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1117 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1118 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1119 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1120 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1121 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1122 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1123 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1124 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1125 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1126 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1127 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1128 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1129 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1130 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1131 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1132 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1133 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1134 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1135 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1136 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1137 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1140 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1141 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1142 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1143 0x18, 0x8c, 0x1d, 0x32
1147 /* Multisession Vector context Test */
1148 /*Begin Session 0 */
1149 static uint8_t ms_aes_cbc_key0[] = {
1150 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1151 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1154 static uint8_t ms_aes_cbc_iv0[] = {
1155 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1156 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1159 static const uint8_t ms_aes_cbc_cipher0[] = {
1160 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1161 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1162 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1163 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1164 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1165 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1166 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1167 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1168 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1169 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1170 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1171 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1172 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1173 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1174 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1175 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1176 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1177 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1178 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1179 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1180 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1181 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1182 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1183 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1184 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1185 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1186 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1187 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1188 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1189 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1190 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1191 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1192 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1193 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1194 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1195 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1196 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1197 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1198 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1199 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1200 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1201 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1202 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1203 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1204 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1205 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1206 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1207 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1208 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1209 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1210 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1211 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1212 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1213 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1214 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1215 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1216 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1217 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1218 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1219 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1220 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1221 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1222 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1223 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1227 static uint8_t ms_hmac_key0[] = {
1228 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest0[] = {
1239 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1240 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1241 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1242 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1243 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1244 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1245 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1246 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1250 /* Begin session 1 */
1252 static uint8_t ms_aes_cbc_key1[] = {
1253 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1254 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1257 static uint8_t ms_aes_cbc_iv1[] = {
1258 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1259 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1262 static const uint8_t ms_aes_cbc_cipher1[] = {
1263 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1264 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1265 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1266 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1267 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1268 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1269 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1270 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1271 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1272 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1273 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1274 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1275 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1276 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1277 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1278 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1279 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1280 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1281 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1282 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1283 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1284 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1285 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1286 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1287 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1288 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1289 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1290 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1291 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1292 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1293 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1294 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1295 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1296 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1297 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1298 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1299 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1300 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1301 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1302 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1303 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1304 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1305 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1306 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1307 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1308 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1309 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1310 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1311 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1312 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1313 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1314 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1315 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1316 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1317 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1318 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1319 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1320 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1321 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1322 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1323 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1324 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1325 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1326 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1330 static uint8_t ms_hmac_key1[] = {
1331 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1332 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1333 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1334 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1335 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1336 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1337 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1338 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1341 static const uint8_t ms_hmac_digest1[] = {
1342 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1343 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1344 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1345 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1346 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1347 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1348 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1349 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1352 /* Begin Session 2 */
1353 static uint8_t ms_aes_cbc_key2[] = {
1354 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1355 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1358 static uint8_t ms_aes_cbc_iv2[] = {
1359 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1360 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1363 static const uint8_t ms_aes_cbc_cipher2[] = {
1364 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1365 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1366 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1367 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1368 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1369 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1370 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1371 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1372 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1373 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1374 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1375 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1376 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1377 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1378 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1379 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1380 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1381 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1382 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1383 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1384 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1385 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1386 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1387 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1388 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1389 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1390 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1391 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1392 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1393 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1394 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1395 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1396 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1397 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1398 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1399 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1400 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1401 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1402 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1403 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1404 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1405 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1406 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1407 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1408 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1409 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1410 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1411 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1412 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1413 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1414 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1415 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1416 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1417 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1418 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1419 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1420 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1421 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1422 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1423 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1424 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1425 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1426 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1427 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1430 static uint8_t ms_hmac_key2[] = {
1431 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1432 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1433 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1434 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1435 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1436 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1437 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1438 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1441 static const uint8_t ms_hmac_digest2[] = {
1442 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1443 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1444 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1445 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1446 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1447 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1448 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1449 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1456 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1458 struct crypto_testsuite_params *ts_params = &testsuite_params;
1459 struct crypto_unittest_params *ut_params = &unittest_params;
1461 /* Verify the capabilities */
1462 struct rte_cryptodev_sym_capability_idx cap_idx;
1463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1464 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1469 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1474 /* Generate test mbuf data and space for digest */
1475 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1476 catch_22_quote, QUOTE_512_BYTES, 0);
1478 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1479 DIGEST_BYTE_LENGTH_SHA1);
1480 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1482 /* Setup Cipher Parameters */
1483 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1484 ut_params->cipher_xform.next = &ut_params->auth_xform;
1486 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1487 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1488 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1489 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1490 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1491 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1493 /* Setup HMAC Parameters */
1494 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1496 ut_params->auth_xform.next = NULL;
1498 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1499 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1500 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1501 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1502 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1504 ut_params->sess = rte_cryptodev_sym_session_create(
1505 ts_params->session_mpool);
1507 /* Create crypto session*/
1508 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1509 ut_params->sess, &ut_params->cipher_xform,
1510 ts_params->session_priv_mpool);
1511 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1513 /* Generate crypto op data structure */
1514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1516 TEST_ASSERT_NOT_NULL(ut_params->op,
1517 "Failed to allocate symmetric crypto operation struct");
1519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1523 /* set crypto operation source mbuf */
1524 sym_op->m_src = ut_params->ibuf;
1526 /* Set crypto operation authentication parameters */
1527 sym_op->auth.digest.data = ut_params->digest;
1528 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1529 ut_params->ibuf, QUOTE_512_BYTES);
1531 sym_op->auth.data.offset = 0;
1532 sym_op->auth.data.length = QUOTE_512_BYTES;
1534 /* Copy IV at the end of the crypto operation */
1535 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1536 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1538 /* Set crypto operation cipher parameters */
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1544 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1547 TEST_ASSERT_NOT_NULL(
1548 process_crypto_request(ts_params->valid_devs[0],
1550 "failed to process sym crypto op");
1552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1553 "crypto op processing failed");
1556 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1559 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1560 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1562 "ciphertext data not as expected");
1564 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1566 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1567 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1568 gbl_driver_id == rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1570 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1571 DIGEST_BYTE_LENGTH_SHA1,
1572 "Generated digest data not as expected");
1574 return TEST_SUCCESS;
1577 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1579 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1581 static uint8_t hmac_sha512_key[] = {
1582 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1583 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1584 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1585 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1586 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1587 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1588 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1589 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1591 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1592 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1593 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1594 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1595 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1596 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1597 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1598 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1599 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1604 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1605 struct crypto_unittest_params *ut_params,
1606 uint8_t *cipher_key,
1610 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1611 struct crypto_unittest_params *ut_params,
1612 struct crypto_testsuite_params *ts_params,
1613 const uint8_t *cipher,
1614 const uint8_t *digest,
1619 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1620 struct crypto_unittest_params *ut_params,
1621 uint8_t *cipher_key,
1625 /* Setup Cipher Parameters */
1626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1627 ut_params->cipher_xform.next = NULL;
1629 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1630 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1631 ut_params->cipher_xform.cipher.key.data = cipher_key;
1632 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1633 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1634 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1636 /* Setup HMAC Parameters */
1637 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1638 ut_params->auth_xform.next = &ut_params->cipher_xform;
1640 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1641 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1642 ut_params->auth_xform.auth.key.data = hmac_key;
1643 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1644 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1646 return TEST_SUCCESS;
1651 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1652 struct crypto_unittest_params *ut_params,
1653 struct crypto_testsuite_params *ts_params,
1654 const uint8_t *cipher,
1655 const uint8_t *digest,
1658 /* Generate test mbuf data and digest */
1659 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1662 QUOTE_512_BYTES, 0);
1664 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1665 DIGEST_BYTE_LENGTH_SHA512);
1666 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1668 rte_memcpy(ut_params->digest,
1670 DIGEST_BYTE_LENGTH_SHA512);
1672 /* Generate Crypto op data structure */
1673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1675 TEST_ASSERT_NOT_NULL(ut_params->op,
1676 "Failed to allocate symmetric crypto operation struct");
1678 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1680 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1682 /* set crypto operation source mbuf */
1683 sym_op->m_src = ut_params->ibuf;
1685 sym_op->auth.digest.data = ut_params->digest;
1686 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1687 ut_params->ibuf, QUOTE_512_BYTES);
1689 sym_op->auth.data.offset = 0;
1690 sym_op->auth.data.length = QUOTE_512_BYTES;
1692 /* Copy IV at the end of the crypto operation */
1693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1694 iv, CIPHER_IV_LENGTH_AES_CBC);
1696 sym_op->cipher.data.offset = 0;
1697 sym_op->cipher.data.length = QUOTE_512_BYTES;
1699 /* Process crypto operation */
1700 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1701 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1704 TEST_ASSERT_NOT_NULL(
1705 process_crypto_request(ts_params->valid_devs[0],
1707 "failed to process sym crypto op");
1709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1710 "crypto op processing failed");
1712 ut_params->obuf = ut_params->op->sym->m_src;
1715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1716 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1719 "Plaintext data not as expected");
1722 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1723 "Digest verification failed");
1725 return TEST_SUCCESS;
1729 test_blockcipher(enum blockcipher_test_type test_type)
1731 struct crypto_testsuite_params *ts_params = &testsuite_params;
1734 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1735 ts_params->op_mpool,
1736 ts_params->session_mpool, ts_params->session_priv_mpool,
1737 ts_params->valid_devs[0],
1740 if (status == -ENOTSUP)
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 return TEST_SUCCESS;
1749 test_AES_cipheronly_all(void)
1751 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1755 test_AES_docsis_all(void)
1757 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1761 test_DES_docsis_all(void)
1763 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1767 test_DES_cipheronly_all(void)
1769 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1773 test_authonly_all(void)
1775 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1779 test_AES_chain_all(void)
1781 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1785 test_3DES_chain_all(void)
1787 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1791 test_3DES_cipheronly_all(void)
1793 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1796 /* ***** SNOW 3G Tests ***** */
1798 create_wireless_algo_hash_session(uint8_t dev_id,
1799 const uint8_t *key, const uint8_t key_len,
1800 const uint8_t iv_len, const uint8_t auth_len,
1801 enum rte_crypto_auth_operation op,
1802 enum rte_crypto_auth_algorithm algo)
1804 uint8_t hash_key[key_len];
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 struct crypto_unittest_params *ut_params = &unittest_params;
1810 memcpy(hash_key, key, key_len);
1812 debug_hexdump(stdout, "key:", key, key_len);
1814 /* Setup Authentication Parameters */
1815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1816 ut_params->auth_xform.next = NULL;
1818 ut_params->auth_xform.auth.op = op;
1819 ut_params->auth_xform.auth.algo = algo;
1820 ut_params->auth_xform.auth.key.length = key_len;
1821 ut_params->auth_xform.auth.key.data = hash_key;
1822 ut_params->auth_xform.auth.digest_length = auth_len;
1823 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1824 ut_params->auth_xform.auth.iv.length = iv_len;
1825 ut_params->sess = rte_cryptodev_sym_session_create(
1826 ts_params->session_mpool);
1828 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1829 &ut_params->auth_xform,
1830 ts_params->session_priv_mpool);
1831 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1837 create_wireless_algo_cipher_session(uint8_t dev_id,
1838 enum rte_crypto_cipher_operation op,
1839 enum rte_crypto_cipher_algorithm algo,
1840 const uint8_t *key, const uint8_t key_len,
1843 uint8_t cipher_key[key_len];
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 memcpy(cipher_key, key, key_len);
1850 /* Setup Cipher Parameters */
1851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1852 ut_params->cipher_xform.next = NULL;
1854 ut_params->cipher_xform.cipher.algo = algo;
1855 ut_params->cipher_xform.cipher.op = op;
1856 ut_params->cipher_xform.cipher.key.data = cipher_key;
1857 ut_params->cipher_xform.cipher.key.length = key_len;
1858 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1859 ut_params->cipher_xform.cipher.iv.length = iv_len;
1861 debug_hexdump(stdout, "key:", key, key_len);
1863 /* Create Crypto session */
1864 ut_params->sess = rte_cryptodev_sym_session_create(
1865 ts_params->session_mpool);
1867 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1868 &ut_params->cipher_xform,
1869 ts_params->session_priv_mpool);
1870 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1871 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1876 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1877 unsigned int cipher_len,
1878 unsigned int cipher_offset)
1880 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 struct crypto_unittest_params *ut_params = &unittest_params;
1883 /* Generate Crypto op data structure */
1884 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1885 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1886 TEST_ASSERT_NOT_NULL(ut_params->op,
1887 "Failed to allocate pktmbuf offload");
1889 /* Set crypto operation data parameters */
1890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1892 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1894 /* set crypto operation source mbuf */
1895 sym_op->m_src = ut_params->ibuf;
1898 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1900 sym_op->cipher.data.length = cipher_len;
1901 sym_op->cipher.data.offset = cipher_offset;
1906 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1907 unsigned int cipher_len,
1908 unsigned int cipher_offset)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1911 struct crypto_unittest_params *ut_params = &unittest_params;
1913 /* Generate Crypto op data structure */
1914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1916 TEST_ASSERT_NOT_NULL(ut_params->op,
1917 "Failed to allocate pktmbuf offload");
1919 /* Set crypto operation data parameters */
1920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1922 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1924 /* set crypto operation source mbuf */
1925 sym_op->m_src = ut_params->ibuf;
1926 sym_op->m_dst = ut_params->obuf;
1929 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1931 sym_op->cipher.data.length = cipher_len;
1932 sym_op->cipher.data.offset = cipher_offset;
1937 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1938 enum rte_crypto_cipher_operation cipher_op,
1939 enum rte_crypto_auth_operation auth_op,
1940 enum rte_crypto_auth_algorithm auth_algo,
1941 enum rte_crypto_cipher_algorithm cipher_algo,
1942 const uint8_t *key, uint8_t key_len,
1943 uint8_t auth_iv_len, uint8_t auth_len,
1944 uint8_t cipher_iv_len)
1947 uint8_t cipher_auth_key[key_len];
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 struct crypto_unittest_params *ut_params = &unittest_params;
1953 memcpy(cipher_auth_key, key, key_len);
1955 /* Setup Authentication Parameters */
1956 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1957 ut_params->auth_xform.next = NULL;
1959 ut_params->auth_xform.auth.op = auth_op;
1960 ut_params->auth_xform.auth.algo = auth_algo;
1961 ut_params->auth_xform.auth.key.length = key_len;
1962 /* Hash key = cipher key */
1963 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1964 ut_params->auth_xform.auth.digest_length = auth_len;
1965 /* Auth IV will be after cipher IV */
1966 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1967 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1969 /* Setup Cipher Parameters */
1970 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1971 ut_params->cipher_xform.next = &ut_params->auth_xform;
1973 ut_params->cipher_xform.cipher.algo = cipher_algo;
1974 ut_params->cipher_xform.cipher.op = cipher_op;
1975 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1976 ut_params->cipher_xform.cipher.key.length = key_len;
1977 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1978 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1980 debug_hexdump(stdout, "key:", key, key_len);
1982 /* Create Crypto session*/
1983 ut_params->sess = rte_cryptodev_sym_session_create(
1984 ts_params->session_mpool);
1985 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1987 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1988 &ut_params->cipher_xform,
1989 ts_params->session_priv_mpool);
1990 if (status == -ENOTSUP)
1993 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1998 create_wireless_cipher_auth_session(uint8_t dev_id,
1999 enum rte_crypto_cipher_operation cipher_op,
2000 enum rte_crypto_auth_operation auth_op,
2001 enum rte_crypto_auth_algorithm auth_algo,
2002 enum rte_crypto_cipher_algorithm cipher_algo,
2003 const struct wireless_test_data *tdata)
2005 const uint8_t key_len = tdata->key.len;
2006 uint8_t cipher_auth_key[key_len];
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 struct crypto_unittest_params *ut_params = &unittest_params;
2011 const uint8_t *key = tdata->key.data;
2012 const uint8_t auth_len = tdata->digest.len;
2013 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2014 uint8_t auth_iv_len = tdata->auth_iv.len;
2016 memcpy(cipher_auth_key, key, key_len);
2018 /* Setup Authentication Parameters */
2019 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2020 ut_params->auth_xform.next = NULL;
2022 ut_params->auth_xform.auth.op = auth_op;
2023 ut_params->auth_xform.auth.algo = auth_algo;
2024 ut_params->auth_xform.auth.key.length = key_len;
2025 /* Hash key = cipher key */
2026 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 /* Auth IV will be after cipher IV */
2029 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2030 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2032 /* Setup Cipher Parameters */
2033 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2034 ut_params->cipher_xform.next = &ut_params->auth_xform;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2041 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2044 debug_hexdump(stdout, "key:", key, key_len);
2046 /* Create Crypto session*/
2047 ut_params->sess = rte_cryptodev_sym_session_create(
2048 ts_params->session_mpool);
2050 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2051 &ut_params->cipher_xform,
2052 ts_params->session_priv_mpool);
2054 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2060 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2061 const struct wireless_test_data *tdata)
2063 return create_wireless_cipher_auth_session(dev_id,
2064 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2065 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2066 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2070 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2071 enum rte_crypto_cipher_operation cipher_op,
2072 enum rte_crypto_auth_operation auth_op,
2073 enum rte_crypto_auth_algorithm auth_algo,
2074 enum rte_crypto_cipher_algorithm cipher_algo,
2075 const uint8_t *key, const uint8_t key_len,
2076 uint8_t auth_iv_len, uint8_t auth_len,
2077 uint8_t cipher_iv_len)
2079 uint8_t auth_cipher_key[key_len];
2081 struct crypto_testsuite_params *ts_params = &testsuite_params;
2082 struct crypto_unittest_params *ut_params = &unittest_params;
2084 memcpy(auth_cipher_key, key, key_len);
2086 /* Setup Authentication Parameters */
2087 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2088 ut_params->auth_xform.auth.op = auth_op;
2089 ut_params->auth_xform.next = &ut_params->cipher_xform;
2090 ut_params->auth_xform.auth.algo = auth_algo;
2091 ut_params->auth_xform.auth.key.length = key_len;
2092 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2093 ut_params->auth_xform.auth.digest_length = auth_len;
2094 /* Auth IV will be after cipher IV */
2095 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2096 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2098 /* Setup Cipher Parameters */
2099 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2100 ut_params->cipher_xform.next = NULL;
2101 ut_params->cipher_xform.cipher.algo = cipher_algo;
2102 ut_params->cipher_xform.cipher.op = cipher_op;
2103 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2104 ut_params->cipher_xform.cipher.key.length = key_len;
2105 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2106 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2108 debug_hexdump(stdout, "key:", key, key_len);
2110 /* Create Crypto session*/
2111 ut_params->sess = rte_cryptodev_sym_session_create(
2112 ts_params->session_mpool);
2113 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2115 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2116 ut_params->auth_xform.next = NULL;
2117 ut_params->cipher_xform.next = &ut_params->auth_xform;
2118 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2119 &ut_params->cipher_xform,
2120 ts_params->session_priv_mpool);
2123 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2124 &ut_params->auth_xform,
2125 ts_params->session_priv_mpool);
2127 if (status == -ENOTSUP)
2130 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2136 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2137 unsigned int auth_tag_len,
2138 const uint8_t *iv, unsigned int iv_len,
2139 unsigned int data_pad_len,
2140 enum rte_crypto_auth_operation op,
2141 unsigned int auth_len, unsigned int auth_offset)
2143 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 struct crypto_unittest_params *ut_params = &unittest_params;
2147 /* Generate Crypto op data structure */
2148 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2149 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2150 TEST_ASSERT_NOT_NULL(ut_params->op,
2151 "Failed to allocate pktmbuf offload");
2153 /* Set crypto operation data parameters */
2154 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2156 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2158 /* set crypto operation source mbuf */
2159 sym_op->m_src = ut_params->ibuf;
2162 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2165 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2166 ut_params->ibuf, auth_tag_len);
2168 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2169 "no room to append auth tag");
2170 ut_params->digest = sym_op->auth.digest.data;
2171 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2172 ut_params->ibuf, data_pad_len);
2173 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2174 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2176 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2178 debug_hexdump(stdout, "digest:",
2179 sym_op->auth.digest.data,
2182 sym_op->auth.data.length = auth_len;
2183 sym_op->auth.data.offset = auth_offset;
2189 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2190 enum rte_crypto_auth_operation op)
2192 struct crypto_testsuite_params *ts_params = &testsuite_params;
2193 struct crypto_unittest_params *ut_params = &unittest_params;
2195 const uint8_t *auth_tag = tdata->digest.data;
2196 const unsigned int auth_tag_len = tdata->digest.len;
2197 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2198 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2200 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2201 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2202 const uint8_t *auth_iv = tdata->auth_iv.data;
2203 const uint8_t auth_iv_len = tdata->auth_iv.len;
2204 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2205 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2207 /* Generate Crypto op data structure */
2208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2210 TEST_ASSERT_NOT_NULL(ut_params->op,
2211 "Failed to allocate pktmbuf offload");
2212 /* Set crypto operation data parameters */
2213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2215 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2217 /* set crypto operation source mbuf */
2218 sym_op->m_src = ut_params->ibuf;
2221 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2222 ut_params->ibuf, auth_tag_len);
2224 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2225 "no room to append auth tag");
2226 ut_params->digest = sym_op->auth.digest.data;
2227 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2228 ut_params->ibuf, data_pad_len);
2229 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2230 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2232 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2234 debug_hexdump(stdout, "digest:",
2235 sym_op->auth.digest.data,
2238 /* Copy cipher and auth IVs at the end of the crypto operation */
2239 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2241 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2242 iv_ptr += cipher_iv_len;
2243 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2245 sym_op->cipher.data.length = cipher_len;
2246 sym_op->cipher.data.offset = 0;
2247 sym_op->auth.data.length = auth_len;
2248 sym_op->auth.data.offset = 0;
2254 create_zuc_cipher_hash_generate_operation(
2255 const struct wireless_test_data *tdata)
2257 return create_wireless_cipher_hash_operation(tdata,
2258 RTE_CRYPTO_AUTH_OP_GENERATE);
2262 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2263 const unsigned auth_tag_len,
2264 const uint8_t *auth_iv, uint8_t auth_iv_len,
2265 unsigned data_pad_len,
2266 enum rte_crypto_auth_operation op,
2267 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2268 const unsigned cipher_len, const unsigned cipher_offset,
2269 const unsigned auth_len, const unsigned auth_offset)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2272 struct crypto_unittest_params *ut_params = &unittest_params;
2274 enum rte_crypto_cipher_algorithm cipher_algo =
2275 ut_params->cipher_xform.cipher.algo;
2276 enum rte_crypto_auth_algorithm auth_algo =
2277 ut_params->auth_xform.auth.algo;
2279 /* Generate Crypto op data structure */
2280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2282 TEST_ASSERT_NOT_NULL(ut_params->op,
2283 "Failed to allocate pktmbuf offload");
2284 /* Set crypto operation data parameters */
2285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2287 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2289 /* set crypto operation source mbuf */
2290 sym_op->m_src = ut_params->ibuf;
2293 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2294 ut_params->ibuf, auth_tag_len);
2296 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2297 "no room to append auth tag");
2298 ut_params->digest = sym_op->auth.digest.data;
2300 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2301 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2302 ut_params->ibuf, data_pad_len);
2304 struct rte_mbuf *m = ut_params->ibuf;
2305 unsigned int offset = data_pad_len;
2307 while (offset > m->data_len && m->next != NULL) {
2308 offset -= m->data_len;
2311 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2315 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2316 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2318 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2320 debug_hexdump(stdout, "digest:",
2321 sym_op->auth.digest.data,
2324 /* Copy cipher and auth IVs at the end of the crypto operation */
2325 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2327 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2328 iv_ptr += cipher_iv_len;
2329 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2331 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2332 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2333 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2334 sym_op->cipher.data.length = cipher_len;
2335 sym_op->cipher.data.offset = cipher_offset;
2337 sym_op->cipher.data.length = cipher_len >> 3;
2338 sym_op->cipher.data.offset = cipher_offset >> 3;
2341 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2342 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2343 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2344 sym_op->auth.data.length = auth_len;
2345 sym_op->auth.data.offset = auth_offset;
2347 sym_op->auth.data.length = auth_len >> 3;
2348 sym_op->auth.data.offset = auth_offset >> 3;
2355 create_wireless_algo_auth_cipher_operation(
2356 const uint8_t *auth_tag, unsigned int auth_tag_len,
2357 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2358 const uint8_t *auth_iv, uint8_t auth_iv_len,
2359 unsigned int data_pad_len,
2360 unsigned int cipher_len, unsigned int cipher_offset,
2361 unsigned int auth_len, unsigned int auth_offset,
2362 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2364 struct crypto_testsuite_params *ts_params = &testsuite_params;
2365 struct crypto_unittest_params *ut_params = &unittest_params;
2367 enum rte_crypto_cipher_algorithm cipher_algo =
2368 ut_params->cipher_xform.cipher.algo;
2369 enum rte_crypto_auth_algorithm auth_algo =
2370 ut_params->auth_xform.auth.algo;
2372 /* Generate Crypto op data structure */
2373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2375 TEST_ASSERT_NOT_NULL(ut_params->op,
2376 "Failed to allocate pktmbuf offload");
2378 /* Set crypto operation data parameters */
2379 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2381 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2383 /* set crypto operation mbufs */
2384 sym_op->m_src = ut_params->ibuf;
2385 if (op_mode == OUT_OF_PLACE)
2386 sym_op->m_dst = ut_params->obuf;
2390 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2391 (op_mode == IN_PLACE ?
2392 ut_params->ibuf : ut_params->obuf),
2393 uint8_t *, data_pad_len);
2394 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2395 (op_mode == IN_PLACE ?
2396 ut_params->ibuf : ut_params->obuf),
2398 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2400 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2401 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2402 sym_op->m_src : sym_op->m_dst);
2403 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2404 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2405 sgl_buf = sgl_buf->next;
2407 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2408 uint8_t *, remaining_off);
2409 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2411 memset(sym_op->auth.digest.data, 0, remaining_off);
2412 while (sgl_buf->next != NULL) {
2413 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2414 0, rte_pktmbuf_data_len(sgl_buf));
2415 sgl_buf = sgl_buf->next;
2419 /* Copy digest for the verification */
2421 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2423 /* Copy cipher and auth IVs at the end of the crypto operation */
2424 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2425 ut_params->op, uint8_t *, IV_OFFSET);
2427 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2428 iv_ptr += cipher_iv_len;
2429 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2431 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2432 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2433 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2434 sym_op->cipher.data.length = cipher_len;
2435 sym_op->cipher.data.offset = cipher_offset;
2437 sym_op->cipher.data.length = cipher_len >> 3;
2438 sym_op->cipher.data.offset = cipher_offset >> 3;
2441 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2442 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2443 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2444 sym_op->auth.data.length = auth_len;
2445 sym_op->auth.data.offset = auth_offset;
2447 sym_op->auth.data.length = auth_len >> 3;
2448 sym_op->auth.data.offset = auth_offset >> 3;
2455 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2461 unsigned plaintext_pad_len;
2462 unsigned plaintext_len;
2464 struct rte_cryptodev_info dev_info;
2466 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2467 uint64_t feat_flags = dev_info.feature_flags;
2469 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2470 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2471 printf("Device doesn't support NON-Byte Aligned Data.\n");
2475 /* Verify the capabilities */
2476 struct rte_cryptodev_sym_capability_idx cap_idx;
2477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2478 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2483 /* Create SNOW 3G session */
2484 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2485 tdata->key.data, tdata->key.len,
2486 tdata->auth_iv.len, tdata->digest.len,
2487 RTE_CRYPTO_AUTH_OP_GENERATE,
2488 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2492 /* alloc mbuf and set payload */
2493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2495 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2496 rte_pktmbuf_tailroom(ut_params->ibuf));
2498 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2499 /* Append data which is padded to a multiple of */
2500 /* the algorithms block size */
2501 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2502 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2504 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2506 /* Create SNOW 3G operation */
2507 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2508 tdata->auth_iv.data, tdata->auth_iv.len,
2509 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2510 tdata->validAuthLenInBits.len,
2515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2517 ut_params->obuf = ut_params->op->sym->m_src;
2518 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2519 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2520 + plaintext_pad_len;
2523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2526 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2527 "SNOW 3G Generated auth tag not as expected");
2533 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2535 struct crypto_testsuite_params *ts_params = &testsuite_params;
2536 struct crypto_unittest_params *ut_params = &unittest_params;
2539 unsigned plaintext_pad_len;
2540 unsigned plaintext_len;
2542 struct rte_cryptodev_info dev_info;
2544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2545 uint64_t feat_flags = dev_info.feature_flags;
2547 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2548 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2549 printf("Device doesn't support NON-Byte Aligned Data.\n");
2553 /* Verify the capabilities */
2554 struct rte_cryptodev_sym_capability_idx cap_idx;
2555 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2556 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2557 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2561 /* Create SNOW 3G session */
2562 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2563 tdata->key.data, tdata->key.len,
2564 tdata->auth_iv.len, tdata->digest.len,
2565 RTE_CRYPTO_AUTH_OP_VERIFY,
2566 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2569 /* alloc mbuf and set payload */
2570 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2572 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2573 rte_pktmbuf_tailroom(ut_params->ibuf));
2575 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2576 /* Append data which is padded to a multiple of */
2577 /* the algorithms block size */
2578 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2579 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2581 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2583 /* Create SNOW 3G operation */
2584 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2586 tdata->auth_iv.data, tdata->auth_iv.len,
2588 RTE_CRYPTO_AUTH_OP_VERIFY,
2589 tdata->validAuthLenInBits.len,
2594 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2596 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2597 ut_params->obuf = ut_params->op->sym->m_src;
2598 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2599 + plaintext_pad_len;
2602 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2611 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2613 struct crypto_testsuite_params *ts_params = &testsuite_params;
2614 struct crypto_unittest_params *ut_params = &unittest_params;
2617 unsigned plaintext_pad_len;
2618 unsigned plaintext_len;
2621 /* Verify the capabilities */
2622 struct rte_cryptodev_sym_capability_idx cap_idx;
2623 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2624 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2625 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2629 /* Create KASUMI session */
2630 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2631 tdata->key.data, tdata->key.len,
2632 0, tdata->digest.len,
2633 RTE_CRYPTO_AUTH_OP_GENERATE,
2634 RTE_CRYPTO_AUTH_KASUMI_F9);
2638 /* alloc mbuf and set payload */
2639 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2641 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2642 rte_pktmbuf_tailroom(ut_params->ibuf));
2644 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2645 /* Append data which is padded to a multiple of */
2646 /* the algorithms block size */
2647 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2648 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2650 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2652 /* Create KASUMI operation */
2653 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2655 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2656 tdata->plaintext.len,
2661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2662 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2665 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2668 ut_params->obuf = ut_params->op->sym->m_src;
2669 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2670 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2671 + plaintext_pad_len;
2674 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2677 DIGEST_BYTE_LENGTH_KASUMI_F9,
2678 "KASUMI Generated auth tag not as expected");
2684 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2686 struct crypto_testsuite_params *ts_params = &testsuite_params;
2687 struct crypto_unittest_params *ut_params = &unittest_params;
2690 unsigned plaintext_pad_len;
2691 unsigned plaintext_len;
2694 /* Verify the capabilities */
2695 struct rte_cryptodev_sym_capability_idx cap_idx;
2696 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2698 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2702 /* Create KASUMI session */
2703 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2704 tdata->key.data, tdata->key.len,
2705 0, tdata->digest.len,
2706 RTE_CRYPTO_AUTH_OP_VERIFY,
2707 RTE_CRYPTO_AUTH_KASUMI_F9);
2710 /* alloc mbuf and set payload */
2711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2714 rte_pktmbuf_tailroom(ut_params->ibuf));
2716 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2717 /* Append data which is padded to a multiple */
2718 /* of the algorithms block size */
2719 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2720 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2724 /* Create KASUMI operation */
2725 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2729 RTE_CRYPTO_AUTH_OP_VERIFY,
2730 tdata->plaintext.len,
2735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2738 ut_params->obuf = ut_params->op->sym->m_src;
2739 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2740 + plaintext_pad_len;
2743 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2752 test_snow3g_hash_generate_test_case_1(void)
2754 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2758 test_snow3g_hash_generate_test_case_2(void)
2760 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2764 test_snow3g_hash_generate_test_case_3(void)
2766 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2770 test_snow3g_hash_generate_test_case_4(void)
2772 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2776 test_snow3g_hash_generate_test_case_5(void)
2778 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2782 test_snow3g_hash_generate_test_case_6(void)
2784 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2788 test_snow3g_hash_verify_test_case_1(void)
2790 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2795 test_snow3g_hash_verify_test_case_2(void)
2797 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2801 test_snow3g_hash_verify_test_case_3(void)
2803 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2807 test_snow3g_hash_verify_test_case_4(void)
2809 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2813 test_snow3g_hash_verify_test_case_5(void)
2815 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2819 test_snow3g_hash_verify_test_case_6(void)
2821 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2825 test_kasumi_hash_generate_test_case_1(void)
2827 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2831 test_kasumi_hash_generate_test_case_2(void)
2833 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2837 test_kasumi_hash_generate_test_case_3(void)
2839 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2843 test_kasumi_hash_generate_test_case_4(void)
2845 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2849 test_kasumi_hash_generate_test_case_5(void)
2851 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2855 test_kasumi_hash_generate_test_case_6(void)
2857 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2861 test_kasumi_hash_verify_test_case_1(void)
2863 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2867 test_kasumi_hash_verify_test_case_2(void)
2869 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2873 test_kasumi_hash_verify_test_case_3(void)
2875 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2879 test_kasumi_hash_verify_test_case_4(void)
2881 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2885 test_kasumi_hash_verify_test_case_5(void)
2887 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2891 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2893 struct crypto_testsuite_params *ts_params = &testsuite_params;
2894 struct crypto_unittest_params *ut_params = &unittest_params;
2897 uint8_t *plaintext, *ciphertext;
2898 unsigned plaintext_pad_len;
2899 unsigned plaintext_len;
2901 /* Verify the capabilities */
2902 struct rte_cryptodev_sym_capability_idx cap_idx;
2903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2909 /* Create KASUMI session */
2910 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2911 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2912 RTE_CRYPTO_CIPHER_KASUMI_F8,
2913 tdata->key.data, tdata->key.len,
2914 tdata->cipher_iv.len);
2918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2920 /* Clear mbuf payload */
2921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2922 rte_pktmbuf_tailroom(ut_params->ibuf));
2924 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2925 /* Append data which is padded to a multiple */
2926 /* of the algorithms block size */
2927 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2928 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2930 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2932 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2934 /* Create KASUMI operation */
2935 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2936 tdata->cipher_iv.len,
2937 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2938 tdata->validCipherOffsetInBits.len);
2942 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2944 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2946 ut_params->obuf = ut_params->op->sym->m_dst;
2947 if (ut_params->obuf)
2948 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2950 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2952 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2954 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2955 (tdata->validCipherOffsetInBits.len >> 3);
2957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2959 reference_ciphertext,
2960 tdata->validCipherLenInBits.len,
2961 "KASUMI Ciphertext data not as expected");
2966 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2968 struct crypto_testsuite_params *ts_params = &testsuite_params;
2969 struct crypto_unittest_params *ut_params = &unittest_params;
2973 unsigned int plaintext_pad_len;
2974 unsigned int plaintext_len;
2976 uint8_t buffer[10000];
2977 const uint8_t *ciphertext;
2979 struct rte_cryptodev_info dev_info;
2981 /* Verify the capabilities */
2982 struct rte_cryptodev_sym_capability_idx cap_idx;
2983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2984 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2985 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2989 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2991 uint64_t feat_flags = dev_info.feature_flags;
2993 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2994 printf("Device doesn't support in-place scatter-gather. "
2999 /* Create KASUMI session */
3000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3002 RTE_CRYPTO_CIPHER_KASUMI_F8,
3003 tdata->key.data, tdata->key.len,
3004 tdata->cipher_iv.len);
3008 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3011 /* Append data which is padded to a multiple */
3012 /* of the algorithms block size */
3013 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3015 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3016 plaintext_pad_len, 10, 0);
3018 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3020 /* Create KASUMI operation */
3021 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3022 tdata->cipher_iv.len,
3023 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3024 tdata->validCipherOffsetInBits.len);
3028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3032 ut_params->obuf = ut_params->op->sym->m_dst;
3034 if (ut_params->obuf)
3035 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3036 plaintext_len, buffer);
3038 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3039 tdata->validCipherOffsetInBits.len >> 3,
3040 plaintext_len, buffer);
3043 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3045 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3046 (tdata->validCipherOffsetInBits.len >> 3);
3048 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3050 reference_ciphertext,
3051 tdata->validCipherLenInBits.len,
3052 "KASUMI Ciphertext data not as expected");
3057 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3059 struct crypto_testsuite_params *ts_params = &testsuite_params;
3060 struct crypto_unittest_params *ut_params = &unittest_params;
3063 uint8_t *plaintext, *ciphertext;
3064 unsigned plaintext_pad_len;
3065 unsigned plaintext_len;
3067 /* Verify the capabilities */
3068 struct rte_cryptodev_sym_capability_idx cap_idx;
3069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3070 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3071 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3075 /* Create KASUMI session */
3076 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3077 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3078 RTE_CRYPTO_CIPHER_KASUMI_F8,
3079 tdata->key.data, tdata->key.len,
3080 tdata->cipher_iv.len);
3084 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3085 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3087 /* Clear mbuf payload */
3088 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3089 rte_pktmbuf_tailroom(ut_params->ibuf));
3091 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3092 /* Append data which is padded to a multiple */
3093 /* of the algorithms block size */
3094 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3097 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3098 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3100 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3102 /* Create KASUMI operation */
3103 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3104 tdata->cipher_iv.len,
3105 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3106 tdata->validCipherOffsetInBits.len);
3110 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3112 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3114 ut_params->obuf = ut_params->op->sym->m_dst;
3115 if (ut_params->obuf)
3116 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3118 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3120 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3122 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3123 (tdata->validCipherOffsetInBits.len >> 3);
3125 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3127 reference_ciphertext,
3128 tdata->validCipherLenInBits.len,
3129 "KASUMI Ciphertext data not as expected");
3134 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3136 struct crypto_testsuite_params *ts_params = &testsuite_params;
3137 struct crypto_unittest_params *ut_params = &unittest_params;
3140 unsigned int plaintext_pad_len;
3141 unsigned int plaintext_len;
3143 const uint8_t *ciphertext;
3144 uint8_t buffer[2048];
3146 struct rte_cryptodev_info dev_info;
3148 /* Verify the capabilities */
3149 struct rte_cryptodev_sym_capability_idx cap_idx;
3150 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3151 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3152 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3156 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3158 uint64_t feat_flags = dev_info.feature_flags;
3159 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3160 printf("Device doesn't support out-of-place scatter-gather "
3161 "in both input and output mbufs. "
3166 /* Create KASUMI session */
3167 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3168 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3169 RTE_CRYPTO_CIPHER_KASUMI_F8,
3170 tdata->key.data, tdata->key.len,
3171 tdata->cipher_iv.len);
3175 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3176 /* Append data which is padded to a multiple */
3177 /* of the algorithms block size */
3178 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3180 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3181 plaintext_pad_len, 10, 0);
3182 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3183 plaintext_pad_len, 3, 0);
3185 /* Append data which is padded to a multiple */
3186 /* of the algorithms block size */
3187 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3189 /* Create KASUMI operation */
3190 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3191 tdata->cipher_iv.len,
3192 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3193 tdata->validCipherOffsetInBits.len);
3197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3199 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3201 ut_params->obuf = ut_params->op->sym->m_dst;
3202 if (ut_params->obuf)
3203 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3204 plaintext_pad_len, buffer);
3206 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3207 tdata->validCipherOffsetInBits.len >> 3,
3208 plaintext_pad_len, buffer);
3210 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3211 (tdata->validCipherOffsetInBits.len >> 3);
3213 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3215 reference_ciphertext,
3216 tdata->validCipherLenInBits.len,
3217 "KASUMI Ciphertext data not as expected");
3223 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3225 struct crypto_testsuite_params *ts_params = &testsuite_params;
3226 struct crypto_unittest_params *ut_params = &unittest_params;
3229 uint8_t *ciphertext, *plaintext;
3230 unsigned ciphertext_pad_len;
3231 unsigned ciphertext_len;
3233 /* Verify the capabilities */
3234 struct rte_cryptodev_sym_capability_idx cap_idx;
3235 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3236 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3241 /* Create KASUMI session */
3242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3243 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3244 RTE_CRYPTO_CIPHER_KASUMI_F8,
3245 tdata->key.data, tdata->key.len,
3246 tdata->cipher_iv.len);
3250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3253 /* Clear mbuf payload */
3254 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3255 rte_pktmbuf_tailroom(ut_params->ibuf));
3257 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3258 /* Append data which is padded to a multiple */
3259 /* of the algorithms block size */
3260 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3261 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3262 ciphertext_pad_len);
3263 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3264 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3266 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3268 /* Create KASUMI operation */
3269 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3270 tdata->cipher_iv.len,
3271 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3272 tdata->validCipherOffsetInBits.len);
3276 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_dst;
3281 if (ut_params->obuf)
3282 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3284 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3286 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3288 const uint8_t *reference_plaintext = tdata->plaintext.data +
3289 (tdata->validCipherOffsetInBits.len >> 3);
3291 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3293 reference_plaintext,
3294 tdata->validCipherLenInBits.len,
3295 "KASUMI Plaintext data not as expected");
3300 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3302 struct crypto_testsuite_params *ts_params = &testsuite_params;
3303 struct crypto_unittest_params *ut_params = &unittest_params;
3306 uint8_t *ciphertext, *plaintext;
3307 unsigned ciphertext_pad_len;
3308 unsigned ciphertext_len;
3310 /* Verify the capabilities */
3311 struct rte_cryptodev_sym_capability_idx cap_idx;
3312 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3313 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3314 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3318 /* Create KASUMI session */
3319 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3320 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3321 RTE_CRYPTO_CIPHER_KASUMI_F8,
3322 tdata->key.data, tdata->key.len,
3323 tdata->cipher_iv.len);
3327 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3329 /* Clear mbuf payload */
3330 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3331 rte_pktmbuf_tailroom(ut_params->ibuf));
3333 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3334 /* Append data which is padded to a multiple */
3335 /* of the algorithms block size */
3336 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3337 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3338 ciphertext_pad_len);
3339 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3341 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3343 /* Create KASUMI operation */
3344 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3345 tdata->cipher_iv.len,
3346 tdata->ciphertext.len,
3347 tdata->validCipherOffsetInBits.len);
3351 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3353 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3355 ut_params->obuf = ut_params->op->sym->m_dst;
3356 if (ut_params->obuf)
3357 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3359 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3361 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3363 const uint8_t *reference_plaintext = tdata->plaintext.data +
3364 (tdata->validCipherOffsetInBits.len >> 3);
3366 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3368 reference_plaintext,
3369 tdata->validCipherLenInBits.len,
3370 "KASUMI Plaintext data not as expected");
3375 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3377 struct crypto_testsuite_params *ts_params = &testsuite_params;
3378 struct crypto_unittest_params *ut_params = &unittest_params;
3381 uint8_t *plaintext, *ciphertext;
3382 unsigned plaintext_pad_len;
3383 unsigned plaintext_len;
3385 /* Verify the capabilities */
3386 struct rte_cryptodev_sym_capability_idx cap_idx;
3387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3393 /* Create SNOW 3G session */
3394 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3395 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3396 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3397 tdata->key.data, tdata->key.len,
3398 tdata->cipher_iv.len);
3402 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3404 /* Clear mbuf payload */
3405 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3406 rte_pktmbuf_tailroom(ut_params->ibuf));
3408 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3409 /* Append data which is padded to a multiple of */
3410 /* the algorithms block size */
3411 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3412 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3414 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3416 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3418 /* Create SNOW 3G operation */
3419 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3420 tdata->cipher_iv.len,
3421 tdata->validCipherLenInBits.len,
3426 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3428 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3430 ut_params->obuf = ut_params->op->sym->m_dst;
3431 if (ut_params->obuf)
3432 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3434 ciphertext = plaintext;
3436 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3439 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3441 tdata->ciphertext.data,
3442 tdata->validDataLenInBits.len,
3443 "SNOW 3G Ciphertext data not as expected");
3449 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3451 struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 struct crypto_unittest_params *ut_params = &unittest_params;
3453 uint8_t *plaintext, *ciphertext;
3456 unsigned plaintext_pad_len;
3457 unsigned plaintext_len;
3459 /* Verify the capabilities */
3460 struct rte_cryptodev_sym_capability_idx cap_idx;
3461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3462 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3467 /* Create SNOW 3G session */
3468 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3469 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3470 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3471 tdata->key.data, tdata->key.len,
3472 tdata->cipher_iv.len);
3476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3477 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3480 "Failed to allocate input buffer in mempool");
3481 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3482 "Failed to allocate output buffer in mempool");
3484 /* Clear mbuf payload */
3485 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3486 rte_pktmbuf_tailroom(ut_params->ibuf));
3488 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3489 /* Append data which is padded to a multiple of */
3490 /* the algorithms block size */
3491 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3492 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3494 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3495 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3497 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3499 /* Create SNOW 3G operation */
3500 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3501 tdata->cipher_iv.len,
3502 tdata->validCipherLenInBits.len,
3507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 ut_params->obuf = ut_params->op->sym->m_dst;
3512 if (ut_params->obuf)
3513 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3515 ciphertext = plaintext;
3517 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3520 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3522 tdata->ciphertext.data,
3523 tdata->validDataLenInBits.len,
3524 "SNOW 3G Ciphertext data not as expected");
3529 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3531 struct crypto_testsuite_params *ts_params = &testsuite_params;
3532 struct crypto_unittest_params *ut_params = &unittest_params;
3535 unsigned int plaintext_pad_len;
3536 unsigned int plaintext_len;
3537 uint8_t buffer[10000];
3538 const uint8_t *ciphertext;
3540 struct rte_cryptodev_info dev_info;
3542 /* Verify the capabilities */
3543 struct rte_cryptodev_sym_capability_idx cap_idx;
3544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3545 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3550 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3552 uint64_t feat_flags = dev_info.feature_flags;
3554 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3555 printf("Device doesn't support out-of-place scatter-gather "
3556 "in both input and output mbufs. "
3561 /* Create SNOW 3G session */
3562 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3563 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3564 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3565 tdata->key.data, tdata->key.len,
3566 tdata->cipher_iv.len);
3570 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3571 /* Append data which is padded to a multiple of */
3572 /* the algorithms block size */
3573 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3575 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3576 plaintext_pad_len, 10, 0);
3577 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 3, 0);
3580 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3581 "Failed to allocate input buffer in mempool");
3582 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3583 "Failed to allocate output buffer in mempool");
3585 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3587 /* Create SNOW 3G operation */
3588 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3589 tdata->cipher_iv.len,
3590 tdata->validCipherLenInBits.len,
3595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3597 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3599 ut_params->obuf = ut_params->op->sym->m_dst;
3600 if (ut_params->obuf)
3601 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3602 plaintext_len, buffer);
3604 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3605 plaintext_len, buffer);
3607 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3610 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3612 tdata->ciphertext.data,
3613 tdata->validDataLenInBits.len,
3614 "SNOW 3G Ciphertext data not as expected");
3619 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3621 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3623 uint8_t curr_byte, prev_byte;
3624 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3625 uint8_t lower_byte_mask = (1 << offset) - 1;
3628 prev_byte = buffer[0];
3629 buffer[0] >>= offset;
3631 for (i = 1; i < length_in_bytes; i++) {
3632 curr_byte = buffer[i];
3633 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3634 (curr_byte >> offset);
3635 prev_byte = curr_byte;
3640 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3642 struct crypto_testsuite_params *ts_params = &testsuite_params;
3643 struct crypto_unittest_params *ut_params = &unittest_params;
3644 uint8_t *plaintext, *ciphertext;
3646 uint32_t plaintext_len;
3647 uint32_t plaintext_pad_len;
3648 uint8_t extra_offset = 4;
3649 uint8_t *expected_ciphertext_shifted;
3650 struct rte_cryptodev_info dev_info;
3652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3653 uint64_t feat_flags = dev_info.feature_flags;
3655 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3656 ((tdata->validDataLenInBits.len % 8) != 0)) {
3657 printf("Device doesn't support NON-Byte Aligned Data.\n");
3661 /* Verify the capabilities */
3662 struct rte_cryptodev_sym_capability_idx cap_idx;
3663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3664 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3669 /* Create SNOW 3G session */
3670 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3671 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3672 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3673 tdata->key.data, tdata->key.len,
3674 tdata->cipher_iv.len);
3678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3681 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3682 "Failed to allocate input buffer in mempool");
3683 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3684 "Failed to allocate output buffer in mempool");
3686 /* Clear mbuf payload */
3687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 rte_pktmbuf_tailroom(ut_params->ibuf));
3690 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3692 * Append data which is padded to a
3693 * multiple of the algorithms block size
3695 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3697 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3700 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3702 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3703 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3705 #ifdef RTE_APP_TEST_DEBUG
3706 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3708 /* Create SNOW 3G operation */
3709 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3710 tdata->cipher_iv.len,
3711 tdata->validCipherLenInBits.len,
3716 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3720 ut_params->obuf = ut_params->op->sym->m_dst;
3721 if (ut_params->obuf)
3722 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3724 ciphertext = plaintext;
3726 #ifdef RTE_APP_TEST_DEBUG
3727 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3730 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3732 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3733 "failed to reserve memory for ciphertext shifted\n");
3735 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3736 ceil_byte_length(tdata->ciphertext.len));
3737 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3740 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3742 expected_ciphertext_shifted,
3743 tdata->validDataLenInBits.len,
3745 "SNOW 3G Ciphertext data not as expected");
3749 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3751 struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 struct crypto_unittest_params *ut_params = &unittest_params;
3756 uint8_t *plaintext, *ciphertext;
3757 unsigned ciphertext_pad_len;
3758 unsigned ciphertext_len;
3760 /* Verify the capabilities */
3761 struct rte_cryptodev_sym_capability_idx cap_idx;
3762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3763 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3768 /* Create SNOW 3G session */
3769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3770 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3771 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3772 tdata->key.data, tdata->key.len,
3773 tdata->cipher_iv.len);
3777 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3779 /* Clear mbuf payload */
3780 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3781 rte_pktmbuf_tailroom(ut_params->ibuf));
3783 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3784 /* Append data which is padded to a multiple of */
3785 /* the algorithms block size */
3786 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3787 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3788 ciphertext_pad_len);
3789 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3791 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3793 /* Create SNOW 3G operation */
3794 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3795 tdata->cipher_iv.len,
3796 tdata->validCipherLenInBits.len,
3797 tdata->cipher.offset_bits);
3801 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3803 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3804 ut_params->obuf = ut_params->op->sym->m_dst;
3805 if (ut_params->obuf)
3806 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3808 plaintext = ciphertext;
3810 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3813 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3814 tdata->plaintext.data,
3815 tdata->validDataLenInBits.len,
3816 "SNOW 3G Plaintext data not as expected");
3820 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3822 struct crypto_testsuite_params *ts_params = &testsuite_params;
3823 struct crypto_unittest_params *ut_params = &unittest_params;
3827 uint8_t *plaintext, *ciphertext;
3828 unsigned ciphertext_pad_len;
3829 unsigned ciphertext_len;
3831 /* Verify the capabilities */
3832 struct rte_cryptodev_sym_capability_idx cap_idx;
3833 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3834 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3839 /* Create SNOW 3G session */
3840 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3841 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3842 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3843 tdata->key.data, tdata->key.len,
3844 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3849 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3852 "Failed to allocate input buffer");
3853 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3854 "Failed to allocate output buffer");
3856 /* Clear mbuf payload */
3857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3858 rte_pktmbuf_tailroom(ut_params->ibuf));
3860 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3861 rte_pktmbuf_tailroom(ut_params->obuf));
3863 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3864 /* Append data which is padded to a multiple of */
3865 /* the algorithms block size */
3866 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3867 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 ciphertext_pad_len);
3869 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3870 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3874 /* Create SNOW 3G operation */
3875 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3876 tdata->cipher_iv.len,
3877 tdata->validCipherLenInBits.len,
3882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3885 ut_params->obuf = ut_params->op->sym->m_dst;
3886 if (ut_params->obuf)
3887 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3889 plaintext = ciphertext;
3891 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3895 tdata->plaintext.data,
3896 tdata->validDataLenInBits.len,
3897 "SNOW 3G Plaintext data not as expected");
3902 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3904 struct crypto_testsuite_params *ts_params = &testsuite_params;
3905 struct crypto_unittest_params *ut_params = &unittest_params;
3909 uint8_t *plaintext, *ciphertext;
3910 unsigned int plaintext_pad_len;
3911 unsigned int plaintext_len;
3913 struct rte_cryptodev_info dev_info;
3914 struct rte_cryptodev_sym_capability_idx cap_idx;
3916 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3917 uint64_t feat_flags = dev_info.feature_flags;
3919 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3920 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3921 (tdata->validDataLenInBits.len % 8 != 0))) {
3922 printf("Device doesn't support NON-Byte Aligned Data.\n");
3926 /* Check if device supports ZUC EEA3 */
3927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3928 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3930 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3934 /* Check if device supports ZUC EIA3 */
3935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3936 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3938 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3942 /* Create ZUC session */
3943 retval = create_zuc_cipher_auth_encrypt_generate_session(
3944 ts_params->valid_devs[0],
3948 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3950 /* clear mbuf payload */
3951 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3952 rte_pktmbuf_tailroom(ut_params->ibuf));
3954 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3955 /* Append data which is padded to a multiple of */
3956 /* the algorithms block size */
3957 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3958 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3960 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3962 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3964 /* Create ZUC operation */
3965 retval = create_zuc_cipher_hash_generate_operation(tdata);
3969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3972 ut_params->obuf = ut_params->op->sym->m_src;
3973 if (ut_params->obuf)
3974 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3976 ciphertext = plaintext;
3978 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 tdata->ciphertext.data,
3983 tdata->validDataLenInBits.len,
3984 "ZUC Ciphertext data not as expected");
3986 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3987 + plaintext_pad_len;
3990 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3994 "ZUC Generated auth tag not as expected");
3999 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4001 struct crypto_testsuite_params *ts_params = &testsuite_params;
4002 struct crypto_unittest_params *ut_params = &unittest_params;
4006 uint8_t *plaintext, *ciphertext;
4007 unsigned plaintext_pad_len;
4008 unsigned plaintext_len;
4010 /* Verify the capabilities */
4011 struct rte_cryptodev_sym_capability_idx cap_idx;
4012 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4013 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4014 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4018 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4023 /* Create SNOW 3G session */
4024 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4025 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4026 RTE_CRYPTO_AUTH_OP_GENERATE,
4027 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4029 tdata->key.data, tdata->key.len,
4030 tdata->auth_iv.len, tdata->digest.len,
4031 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 /* clear mbuf payload */
4037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4038 rte_pktmbuf_tailroom(ut_params->ibuf));
4040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4041 /* Append data which is padded to a multiple of */
4042 /* the algorithms block size */
4043 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4044 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4048 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4052 tdata->digest.len, tdata->auth_iv.data,
4054 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4055 tdata->cipher_iv.data, tdata->cipher_iv.len,
4056 tdata->validCipherLenInBits.len,
4058 tdata->validAuthLenInBits.len,
4064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4066 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4067 ut_params->obuf = ut_params->op->sym->m_src;
4068 if (ut_params->obuf)
4069 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4071 ciphertext = plaintext;
4073 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4077 tdata->ciphertext.data,
4078 tdata->validDataLenInBits.len,
4079 "SNOW 3G Ciphertext data not as expected");
4081 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4082 + plaintext_pad_len;
4085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4088 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4089 "SNOW 3G Generated auth tag not as expected");
4094 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4095 uint8_t op_mode, uint8_t verify)
4097 struct crypto_testsuite_params *ts_params = &testsuite_params;
4098 struct crypto_unittest_params *ut_params = &unittest_params;
4102 uint8_t *plaintext = NULL, *ciphertext = NULL;
4103 unsigned int plaintext_pad_len;
4104 unsigned int plaintext_len;
4105 unsigned int ciphertext_pad_len;
4106 unsigned int ciphertext_len;
4108 struct rte_cryptodev_info dev_info;
4110 /* Verify the capabilities */
4111 struct rte_cryptodev_sym_capability_idx cap_idx;
4112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4113 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4114 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4117 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4118 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4119 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4123 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4125 uint64_t feat_flags = dev_info.feature_flags;
4127 if (op_mode == OUT_OF_PLACE) {
4128 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4129 printf("Device doesn't support digest encrypted.\n");
4134 /* Create SNOW 3G session */
4135 retval = create_wireless_algo_auth_cipher_session(
4136 ts_params->valid_devs[0],
4137 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4138 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4139 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4140 : RTE_CRYPTO_AUTH_OP_GENERATE),
4141 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4142 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4143 tdata->key.data, tdata->key.len,
4144 tdata->auth_iv.len, tdata->digest.len,
4145 tdata->cipher_iv.len);
4150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4151 if (op_mode == OUT_OF_PLACE)
4152 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4154 /* clear mbuf payload */
4155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4156 rte_pktmbuf_tailroom(ut_params->ibuf));
4157 if (op_mode == OUT_OF_PLACE)
4158 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4159 rte_pktmbuf_tailroom(ut_params->obuf));
4161 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4162 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4163 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4164 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4167 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4168 ciphertext_pad_len);
4169 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4170 if (op_mode == OUT_OF_PLACE)
4171 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4172 debug_hexdump(stdout, "ciphertext:", ciphertext,
4175 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4177 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4178 if (op_mode == OUT_OF_PLACE)
4179 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4180 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4183 /* Create SNOW 3G operation */
4184 retval = create_wireless_algo_auth_cipher_operation(
4185 tdata->digest.data, tdata->digest.len,
4186 tdata->cipher_iv.data, tdata->cipher_iv.len,
4187 tdata->auth_iv.data, tdata->auth_iv.len,
4188 (tdata->digest.offset_bytes == 0 ?
4189 (verify ? ciphertext_pad_len : plaintext_pad_len)
4190 : tdata->digest.offset_bytes),
4191 tdata->validCipherLenInBits.len,
4192 tdata->cipher.offset_bits,
4193 tdata->validAuthLenInBits.len,
4194 tdata->auth.offset_bits,
4195 op_mode, 0, verify);
4200 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4205 ut_params->obuf = (op_mode == IN_PLACE ?
4206 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4209 if (ut_params->obuf)
4210 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4213 plaintext = ciphertext +
4214 (tdata->cipher.offset_bits >> 3);
4216 debug_hexdump(stdout, "plaintext:", plaintext,
4217 (tdata->plaintext.len >> 3) - tdata->digest.len);
4218 debug_hexdump(stdout, "plaintext expected:",
4219 tdata->plaintext.data,
4220 (tdata->plaintext.len >> 3) - tdata->digest.len);
4222 if (ut_params->obuf)
4223 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4226 ciphertext = plaintext;
4228 debug_hexdump(stdout, "ciphertext:", ciphertext,
4230 debug_hexdump(stdout, "ciphertext expected:",
4231 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4233 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4234 + (tdata->digest.offset_bytes == 0 ?
4235 plaintext_pad_len : tdata->digest.offset_bytes);
4237 debug_hexdump(stdout, "digest:", ut_params->digest,
4239 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4245 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4247 tdata->plaintext.data,
4248 tdata->plaintext.len >> 3,
4249 "SNOW 3G Plaintext data not as expected");
4251 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4253 tdata->ciphertext.data,
4254 tdata->validDataLenInBits.len,
4255 "SNOW 3G Ciphertext data not as expected");
4257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4260 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4261 "SNOW 3G Generated auth tag not as expected");
4267 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4268 uint8_t op_mode, uint8_t verify)
4270 struct crypto_testsuite_params *ts_params = &testsuite_params;
4271 struct crypto_unittest_params *ut_params = &unittest_params;
4275 const uint8_t *plaintext = NULL;
4276 const uint8_t *ciphertext = NULL;
4277 const uint8_t *digest = NULL;
4278 unsigned int plaintext_pad_len;
4279 unsigned int plaintext_len;
4280 unsigned int ciphertext_pad_len;
4281 unsigned int ciphertext_len;
4282 uint8_t buffer[10000];
4283 uint8_t digest_buffer[10000];
4285 struct rte_cryptodev_info dev_info;
4287 /* Verify the capabilities */
4288 struct rte_cryptodev_sym_capability_idx cap_idx;
4289 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4290 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4291 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4294 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4295 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4302 uint64_t feat_flags = dev_info.feature_flags;
4304 if (op_mode == IN_PLACE) {
4305 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4306 printf("Device doesn't support in-place scatter-gather "
4307 "in both input and output mbufs.\n");
4311 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4312 printf("Device doesn't support out-of-place scatter-gather "
4313 "in both input and output mbufs.\n");
4316 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4317 printf("Device doesn't support digest encrypted.\n");
4322 /* Create SNOW 3G session */
4323 retval = create_wireless_algo_auth_cipher_session(
4324 ts_params->valid_devs[0],
4325 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4326 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4327 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4328 : RTE_CRYPTO_AUTH_OP_GENERATE),
4329 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4330 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4331 tdata->key.data, tdata->key.len,
4332 tdata->auth_iv.len, tdata->digest.len,
4333 tdata->cipher_iv.len);
4338 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4339 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4340 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4341 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4343 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4344 plaintext_pad_len, 15, 0);
4345 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4346 "Failed to allocate input buffer in mempool");
4348 if (op_mode == OUT_OF_PLACE) {
4349 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4350 plaintext_pad_len, 15, 0);
4351 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4352 "Failed to allocate output buffer in mempool");
4356 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4357 tdata->ciphertext.data);
4358 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4359 ciphertext_len, buffer);
4360 debug_hexdump(stdout, "ciphertext:", ciphertext,
4363 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4364 tdata->plaintext.data);
4365 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4366 plaintext_len, buffer);
4367 debug_hexdump(stdout, "plaintext:", plaintext,
4370 memset(buffer, 0, sizeof(buffer));
4372 /* Create SNOW 3G operation */
4373 retval = create_wireless_algo_auth_cipher_operation(
4374 tdata->digest.data, tdata->digest.len,
4375 tdata->cipher_iv.data, tdata->cipher_iv.len,
4376 tdata->auth_iv.data, tdata->auth_iv.len,
4377 (tdata->digest.offset_bytes == 0 ?
4378 (verify ? ciphertext_pad_len : plaintext_pad_len)
4379 : tdata->digest.offset_bytes),
4380 tdata->validCipherLenInBits.len,
4381 tdata->cipher.offset_bits,
4382 tdata->validAuthLenInBits.len,
4383 tdata->auth.offset_bits,
4384 op_mode, 1, verify);
4389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4392 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4394 ut_params->obuf = (op_mode == IN_PLACE ?
4395 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4398 if (ut_params->obuf)
4399 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4400 plaintext_len, buffer);
4402 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4403 plaintext_len, buffer);
4405 debug_hexdump(stdout, "plaintext:", plaintext,
4406 (tdata->plaintext.len >> 3) - tdata->digest.len);
4407 debug_hexdump(stdout, "plaintext expected:",
4408 tdata->plaintext.data,
4409 (tdata->plaintext.len >> 3) - tdata->digest.len);
4411 if (ut_params->obuf)
4412 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4413 ciphertext_len, buffer);
4415 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4416 ciphertext_len, buffer);
4418 debug_hexdump(stdout, "ciphertext:", ciphertext,
4420 debug_hexdump(stdout, "ciphertext expected:",
4421 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4423 if (ut_params->obuf)
4424 digest = rte_pktmbuf_read(ut_params->obuf,
4425 (tdata->digest.offset_bytes == 0 ?
4426 plaintext_pad_len : tdata->digest.offset_bytes),
4427 tdata->digest.len, digest_buffer);
4429 digest = rte_pktmbuf_read(ut_params->ibuf,
4430 (tdata->digest.offset_bytes == 0 ?
4431 plaintext_pad_len : tdata->digest.offset_bytes),
4432 tdata->digest.len, digest_buffer);
4434 debug_hexdump(stdout, "digest:", digest,
4436 debug_hexdump(stdout, "digest expected:",
4437 tdata->digest.data, tdata->digest.len);
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4444 tdata->plaintext.data,
4445 tdata->plaintext.len >> 3,
4446 "SNOW 3G Plaintext data not as expected");
4448 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4450 tdata->ciphertext.data,
4451 tdata->validDataLenInBits.len,
4452 "SNOW 3G Ciphertext data not as expected");
4454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4457 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4458 "SNOW 3G Generated auth tag not as expected");
4464 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4465 uint8_t op_mode, uint8_t verify)
4467 struct crypto_testsuite_params *ts_params = &testsuite_params;
4468 struct crypto_unittest_params *ut_params = &unittest_params;
4472 uint8_t *plaintext = NULL, *ciphertext = NULL;
4473 unsigned int plaintext_pad_len;
4474 unsigned int plaintext_len;
4475 unsigned int ciphertext_pad_len;
4476 unsigned int ciphertext_len;
4478 struct rte_cryptodev_info dev_info;
4480 /* Verify the capabilities */
4481 struct rte_cryptodev_sym_capability_idx cap_idx;
4482 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4483 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4484 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4489 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4493 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4495 uint64_t feat_flags = dev_info.feature_flags;
4497 if (op_mode == OUT_OF_PLACE) {
4498 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4499 printf("Device doesn't support digest encrypted.\n");
4504 /* Create KASUMI session */
4505 retval = create_wireless_algo_auth_cipher_session(
4506 ts_params->valid_devs[0],
4507 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4508 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4509 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4510 : RTE_CRYPTO_AUTH_OP_GENERATE),
4511 RTE_CRYPTO_AUTH_KASUMI_F9,
4512 RTE_CRYPTO_CIPHER_KASUMI_F8,
4513 tdata->key.data, tdata->key.len,
4514 0, tdata->digest.len,
4515 tdata->cipher_iv.len);
4520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4521 if (op_mode == OUT_OF_PLACE)
4522 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4524 /* clear mbuf payload */
4525 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4526 rte_pktmbuf_tailroom(ut_params->ibuf));
4527 if (op_mode == OUT_OF_PLACE)
4528 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4529 rte_pktmbuf_tailroom(ut_params->obuf));
4531 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4532 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4533 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4534 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4537 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4538 ciphertext_pad_len);
4539 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4540 if (op_mode == OUT_OF_PLACE)
4541 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4542 debug_hexdump(stdout, "ciphertext:", ciphertext,
4545 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4547 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4548 if (op_mode == OUT_OF_PLACE)
4549 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4550 debug_hexdump(stdout, "plaintext:", plaintext,
4554 /* Create KASUMI operation */
4555 retval = create_wireless_algo_auth_cipher_operation(
4556 tdata->digest.data, tdata->digest.len,
4557 tdata->cipher_iv.data, tdata->cipher_iv.len,
4559 (tdata->digest.offset_bytes == 0 ?
4560 (verify ? ciphertext_pad_len : plaintext_pad_len)
4561 : tdata->digest.offset_bytes),
4562 tdata->validCipherLenInBits.len,
4563 tdata->validCipherOffsetInBits.len,
4564 tdata->validAuthLenInBits.len,
4566 op_mode, 0, verify);
4571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4574 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4576 ut_params->obuf = (op_mode == IN_PLACE ?
4577 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4581 if (ut_params->obuf)
4582 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4585 plaintext = ciphertext;
4587 debug_hexdump(stdout, "plaintext:", plaintext,
4588 (tdata->plaintext.len >> 3) - tdata->digest.len);
4589 debug_hexdump(stdout, "plaintext expected:",
4590 tdata->plaintext.data,
4591 (tdata->plaintext.len >> 3) - tdata->digest.len);
4593 if (ut_params->obuf)
4594 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4597 ciphertext = plaintext;
4599 debug_hexdump(stdout, "ciphertext:", ciphertext,
4601 debug_hexdump(stdout, "ciphertext expected:",
4602 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4604 ut_params->digest = rte_pktmbuf_mtod(
4605 ut_params->obuf, uint8_t *) +
4606 (tdata->digest.offset_bytes == 0 ?
4607 plaintext_pad_len : tdata->digest.offset_bytes);
4609 debug_hexdump(stdout, "digest:", ut_params->digest,
4611 debug_hexdump(stdout, "digest expected:",
4612 tdata->digest.data, tdata->digest.len);
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4619 tdata->plaintext.data,
4620 tdata->plaintext.len >> 3,
4621 "KASUMI Plaintext data not as expected");
4623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4625 tdata->ciphertext.data,
4626 tdata->ciphertext.len >> 3,
4627 "KASUMI Ciphertext data not as expected");
4629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4632 DIGEST_BYTE_LENGTH_KASUMI_F9,
4633 "KASUMI Generated auth tag not as expected");
4639 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4640 uint8_t op_mode, uint8_t verify)
4642 struct crypto_testsuite_params *ts_params = &testsuite_params;
4643 struct crypto_unittest_params *ut_params = &unittest_params;
4647 const uint8_t *plaintext = NULL;
4648 const uint8_t *ciphertext = NULL;
4649 const uint8_t *digest = NULL;
4650 unsigned int plaintext_pad_len;
4651 unsigned int plaintext_len;
4652 unsigned int ciphertext_pad_len;
4653 unsigned int ciphertext_len;
4654 uint8_t buffer[10000];
4655 uint8_t digest_buffer[10000];
4657 struct rte_cryptodev_info dev_info;
4659 /* Verify the capabilities */
4660 struct rte_cryptodev_sym_capability_idx cap_idx;
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4662 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4666 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4667 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4674 uint64_t feat_flags = dev_info.feature_flags;
4676 if (op_mode == IN_PLACE) {
4677 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4678 printf("Device doesn't support in-place scatter-gather "
4679 "in both input and output mbufs.\n");
4683 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4684 printf("Device doesn't support out-of-place scatter-gather "
4685 "in both input and output mbufs.\n");
4688 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4689 printf("Device doesn't support digest encrypted.\n");
4694 /* Create KASUMI session */
4695 retval = create_wireless_algo_auth_cipher_session(
4696 ts_params->valid_devs[0],
4697 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4698 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4699 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4700 : RTE_CRYPTO_AUTH_OP_GENERATE),
4701 RTE_CRYPTO_AUTH_KASUMI_F9,
4702 RTE_CRYPTO_CIPHER_KASUMI_F8,
4703 tdata->key.data, tdata->key.len,
4704 0, tdata->digest.len,
4705 tdata->cipher_iv.len);
4710 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4711 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4712 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4713 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4715 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4716 plaintext_pad_len, 15, 0);
4717 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4718 "Failed to allocate input buffer in mempool");
4720 if (op_mode == OUT_OF_PLACE) {
4721 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4722 plaintext_pad_len, 15, 0);
4723 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4724 "Failed to allocate output buffer in mempool");
4728 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4729 tdata->ciphertext.data);
4730 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4731 ciphertext_len, buffer);
4732 debug_hexdump(stdout, "ciphertext:", ciphertext,
4735 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4736 tdata->plaintext.data);
4737 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4738 plaintext_len, buffer);
4739 debug_hexdump(stdout, "plaintext:", plaintext,
4742 memset(buffer, 0, sizeof(buffer));
4744 /* Create KASUMI operation */
4745 retval = create_wireless_algo_auth_cipher_operation(
4746 tdata->digest.data, tdata->digest.len,
4747 tdata->cipher_iv.data, tdata->cipher_iv.len,
4749 (tdata->digest.offset_bytes == 0 ?
4750 (verify ? ciphertext_pad_len : plaintext_pad_len)
4751 : tdata->digest.offset_bytes),
4752 tdata->validCipherLenInBits.len,
4753 tdata->validCipherOffsetInBits.len,
4754 tdata->validAuthLenInBits.len,
4756 op_mode, 1, verify);
4761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4764 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4766 ut_params->obuf = (op_mode == IN_PLACE ?
4767 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4770 if (ut_params->obuf)
4771 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4772 plaintext_len, buffer);
4774 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4775 plaintext_len, buffer);
4777 debug_hexdump(stdout, "plaintext:", plaintext,
4778 (tdata->plaintext.len >> 3) - tdata->digest.len);
4779 debug_hexdump(stdout, "plaintext expected:",
4780 tdata->plaintext.data,
4781 (tdata->plaintext.len >> 3) - tdata->digest.len);
4783 if (ut_params->obuf)
4784 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4785 ciphertext_len, buffer);
4787 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4788 ciphertext_len, buffer);
4790 debug_hexdump(stdout, "ciphertext:", ciphertext,
4792 debug_hexdump(stdout, "ciphertext expected:",
4793 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4795 if (ut_params->obuf)
4796 digest = rte_pktmbuf_read(ut_params->obuf,
4797 (tdata->digest.offset_bytes == 0 ?
4798 plaintext_pad_len : tdata->digest.offset_bytes),
4799 tdata->digest.len, digest_buffer);
4801 digest = rte_pktmbuf_read(ut_params->ibuf,
4802 (tdata->digest.offset_bytes == 0 ?
4803 plaintext_pad_len : tdata->digest.offset_bytes),
4804 tdata->digest.len, digest_buffer);
4806 debug_hexdump(stdout, "digest:", digest,
4808 debug_hexdump(stdout, "digest expected:",
4809 tdata->digest.data, tdata->digest.len);
4814 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4816 tdata->plaintext.data,
4817 tdata->plaintext.len >> 3,
4818 "KASUMI Plaintext data not as expected");
4820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4822 tdata->ciphertext.data,
4823 tdata->validDataLenInBits.len,
4824 "KASUMI Ciphertext data not as expected");
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4829 DIGEST_BYTE_LENGTH_KASUMI_F9,
4830 "KASUMI Generated auth tag not as expected");
4836 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4838 struct crypto_testsuite_params *ts_params = &testsuite_params;
4839 struct crypto_unittest_params *ut_params = &unittest_params;
4843 uint8_t *plaintext, *ciphertext;
4844 unsigned plaintext_pad_len;
4845 unsigned plaintext_len;
4847 /* Verify the capabilities */
4848 struct rte_cryptodev_sym_capability_idx cap_idx;
4849 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4850 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4851 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4854 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4855 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4856 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4860 /* Create KASUMI session */
4861 retval = create_wireless_algo_cipher_auth_session(
4862 ts_params->valid_devs[0],
4863 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4864 RTE_CRYPTO_AUTH_OP_GENERATE,
4865 RTE_CRYPTO_AUTH_KASUMI_F9,
4866 RTE_CRYPTO_CIPHER_KASUMI_F8,
4867 tdata->key.data, tdata->key.len,
4868 0, tdata->digest.len,
4869 tdata->cipher_iv.len);
4873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4875 /* clear mbuf payload */
4876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4877 rte_pktmbuf_tailroom(ut_params->ibuf));
4879 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4880 /* Append data which is padded to a multiple of */
4881 /* the algorithms block size */
4882 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4883 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4885 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4887 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4889 /* Create KASUMI operation */
4890 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4891 tdata->digest.len, NULL, 0,
4892 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4893 tdata->cipher_iv.data, tdata->cipher_iv.len,
4894 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4895 tdata->validCipherOffsetInBits.len,
4896 tdata->validAuthLenInBits.len,
4902 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4904 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4906 if (ut_params->op->sym->m_dst)
4907 ut_params->obuf = ut_params->op->sym->m_dst;
4909 ut_params->obuf = ut_params->op->sym->m_src;
4911 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4912 tdata->validCipherOffsetInBits.len >> 3);
4914 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4915 + plaintext_pad_len;
4917 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4918 (tdata->validCipherOffsetInBits.len >> 3);
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4922 reference_ciphertext,
4923 tdata->validCipherLenInBits.len,
4924 "KASUMI Ciphertext data not as expected");
4927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4930 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4931 "KASUMI Generated auth tag not as expected");
4936 test_zuc_encryption(const struct wireless_test_data *tdata)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4939 struct crypto_unittest_params *ut_params = &unittest_params;
4942 uint8_t *plaintext, *ciphertext;
4943 unsigned plaintext_pad_len;
4944 unsigned plaintext_len;
4946 struct rte_cryptodev_sym_capability_idx cap_idx;
4948 /* Check if device supports ZUC EEA3 */
4949 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4950 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4956 /* Create ZUC session */
4957 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4958 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4959 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4960 tdata->key.data, tdata->key.len,
4961 tdata->cipher_iv.len);
4965 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4967 /* Clear mbuf payload */
4968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4969 rte_pktmbuf_tailroom(ut_params->ibuf));
4971 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4972 /* Append data which is padded to a multiple */
4973 /* of the algorithms block size */
4974 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4975 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4977 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4979 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4981 /* Create ZUC operation */
4982 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4983 tdata->cipher_iv.len,
4984 tdata->plaintext.len,
4989 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4991 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4993 ut_params->obuf = ut_params->op->sym->m_dst;
4994 if (ut_params->obuf)
4995 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4997 ciphertext = plaintext;
4999 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5004 tdata->ciphertext.data,
5005 tdata->validCipherLenInBits.len,
5006 "ZUC Ciphertext data not as expected");
5011 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5013 struct crypto_testsuite_params *ts_params = &testsuite_params;
5014 struct crypto_unittest_params *ut_params = &unittest_params;
5018 unsigned int plaintext_pad_len;
5019 unsigned int plaintext_len;
5020 const uint8_t *ciphertext;
5021 uint8_t ciphertext_buffer[2048];
5022 struct rte_cryptodev_info dev_info;
5024 struct rte_cryptodev_sym_capability_idx cap_idx;
5026 /* Check if device supports ZUC EEA3 */
5027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5028 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5030 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5034 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5036 uint64_t feat_flags = dev_info.feature_flags;
5038 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5039 printf("Device doesn't support in-place scatter-gather. "
5044 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5046 /* Append data which is padded to a multiple */
5047 /* of the algorithms block size */
5048 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5050 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5051 plaintext_pad_len, 10, 0);
5053 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5054 tdata->plaintext.data);
5056 /* Create ZUC session */
5057 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5058 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5059 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5060 tdata->key.data, tdata->key.len,
5061 tdata->cipher_iv.len);
5065 /* Clear mbuf payload */
5067 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5069 /* Create ZUC operation */
5070 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5071 tdata->cipher_iv.len, tdata->plaintext.len,
5076 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5078 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5080 ut_params->obuf = ut_params->op->sym->m_dst;
5081 if (ut_params->obuf)
5082 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5083 0, plaintext_len, ciphertext_buffer);
5085 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5086 0, plaintext_len, ciphertext_buffer);
5089 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5092 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5094 tdata->ciphertext.data,
5095 tdata->validCipherLenInBits.len,
5096 "ZUC Ciphertext data not as expected");
5102 test_zuc_authentication(const struct wireless_test_data *tdata)
5104 struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 struct crypto_unittest_params *ut_params = &unittest_params;
5108 unsigned plaintext_pad_len;
5109 unsigned plaintext_len;
5112 struct rte_cryptodev_sym_capability_idx cap_idx;
5113 struct rte_cryptodev_info dev_info;
5115 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5116 uint64_t feat_flags = dev_info.feature_flags;
5118 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5119 (tdata->validAuthLenInBits.len % 8 != 0)) {
5120 printf("Device doesn't support NON-Byte Aligned Data.\n");
5124 /* Check if device supports ZUC EIA3 */
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5126 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5128 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5132 /* Create ZUC session */
5133 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5134 tdata->key.data, tdata->key.len,
5135 tdata->auth_iv.len, tdata->digest.len,
5136 RTE_CRYPTO_AUTH_OP_GENERATE,
5137 RTE_CRYPTO_AUTH_ZUC_EIA3);
5141 /* alloc mbuf and set payload */
5142 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5145 rte_pktmbuf_tailroom(ut_params->ibuf));
5147 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5148 /* Append data which is padded to a multiple of */
5149 /* the algorithms block size */
5150 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5151 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5153 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5155 /* Create ZUC operation */
5156 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5157 tdata->auth_iv.data, tdata->auth_iv.len,
5158 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5159 tdata->validAuthLenInBits.len,
5164 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5166 ut_params->obuf = ut_params->op->sym->m_src;
5167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5168 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5169 + plaintext_pad_len;
5172 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 "ZUC Generated auth tag not as expected");
5182 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5183 uint8_t op_mode, uint8_t verify)
5185 struct crypto_testsuite_params *ts_params = &testsuite_params;
5186 struct crypto_unittest_params *ut_params = &unittest_params;
5190 uint8_t *plaintext = NULL, *ciphertext = NULL;
5191 unsigned int plaintext_pad_len;
5192 unsigned int plaintext_len;
5193 unsigned int ciphertext_pad_len;
5194 unsigned int ciphertext_len;
5196 struct rte_cryptodev_info dev_info;
5197 struct rte_cryptodev_sym_capability_idx cap_idx;
5199 /* Check if device supports ZUC EIA3 */
5200 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5201 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5203 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5207 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5209 uint64_t feat_flags = dev_info.feature_flags;
5211 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5212 printf("Device doesn't support digest encrypted.\n");
5215 if (op_mode == IN_PLACE) {
5216 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5217 printf("Device doesn't support in-place scatter-gather "
5218 "in both input and output mbufs.\n");
5222 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5223 printf("Device doesn't support out-of-place scatter-gather "
5224 "in both input and output mbufs.\n");
5229 /* Create ZUC session */
5230 retval = create_wireless_algo_auth_cipher_session(
5231 ts_params->valid_devs[0],
5232 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5233 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5234 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5235 : RTE_CRYPTO_AUTH_OP_GENERATE),
5236 RTE_CRYPTO_AUTH_ZUC_EIA3,
5237 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5238 tdata->key.data, tdata->key.len,
5239 tdata->auth_iv.len, tdata->digest.len,
5240 tdata->cipher_iv.len);
5245 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5246 if (op_mode == OUT_OF_PLACE)
5247 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5249 /* clear mbuf payload */
5250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5251 rte_pktmbuf_tailroom(ut_params->ibuf));
5252 if (op_mode == OUT_OF_PLACE)
5253 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5254 rte_pktmbuf_tailroom(ut_params->obuf));
5256 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5257 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5258 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5259 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5262 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5263 ciphertext_pad_len);
5264 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5265 if (op_mode == OUT_OF_PLACE)
5266 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5267 debug_hexdump(stdout, "ciphertext:", ciphertext,
5270 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5272 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5273 if (op_mode == OUT_OF_PLACE)
5274 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5275 debug_hexdump(stdout, "plaintext:", plaintext,
5279 /* Create ZUC operation */
5280 retval = create_wireless_algo_auth_cipher_operation(
5281 tdata->digest.data, tdata->digest.len,
5282 tdata->cipher_iv.data, tdata->cipher_iv.len,
5283 tdata->auth_iv.data, tdata->auth_iv.len,
5284 (tdata->digest.offset_bytes == 0 ?
5285 (verify ? ciphertext_pad_len : plaintext_pad_len)
5286 : tdata->digest.offset_bytes),
5287 tdata->validCipherLenInBits.len,
5288 tdata->validCipherOffsetInBits.len,
5289 tdata->validAuthLenInBits.len,
5291 op_mode, 0, verify);
5296 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5299 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5301 ut_params->obuf = (op_mode == IN_PLACE ?
5302 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5306 if (ut_params->obuf)
5307 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5310 plaintext = ciphertext;
5312 debug_hexdump(stdout, "plaintext:", plaintext,
5313 (tdata->plaintext.len >> 3) - tdata->digest.len);
5314 debug_hexdump(stdout, "plaintext expected:",
5315 tdata->plaintext.data,
5316 (tdata->plaintext.len >> 3) - tdata->digest.len);
5318 if (ut_params->obuf)
5319 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5322 ciphertext = plaintext;
5324 debug_hexdump(stdout, "ciphertext:", ciphertext,
5326 debug_hexdump(stdout, "ciphertext expected:",
5327 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5329 ut_params->digest = rte_pktmbuf_mtod(
5330 ut_params->obuf, uint8_t *) +
5331 (tdata->digest.offset_bytes == 0 ?
5332 plaintext_pad_len : tdata->digest.offset_bytes);
5334 debug_hexdump(stdout, "digest:", ut_params->digest,
5336 debug_hexdump(stdout, "digest expected:",
5337 tdata->digest.data, tdata->digest.len);
5342 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5344 tdata->plaintext.data,
5345 tdata->plaintext.len >> 3,
5346 "ZUC Plaintext data not as expected");
5348 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5350 tdata->ciphertext.data,
5351 tdata->ciphertext.len >> 3,
5352 "ZUC Ciphertext data not as expected");
5354 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5357 DIGEST_BYTE_LENGTH_KASUMI_F9,
5358 "ZUC Generated auth tag not as expected");
5364 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5365 uint8_t op_mode, uint8_t verify)
5367 struct crypto_testsuite_params *ts_params = &testsuite_params;
5368 struct crypto_unittest_params *ut_params = &unittest_params;
5372 const uint8_t *plaintext = NULL;
5373 const uint8_t *ciphertext = NULL;
5374 const uint8_t *digest = NULL;
5375 unsigned int plaintext_pad_len;
5376 unsigned int plaintext_len;
5377 unsigned int ciphertext_pad_len;
5378 unsigned int ciphertext_len;
5379 uint8_t buffer[10000];
5380 uint8_t digest_buffer[10000];
5382 struct rte_cryptodev_info dev_info;
5383 struct rte_cryptodev_sym_capability_idx cap_idx;
5385 /* Check if device supports ZUC EIA3 */
5386 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5387 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5393 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5395 uint64_t feat_flags = dev_info.feature_flags;
5397 if (op_mode == IN_PLACE) {
5398 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5399 printf("Device doesn't support in-place scatter-gather "
5400 "in both input and output mbufs.\n");
5404 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5405 printf("Device doesn't support out-of-place scatter-gather "
5406 "in both input and output mbufs.\n");
5409 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5410 printf("Device doesn't support digest encrypted.\n");
5415 /* Create ZUC session */
5416 retval = create_wireless_algo_auth_cipher_session(
5417 ts_params->valid_devs[0],
5418 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5419 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5420 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5421 : RTE_CRYPTO_AUTH_OP_GENERATE),
5422 RTE_CRYPTO_AUTH_ZUC_EIA3,
5423 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5424 tdata->key.data, tdata->key.len,
5425 tdata->auth_iv.len, tdata->digest.len,
5426 tdata->cipher_iv.len);
5431 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5432 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5433 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5434 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5436 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5437 plaintext_pad_len, 15, 0);
5438 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5439 "Failed to allocate input buffer in mempool");
5441 if (op_mode == OUT_OF_PLACE) {
5442 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5443 plaintext_pad_len, 15, 0);
5444 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5445 "Failed to allocate output buffer in mempool");
5449 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5450 tdata->ciphertext.data);
5451 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5452 ciphertext_len, buffer);
5453 debug_hexdump(stdout, "ciphertext:", ciphertext,
5456 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5457 tdata->plaintext.data);
5458 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5459 plaintext_len, buffer);
5460 debug_hexdump(stdout, "plaintext:", plaintext,
5463 memset(buffer, 0, sizeof(buffer));
5465 /* Create ZUC operation */
5466 retval = create_wireless_algo_auth_cipher_operation(
5467 tdata->digest.data, tdata->digest.len,
5468 tdata->cipher_iv.data, tdata->cipher_iv.len,
5470 (tdata->digest.offset_bytes == 0 ?
5471 (verify ? ciphertext_pad_len : plaintext_pad_len)
5472 : tdata->digest.offset_bytes),
5473 tdata->validCipherLenInBits.len,
5474 tdata->validCipherOffsetInBits.len,
5475 tdata->validAuthLenInBits.len,
5477 op_mode, 1, verify);
5482 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5485 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5487 ut_params->obuf = (op_mode == IN_PLACE ?
5488 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5491 if (ut_params->obuf)
5492 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5493 plaintext_len, buffer);
5495 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5496 plaintext_len, buffer);
5498 debug_hexdump(stdout, "plaintext:", plaintext,
5499 (tdata->plaintext.len >> 3) - tdata->digest.len);
5500 debug_hexdump(stdout, "plaintext expected:",
5501 tdata->plaintext.data,
5502 (tdata->plaintext.len >> 3) - tdata->digest.len);
5504 if (ut_params->obuf)
5505 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5506 ciphertext_len, buffer);
5508 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5509 ciphertext_len, buffer);
5511 debug_hexdump(stdout, "ciphertext:", ciphertext,
5513 debug_hexdump(stdout, "ciphertext expected:",
5514 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5516 if (ut_params->obuf)
5517 digest = rte_pktmbuf_read(ut_params->obuf,
5518 (tdata->digest.offset_bytes == 0 ?
5519 plaintext_pad_len : tdata->digest.offset_bytes),
5520 tdata->digest.len, digest_buffer);
5522 digest = rte_pktmbuf_read(ut_params->ibuf,
5523 (tdata->digest.offset_bytes == 0 ?
5524 plaintext_pad_len : tdata->digest.offset_bytes),
5525 tdata->digest.len, digest_buffer);
5527 debug_hexdump(stdout, "digest:", digest,
5529 debug_hexdump(stdout, "digest expected:",
5530 tdata->digest.data, tdata->digest.len);
5535 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5537 tdata->plaintext.data,
5538 tdata->plaintext.len >> 3,
5539 "ZUC Plaintext data not as expected");
5541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5543 tdata->ciphertext.data,
5544 tdata->validDataLenInBits.len,
5545 "ZUC Ciphertext data not as expected");
5547 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5550 DIGEST_BYTE_LENGTH_KASUMI_F9,
5551 "ZUC Generated auth tag not as expected");
5557 test_kasumi_encryption_test_case_1(void)
5559 return test_kasumi_encryption(&kasumi_test_case_1);
5563 test_kasumi_encryption_test_case_1_sgl(void)
5565 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5569 test_kasumi_encryption_test_case_1_oop(void)
5571 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5575 test_kasumi_encryption_test_case_1_oop_sgl(void)
5577 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5581 test_kasumi_encryption_test_case_2(void)
5583 return test_kasumi_encryption(&kasumi_test_case_2);
5587 test_kasumi_encryption_test_case_3(void)
5589 return test_kasumi_encryption(&kasumi_test_case_3);
5593 test_kasumi_encryption_test_case_4(void)
5595 return test_kasumi_encryption(&kasumi_test_case_4);
5599 test_kasumi_encryption_test_case_5(void)
5601 return test_kasumi_encryption(&kasumi_test_case_5);
5605 test_kasumi_decryption_test_case_1(void)
5607 return test_kasumi_decryption(&kasumi_test_case_1);
5611 test_kasumi_decryption_test_case_1_oop(void)
5613 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5617 test_kasumi_decryption_test_case_2(void)
5619 return test_kasumi_decryption(&kasumi_test_case_2);
5623 test_kasumi_decryption_test_case_3(void)
5625 return test_kasumi_decryption(&kasumi_test_case_3);
5629 test_kasumi_decryption_test_case_4(void)
5631 return test_kasumi_decryption(&kasumi_test_case_4);
5635 test_kasumi_decryption_test_case_5(void)
5637 return test_kasumi_decryption(&kasumi_test_case_5);
5640 test_snow3g_encryption_test_case_1(void)
5642 return test_snow3g_encryption(&snow3g_test_case_1);
5646 test_snow3g_encryption_test_case_1_oop(void)
5648 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5652 test_snow3g_encryption_test_case_1_oop_sgl(void)
5654 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5659 test_snow3g_encryption_test_case_1_offset_oop(void)
5661 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5665 test_snow3g_encryption_test_case_2(void)
5667 return test_snow3g_encryption(&snow3g_test_case_2);
5671 test_snow3g_encryption_test_case_3(void)
5673 return test_snow3g_encryption(&snow3g_test_case_3);
5677 test_snow3g_encryption_test_case_4(void)
5679 return test_snow3g_encryption(&snow3g_test_case_4);
5683 test_snow3g_encryption_test_case_5(void)
5685 return test_snow3g_encryption(&snow3g_test_case_5);
5689 test_snow3g_decryption_test_case_1(void)
5691 return test_snow3g_decryption(&snow3g_test_case_1);
5695 test_snow3g_decryption_test_case_1_oop(void)
5697 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5701 test_snow3g_decryption_test_case_2(void)
5703 return test_snow3g_decryption(&snow3g_test_case_2);
5707 test_snow3g_decryption_test_case_3(void)
5709 return test_snow3g_decryption(&snow3g_test_case_3);
5713 test_snow3g_decryption_test_case_4(void)
5715 return test_snow3g_decryption(&snow3g_test_case_4);
5719 test_snow3g_decryption_test_case_5(void)
5721 return test_snow3g_decryption(&snow3g_test_case_5);
5725 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5726 * Pattern digest from snow3g_test_data must be allocated as
5727 * 4 last bytes in plaintext.
5730 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5731 struct snow3g_hash_test_data *output)
5733 if ((pattern != NULL) && (output != NULL)) {
5734 output->key.len = pattern->key.len;
5736 memcpy(output->key.data,
5737 pattern->key.data, pattern->key.len);
5739 output->auth_iv.len = pattern->auth_iv.len;
5741 memcpy(output->auth_iv.data,
5742 pattern->auth_iv.data, pattern->auth_iv.len);
5744 output->plaintext.len = pattern->plaintext.len;
5746 memcpy(output->plaintext.data,
5747 pattern->plaintext.data, pattern->plaintext.len >> 3);
5749 output->digest.len = pattern->digest.len;
5751 memcpy(output->digest.data,
5752 &pattern->plaintext.data[pattern->digest.offset_bytes],
5753 pattern->digest.len);
5755 output->validAuthLenInBits.len =
5756 pattern->validAuthLenInBits.len;
5761 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5764 test_snow3g_decryption_with_digest_test_case_1(void)
5766 struct snow3g_hash_test_data snow3g_hash_data;
5769 * Function prepare data for hash veryfication test case.
5770 * Digest is allocated in 4 last bytes in plaintext, pattern.
5772 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5774 return test_snow3g_decryption(&snow3g_test_case_7) &
5775 test_snow3g_authentication_verify(&snow3g_hash_data);
5779 test_snow3g_cipher_auth_test_case_1(void)
5781 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5785 test_snow3g_auth_cipher_test_case_1(void)
5787 return test_snow3g_auth_cipher(
5788 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5792 test_snow3g_auth_cipher_test_case_2(void)
5794 return test_snow3g_auth_cipher(
5795 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5799 test_snow3g_auth_cipher_test_case_2_oop(void)
5801 return test_snow3g_auth_cipher(
5802 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5806 test_snow3g_auth_cipher_part_digest_enc(void)
5808 return test_snow3g_auth_cipher(
5809 &snow3g_auth_cipher_partial_digest_encryption,
5814 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5816 return test_snow3g_auth_cipher(
5817 &snow3g_auth_cipher_partial_digest_encryption,
5822 test_snow3g_auth_cipher_test_case_3_sgl(void)
5824 return test_snow3g_auth_cipher_sgl(
5825 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5829 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5831 return test_snow3g_auth_cipher_sgl(
5832 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5836 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5838 return test_snow3g_auth_cipher_sgl(
5839 &snow3g_auth_cipher_partial_digest_encryption,
5844 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5846 return test_snow3g_auth_cipher_sgl(
5847 &snow3g_auth_cipher_partial_digest_encryption,
5852 test_snow3g_auth_cipher_verify_test_case_1(void)
5854 return test_snow3g_auth_cipher(
5855 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5859 test_snow3g_auth_cipher_verify_test_case_2(void)
5861 return test_snow3g_auth_cipher(
5862 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5866 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5868 return test_snow3g_auth_cipher(
5869 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5873 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5875 return test_snow3g_auth_cipher(
5876 &snow3g_auth_cipher_partial_digest_encryption,
5881 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5883 return test_snow3g_auth_cipher(
5884 &snow3g_auth_cipher_partial_digest_encryption,
5889 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5891 return test_snow3g_auth_cipher_sgl(
5892 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5896 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5898 return test_snow3g_auth_cipher_sgl(
5899 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5903 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5905 return test_snow3g_auth_cipher_sgl(
5906 &snow3g_auth_cipher_partial_digest_encryption,
5911 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5913 return test_snow3g_auth_cipher_sgl(
5914 &snow3g_auth_cipher_partial_digest_encryption,
5919 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5921 return test_snow3g_auth_cipher(
5922 &snow3g_test_case_7, IN_PLACE, 0);
5926 test_kasumi_auth_cipher_test_case_1(void)
5928 return test_kasumi_auth_cipher(
5929 &kasumi_test_case_3, IN_PLACE, 0);
5933 test_kasumi_auth_cipher_test_case_2(void)
5935 return test_kasumi_auth_cipher(
5936 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5940 test_kasumi_auth_cipher_test_case_2_oop(void)
5942 return test_kasumi_auth_cipher(
5943 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5947 test_kasumi_auth_cipher_test_case_2_sgl(void)
5949 return test_kasumi_auth_cipher_sgl(
5950 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5954 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5956 return test_kasumi_auth_cipher_sgl(
5957 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5961 test_kasumi_auth_cipher_verify_test_case_1(void)
5963 return test_kasumi_auth_cipher(
5964 &kasumi_test_case_3, IN_PLACE, 1);
5968 test_kasumi_auth_cipher_verify_test_case_2(void)
5970 return test_kasumi_auth_cipher(
5971 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5975 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5977 return test_kasumi_auth_cipher(
5978 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5982 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5984 return test_kasumi_auth_cipher_sgl(
5985 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5989 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5991 return test_kasumi_auth_cipher_sgl(
5992 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5996 test_kasumi_cipher_auth_test_case_1(void)
5998 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6002 test_zuc_encryption_test_case_1(void)
6004 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6008 test_zuc_encryption_test_case_2(void)
6010 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6014 test_zuc_encryption_test_case_3(void)
6016 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6020 test_zuc_encryption_test_case_4(void)
6022 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6026 test_zuc_encryption_test_case_5(void)
6028 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6032 test_zuc_encryption_test_case_6_sgl(void)
6034 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6038 test_zuc_hash_generate_test_case_1(void)
6040 return test_zuc_authentication(&zuc_test_case_auth_1b);
6044 test_zuc_hash_generate_test_case_2(void)
6046 return test_zuc_authentication(&zuc_test_case_auth_90b);
6050 test_zuc_hash_generate_test_case_3(void)
6052 return test_zuc_authentication(&zuc_test_case_auth_577b);
6056 test_zuc_hash_generate_test_case_4(void)
6058 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6062 test_zuc_hash_generate_test_case_5(void)
6064 return test_zuc_authentication(&zuc_test_auth_5670b);
6068 test_zuc_hash_generate_test_case_6(void)
6070 return test_zuc_authentication(&zuc_test_case_auth_128b);
6074 test_zuc_hash_generate_test_case_7(void)
6076 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6080 test_zuc_hash_generate_test_case_8(void)
6082 return test_zuc_authentication(&zuc_test_case_auth_584b);
6086 test_zuc_cipher_auth_test_case_1(void)
6088 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6092 test_zuc_cipher_auth_test_case_2(void)
6094 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6098 test_zuc_auth_cipher_test_case_1(void)
6100 return test_zuc_auth_cipher(
6101 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6105 test_zuc_auth_cipher_test_case_1_oop(void)
6107 return test_zuc_auth_cipher(
6108 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6112 test_zuc_auth_cipher_test_case_1_sgl(void)
6114 return test_zuc_auth_cipher_sgl(
6115 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6119 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6121 return test_zuc_auth_cipher_sgl(
6122 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6126 test_zuc_auth_cipher_verify_test_case_1(void)
6128 return test_zuc_auth_cipher(
6129 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6133 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6135 return test_zuc_auth_cipher(
6136 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6140 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6142 return test_zuc_auth_cipher_sgl(
6143 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6147 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6149 return test_zuc_auth_cipher_sgl(
6150 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6154 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6156 uint8_t dev_id = testsuite_params.valid_devs[0];
6158 struct rte_cryptodev_sym_capability_idx cap_idx;
6160 /* Check if device supports particular cipher algorithm */
6161 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6162 cap_idx.algo.cipher = tdata->cipher_algo;
6163 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6166 /* Check if device supports particular hash algorithm */
6167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6168 cap_idx.algo.auth = tdata->auth_algo;
6169 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6176 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6177 uint8_t op_mode, uint8_t verify)
6179 struct crypto_testsuite_params *ts_params = &testsuite_params;
6180 struct crypto_unittest_params *ut_params = &unittest_params;
6184 uint8_t *plaintext = NULL, *ciphertext = NULL;
6185 unsigned int plaintext_pad_len;
6186 unsigned int plaintext_len;
6187 unsigned int ciphertext_pad_len;
6188 unsigned int ciphertext_len;
6190 struct rte_cryptodev_info dev_info;
6191 struct rte_crypto_op *op;
6193 /* Check if device supports particular algorithms separately */
6194 if (test_mixed_check_if_unsupported(tdata))
6197 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6199 uint64_t feat_flags = dev_info.feature_flags;
6201 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6202 printf("Device doesn't support digest encrypted.\n");
6206 /* Create the session */
6208 retval = create_wireless_algo_cipher_auth_session(
6209 ts_params->valid_devs[0],
6210 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6211 RTE_CRYPTO_AUTH_OP_VERIFY,
6214 tdata->auth_key.data, tdata->auth_key.len,
6215 tdata->auth_iv.len, tdata->digest_enc.len,
6216 tdata->cipher_iv.len);
6218 retval = create_wireless_algo_auth_cipher_session(
6219 ts_params->valid_devs[0],
6220 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6221 RTE_CRYPTO_AUTH_OP_GENERATE,
6224 tdata->auth_key.data, tdata->auth_key.len,
6225 tdata->auth_iv.len, tdata->digest_enc.len,
6226 tdata->cipher_iv.len);
6230 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6231 if (op_mode == OUT_OF_PLACE)
6232 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6234 /* clear mbuf payload */
6235 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6236 rte_pktmbuf_tailroom(ut_params->ibuf));
6237 if (op_mode == OUT_OF_PLACE)
6238 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6239 rte_pktmbuf_tailroom(ut_params->obuf));
6241 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6242 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6243 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6244 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6247 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6248 ciphertext_pad_len);
6249 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6250 if (op_mode == OUT_OF_PLACE)
6251 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6252 debug_hexdump(stdout, "ciphertext:", ciphertext,
6255 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6257 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6258 if (op_mode == OUT_OF_PLACE)
6259 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6260 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6263 /* Create the operation */
6264 retval = create_wireless_algo_auth_cipher_operation(
6265 tdata->digest_enc.data, tdata->digest_enc.len,
6266 tdata->cipher_iv.data, tdata->cipher_iv.len,
6267 tdata->auth_iv.data, tdata->auth_iv.len,
6268 (tdata->digest_enc.offset == 0 ?
6270 : tdata->digest_enc.offset),
6271 tdata->validCipherLen.len_bits,
6272 tdata->cipher.offset_bits,
6273 tdata->validAuthLen.len_bits,
6274 tdata->auth.offset_bits,
6275 op_mode, 0, verify);
6280 op = process_crypto_request(ts_params->valid_devs[0],
6283 /* Check if the op failed because the device doesn't */
6284 /* support this particular combination of algorithms */
6285 if (op == NULL && ut_params->op->status ==
6286 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6287 printf("Device doesn't support this mixed combination. "
6293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6295 ut_params->obuf = (op_mode == IN_PLACE ?
6296 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6299 if (ut_params->obuf)
6300 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6303 plaintext = ciphertext +
6304 (tdata->cipher.offset_bits >> 3);
6306 debug_hexdump(stdout, "plaintext:", plaintext,
6307 tdata->plaintext.len_bits >> 3);
6308 debug_hexdump(stdout, "plaintext expected:",
6309 tdata->plaintext.data,
6310 tdata->plaintext.len_bits >> 3);
6312 if (ut_params->obuf)
6313 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6316 ciphertext = plaintext;
6318 debug_hexdump(stdout, "ciphertext:", ciphertext,
6320 debug_hexdump(stdout, "ciphertext expected:",
6321 tdata->ciphertext.data,
6322 tdata->ciphertext.len_bits >> 3);
6324 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6325 + (tdata->digest_enc.offset == 0 ?
6326 plaintext_pad_len : tdata->digest_enc.offset);
6328 debug_hexdump(stdout, "digest:", ut_params->digest,
6329 tdata->digest_enc.len);
6330 debug_hexdump(stdout, "digest expected:",
6331 tdata->digest_enc.data,
6332 tdata->digest_enc.len);
6337 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6339 tdata->plaintext.data,
6340 tdata->plaintext.len_bits >> 3,
6341 "Plaintext data not as expected");
6343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6345 tdata->ciphertext.data,
6346 tdata->validDataLen.len_bits,
6347 "Ciphertext data not as expected");
6349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6351 tdata->digest_enc.data,
6352 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6353 "Generated auth tag not as expected");
6356 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6357 "crypto op processing failed");
6363 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6364 uint8_t op_mode, uint8_t verify)
6366 struct crypto_testsuite_params *ts_params = &testsuite_params;
6367 struct crypto_unittest_params *ut_params = &unittest_params;
6371 const uint8_t *plaintext = NULL;
6372 const uint8_t *ciphertext = NULL;
6373 const uint8_t *digest = NULL;
6374 unsigned int plaintext_pad_len;
6375 unsigned int plaintext_len;
6376 unsigned int ciphertext_pad_len;
6377 unsigned int ciphertext_len;
6378 uint8_t buffer[10000];
6379 uint8_t digest_buffer[10000];
6381 struct rte_cryptodev_info dev_info;
6382 struct rte_crypto_op *op;
6384 /* Check if device supports particular algorithms */
6385 if (test_mixed_check_if_unsupported(tdata))
6388 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6390 uint64_t feat_flags = dev_info.feature_flags;
6392 if (op_mode == IN_PLACE) {
6393 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6394 printf("Device doesn't support in-place scatter-gather "
6395 "in both input and output mbufs.\n");
6399 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6400 printf("Device doesn't support out-of-place scatter-gather "
6401 "in both input and output mbufs.\n");
6404 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6405 printf("Device doesn't support digest encrypted.\n");
6410 /* Create the session */
6412 retval = create_wireless_algo_cipher_auth_session(
6413 ts_params->valid_devs[0],
6414 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6415 RTE_CRYPTO_AUTH_OP_VERIFY,
6418 tdata->auth_key.data, tdata->auth_key.len,
6419 tdata->auth_iv.len, tdata->digest_enc.len,
6420 tdata->cipher_iv.len);
6422 retval = create_wireless_algo_auth_cipher_session(
6423 ts_params->valid_devs[0],
6424 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6425 RTE_CRYPTO_AUTH_OP_GENERATE,
6428 tdata->auth_key.data, tdata->auth_key.len,
6429 tdata->auth_iv.len, tdata->digest_enc.len,
6430 tdata->cipher_iv.len);
6434 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6435 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6436 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6437 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6439 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6440 ciphertext_pad_len, 15, 0);
6441 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6442 "Failed to allocate input buffer in mempool");
6444 if (op_mode == OUT_OF_PLACE) {
6445 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6446 plaintext_pad_len, 15, 0);
6447 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6448 "Failed to allocate output buffer in mempool");
6452 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6453 tdata->ciphertext.data);
6454 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6455 ciphertext_len, buffer);
6456 debug_hexdump(stdout, "ciphertext:", ciphertext,
6459 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6460 tdata->plaintext.data);
6461 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6462 plaintext_len, buffer);
6463 debug_hexdump(stdout, "plaintext:", plaintext,
6466 memset(buffer, 0, sizeof(buffer));
6468 /* Create the operation */
6469 retval = create_wireless_algo_auth_cipher_operation(
6470 tdata->digest_enc.data, tdata->digest_enc.len,
6471 tdata->cipher_iv.data, tdata->cipher_iv.len,
6472 tdata->auth_iv.data, tdata->auth_iv.len,
6473 (tdata->digest_enc.offset == 0 ?
6475 : tdata->digest_enc.offset),
6476 tdata->validCipherLen.len_bits,
6477 tdata->cipher.offset_bits,
6478 tdata->validAuthLen.len_bits,
6479 tdata->auth.offset_bits,
6480 op_mode, 1, verify);
6485 op = process_crypto_request(ts_params->valid_devs[0],
6488 /* Check if the op failed because the device doesn't */
6489 /* support this particular combination of algorithms */
6490 if (op == NULL && ut_params->op->status ==
6491 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6492 printf("Device doesn't support this mixed combination. "
6499 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6501 ut_params->obuf = (op_mode == IN_PLACE ?
6502 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6505 if (ut_params->obuf)
6506 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6507 plaintext_len, buffer);
6509 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6510 plaintext_len, buffer);
6512 debug_hexdump(stdout, "plaintext:", plaintext,
6513 (tdata->plaintext.len_bits >> 3) -
6514 tdata->digest_enc.len);
6515 debug_hexdump(stdout, "plaintext expected:",
6516 tdata->plaintext.data,
6517 (tdata->plaintext.len_bits >> 3) -
6518 tdata->digest_enc.len);
6520 if (ut_params->obuf)
6521 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6522 ciphertext_len, buffer);
6524 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6525 ciphertext_len, buffer);
6527 debug_hexdump(stdout, "ciphertext:", ciphertext,
6529 debug_hexdump(stdout, "ciphertext expected:",
6530 tdata->ciphertext.data,
6531 tdata->ciphertext.len_bits >> 3);
6533 if (ut_params->obuf)
6534 digest = rte_pktmbuf_read(ut_params->obuf,
6535 (tdata->digest_enc.offset == 0 ?
6537 tdata->digest_enc.offset),
6538 tdata->digest_enc.len, digest_buffer);
6540 digest = rte_pktmbuf_read(ut_params->ibuf,
6541 (tdata->digest_enc.offset == 0 ?
6543 tdata->digest_enc.offset),
6544 tdata->digest_enc.len, digest_buffer);
6546 debug_hexdump(stdout, "digest:", digest,
6547 tdata->digest_enc.len);
6548 debug_hexdump(stdout, "digest expected:",
6549 tdata->digest_enc.data, tdata->digest_enc.len);
6554 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6556 tdata->plaintext.data,
6557 tdata->plaintext.len_bits >> 3,
6558 "Plaintext data not as expected");
6560 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6562 tdata->ciphertext.data,
6563 tdata->validDataLen.len_bits,
6564 "Ciphertext data not as expected");
6565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6567 tdata->digest_enc.data,
6568 tdata->digest_enc.len,
6569 "Generated auth tag not as expected");
6572 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6573 "crypto op processing failed");
6578 /** AUTH AES CMAC + CIPHER AES CTR */
6581 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6583 return test_mixed_auth_cipher(
6584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6588 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6590 return test_mixed_auth_cipher(
6591 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6595 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6597 return test_mixed_auth_cipher_sgl(
6598 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6602 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6604 return test_mixed_auth_cipher_sgl(
6605 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6609 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6611 return test_mixed_auth_cipher(
6612 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6616 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6618 return test_mixed_auth_cipher(
6619 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6623 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6625 return test_mixed_auth_cipher_sgl(
6626 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6630 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6632 return test_mixed_auth_cipher_sgl(
6633 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6636 /** MIXED AUTH + CIPHER */
6639 test_auth_zuc_cipher_snow_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6646 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6653 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6660 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6667 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6669 return test_mixed_auth_cipher(
6670 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6674 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6676 return test_mixed_auth_cipher(
6677 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6681 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6683 return test_mixed_auth_cipher(
6684 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6688 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6690 return test_mixed_auth_cipher(
6691 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6695 test_auth_snow_cipher_zuc_test_case_1(void)
6697 return test_mixed_auth_cipher(
6698 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6702 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6704 return test_mixed_auth_cipher(
6705 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6709 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6711 return test_mixed_auth_cipher(
6712 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6716 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6718 return test_mixed_auth_cipher(
6719 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6723 test_auth_null_cipher_snow_test_case_1(void)
6725 return test_mixed_auth_cipher(
6726 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6730 test_verify_auth_null_cipher_snow_test_case_1(void)
6732 return test_mixed_auth_cipher(
6733 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6737 test_auth_null_cipher_zuc_test_case_1(void)
6739 return test_mixed_auth_cipher(
6740 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6744 test_verify_auth_null_cipher_zuc_test_case_1(void)
6746 return test_mixed_auth_cipher(
6747 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6751 test_auth_snow_cipher_null_test_case_1(void)
6753 return test_mixed_auth_cipher(
6754 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6758 test_verify_auth_snow_cipher_null_test_case_1(void)
6760 return test_mixed_auth_cipher(
6761 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6765 test_auth_zuc_cipher_null_test_case_1(void)
6767 return test_mixed_auth_cipher(
6768 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6772 test_verify_auth_zuc_cipher_null_test_case_1(void)
6774 return test_mixed_auth_cipher(
6775 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6779 test_auth_null_cipher_aes_ctr_test_case_1(void)
6781 return test_mixed_auth_cipher(
6782 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6786 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6788 return test_mixed_auth_cipher(
6789 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6793 test_auth_aes_cmac_cipher_null_test_case_1(void)
6795 return test_mixed_auth_cipher(
6796 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6800 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6802 return test_mixed_auth_cipher(
6803 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6806 /* ***** AEAD algorithm Tests ***** */
6809 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6810 enum rte_crypto_aead_operation op,
6811 const uint8_t *key, const uint8_t key_len,
6812 const uint16_t aad_len, const uint8_t auth_len,
6815 uint8_t aead_key[key_len];
6817 struct crypto_testsuite_params *ts_params = &testsuite_params;
6818 struct crypto_unittest_params *ut_params = &unittest_params;
6820 memcpy(aead_key, key, key_len);
6822 /* Setup AEAD Parameters */
6823 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6824 ut_params->aead_xform.next = NULL;
6825 ut_params->aead_xform.aead.algo = algo;
6826 ut_params->aead_xform.aead.op = op;
6827 ut_params->aead_xform.aead.key.data = aead_key;
6828 ut_params->aead_xform.aead.key.length = key_len;
6829 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6830 ut_params->aead_xform.aead.iv.length = iv_len;
6831 ut_params->aead_xform.aead.digest_length = auth_len;
6832 ut_params->aead_xform.aead.aad_length = aad_len;
6834 debug_hexdump(stdout, "key:", key, key_len);
6836 /* Create Crypto session*/
6837 ut_params->sess = rte_cryptodev_sym_session_create(
6838 ts_params->session_mpool);
6840 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6841 &ut_params->aead_xform,
6842 ts_params->session_priv_mpool);
6844 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6850 create_aead_xform(struct rte_crypto_op *op,
6851 enum rte_crypto_aead_algorithm algo,
6852 enum rte_crypto_aead_operation aead_op,
6853 uint8_t *key, const uint8_t key_len,
6854 const uint8_t aad_len, const uint8_t auth_len,
6857 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6858 "failed to allocate space for crypto transform");
6860 struct rte_crypto_sym_op *sym_op = op->sym;
6862 /* Setup AEAD Parameters */
6863 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6864 sym_op->xform->next = NULL;
6865 sym_op->xform->aead.algo = algo;
6866 sym_op->xform->aead.op = aead_op;
6867 sym_op->xform->aead.key.data = key;
6868 sym_op->xform->aead.key.length = key_len;
6869 sym_op->xform->aead.iv.offset = IV_OFFSET;
6870 sym_op->xform->aead.iv.length = iv_len;
6871 sym_op->xform->aead.digest_length = auth_len;
6872 sym_op->xform->aead.aad_length = aad_len;
6874 debug_hexdump(stdout, "key:", key, key_len);
6880 create_aead_operation(enum rte_crypto_aead_operation op,
6881 const struct aead_test_data *tdata)
6883 struct crypto_testsuite_params *ts_params = &testsuite_params;
6884 struct crypto_unittest_params *ut_params = &unittest_params;
6886 uint8_t *plaintext, *ciphertext;
6887 unsigned int aad_pad_len, plaintext_pad_len;
6889 /* Generate Crypto op data structure */
6890 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6891 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6892 TEST_ASSERT_NOT_NULL(ut_params->op,
6893 "Failed to allocate symmetric crypto operation struct");
6895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6897 /* Append aad data */
6898 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6899 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6900 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6902 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6903 "no room to append aad");
6905 sym_op->aead.aad.phys_addr =
6906 rte_pktmbuf_iova(ut_params->ibuf);
6907 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6908 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6909 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6912 /* Append IV at the end of the crypto operation*/
6913 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6914 uint8_t *, IV_OFFSET);
6916 /* Copy IV 1 byte after the IV pointer, according to the API */
6917 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6918 debug_hexdump(stdout, "iv:", iv_ptr,
6921 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6922 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6924 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6925 "no room to append aad");
6927 sym_op->aead.aad.phys_addr =
6928 rte_pktmbuf_iova(ut_params->ibuf);
6929 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6930 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6933 /* Append IV at the end of the crypto operation*/
6934 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6935 uint8_t *, IV_OFFSET);
6937 if (tdata->iv.len == 0) {
6938 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6939 debug_hexdump(stdout, "iv:", iv_ptr,
6942 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6943 debug_hexdump(stdout, "iv:", iv_ptr,
6948 /* Append plaintext/ciphertext */
6949 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6950 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6953 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6955 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6956 debug_hexdump(stdout, "plaintext:", plaintext,
6957 tdata->plaintext.len);
6959 if (ut_params->obuf) {
6960 ciphertext = (uint8_t *)rte_pktmbuf_append(
6962 plaintext_pad_len + aad_pad_len);
6963 TEST_ASSERT_NOT_NULL(ciphertext,
6964 "no room to append ciphertext");
6966 memset(ciphertext + aad_pad_len, 0,
6967 tdata->ciphertext.len);
6970 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6971 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6973 TEST_ASSERT_NOT_NULL(ciphertext,
6974 "no room to append ciphertext");
6976 memcpy(ciphertext, tdata->ciphertext.data,
6977 tdata->ciphertext.len);
6978 debug_hexdump(stdout, "ciphertext:", ciphertext,
6979 tdata->ciphertext.len);
6981 if (ut_params->obuf) {
6982 plaintext = (uint8_t *)rte_pktmbuf_append(
6984 plaintext_pad_len + aad_pad_len);
6985 TEST_ASSERT_NOT_NULL(plaintext,
6986 "no room to append plaintext");
6988 memset(plaintext + aad_pad_len, 0,
6989 tdata->plaintext.len);
6993 /* Append digest data */
6994 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6995 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6996 ut_params->obuf ? ut_params->obuf :
6998 tdata->auth_tag.len);
6999 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7000 "no room to append digest");
7001 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7002 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7003 ut_params->obuf ? ut_params->obuf :
7008 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7009 ut_params->ibuf, tdata->auth_tag.len);
7010 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7011 "no room to append digest");
7012 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7014 plaintext_pad_len + aad_pad_len);
7016 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7017 tdata->auth_tag.len);
7018 debug_hexdump(stdout, "digest:",
7019 sym_op->aead.digest.data,
7020 tdata->auth_tag.len);
7023 sym_op->aead.data.length = tdata->plaintext.len;
7024 sym_op->aead.data.offset = aad_pad_len;
7030 test_authenticated_encryption(const struct aead_test_data *tdata)
7032 struct crypto_testsuite_params *ts_params = &testsuite_params;
7033 struct crypto_unittest_params *ut_params = &unittest_params;
7036 uint8_t *ciphertext, *auth_tag;
7037 uint16_t plaintext_pad_len;
7040 /* Verify the capabilities */
7041 struct rte_cryptodev_sym_capability_idx cap_idx;
7042 const struct rte_cryptodev_symmetric_capability *capability;
7043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7044 cap_idx.algo.aead = tdata->algo;
7045 capability = rte_cryptodev_sym_capability_get(
7046 ts_params->valid_devs[0], &cap_idx);
7047 if (capability == NULL)
7049 if (rte_cryptodev_sym_capability_check_aead(
7050 capability, tdata->key.len, tdata->auth_tag.len,
7051 tdata->aad.len, tdata->iv.len))
7054 /* Create AEAD session */
7055 retval = create_aead_session(ts_params->valid_devs[0],
7057 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7058 tdata->key.data, tdata->key.len,
7059 tdata->aad.len, tdata->auth_tag.len,
7064 if (tdata->aad.len > MBUF_SIZE) {
7065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7066 /* Populate full size of add data */
7067 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7068 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7070 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7072 /* clear mbuf payload */
7073 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7074 rte_pktmbuf_tailroom(ut_params->ibuf));
7076 /* Create AEAD operation */
7077 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7081 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7083 ut_params->op->sym->m_src = ut_params->ibuf;
7085 /* Process crypto operation */
7086 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7087 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7089 TEST_ASSERT_NOT_NULL(
7090 process_crypto_request(ts_params->valid_devs[0],
7091 ut_params->op), "failed to process sym crypto op");
7093 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7094 "crypto op processing failed");
7096 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7098 if (ut_params->op->sym->m_dst) {
7099 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7101 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7102 uint8_t *, plaintext_pad_len);
7104 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7106 ut_params->op->sym->cipher.data.offset);
7107 auth_tag = ciphertext + plaintext_pad_len;
7110 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7111 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7114 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7116 tdata->ciphertext.data,
7117 tdata->ciphertext.len,
7118 "Ciphertext data not as expected");
7120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7122 tdata->auth_tag.data,
7123 tdata->auth_tag.len,
7124 "Generated auth tag not as expected");
7130 #ifdef RTE_LIBRTE_SECURITY
7131 /* Basic algorithm run function for async inplace mode.
7132 * Creates a session from input parameters and runs one operation
7133 * on input_vec. Checks the output of the crypto operation against
7137 test_pdcp_proto(int i, int oop,
7138 enum rte_crypto_cipher_operation opc,
7139 enum rte_crypto_auth_operation opa,
7141 unsigned int input_vec_len,
7142 uint8_t *output_vec,
7143 unsigned int output_vec_len)
7145 struct crypto_testsuite_params *ts_params = &testsuite_params;
7146 struct crypto_unittest_params *ut_params = &unittest_params;
7148 int ret = TEST_SUCCESS;
7149 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7150 rte_cryptodev_get_sec_ctx(
7151 ts_params->valid_devs[0]);
7153 /* Verify the capabilities */
7154 struct rte_security_capability_idx sec_cap_idx;
7156 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7157 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7158 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7159 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7162 /* Generate test mbuf data */
7163 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7165 /* clear mbuf payload */
7166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7167 rte_pktmbuf_tailroom(ut_params->ibuf));
7169 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7171 memcpy(plaintext, input_vec, input_vec_len);
7173 /* Out of place support */
7176 * For out-op-place we need to alloc another mbuf
7178 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7179 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7182 /* Set crypto type as IPSEC */
7183 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7185 /* Setup Cipher Parameters */
7186 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7187 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7188 ut_params->cipher_xform.cipher.op = opc;
7189 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7190 ut_params->cipher_xform.cipher.key.length =
7191 pdcp_test_params[i].cipher_key_len;
7192 ut_params->cipher_xform.cipher.iv.length = 0;
7194 /* Setup HMAC Parameters if ICV header is required */
7195 if (pdcp_test_params[i].auth_alg != 0) {
7196 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7197 ut_params->auth_xform.next = NULL;
7198 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7199 ut_params->auth_xform.auth.op = opa;
7200 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7201 ut_params->auth_xform.auth.key.length =
7202 pdcp_test_params[i].auth_key_len;
7204 ut_params->cipher_xform.next = &ut_params->auth_xform;
7206 ut_params->cipher_xform.next = NULL;
7209 struct rte_security_session_conf sess_conf = {
7210 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7211 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7213 .bearer = pdcp_test_bearer[i],
7214 .domain = pdcp_test_params[i].domain,
7215 .pkt_dir = pdcp_test_packet_direction[i],
7216 .sn_size = pdcp_test_data_sn_size[i],
7217 .hfn = pdcp_test_hfn[i],
7218 .hfn_threshold = pdcp_test_hfn_threshold[i],
7220 .crypto_xform = &ut_params->cipher_xform
7223 /* Create security session */
7224 ut_params->sec_session = rte_security_session_create(ctx,
7225 &sess_conf, ts_params->session_priv_mpool);
7227 if (!ut_params->sec_session) {
7228 printf("TestCase %s()-%d line %d failed %s: ",
7229 __func__, i, __LINE__, "Failed to allocate session");
7234 /* Generate crypto op data structure */
7235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7237 if (!ut_params->op) {
7238 printf("TestCase %s()-%d line %d failed %s: ",
7239 __func__, i, __LINE__,
7240 "Failed to allocate symmetric crypto operation struct");
7245 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7247 /* set crypto operation source mbuf */
7248 ut_params->op->sym->m_src = ut_params->ibuf;
7250 ut_params->op->sym->m_dst = ut_params->obuf;
7252 /* Process crypto operation */
7253 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7255 printf("TestCase %s()-%d line %d failed %s: ",
7256 __func__, i, __LINE__,
7257 "failed to process sym crypto op");
7262 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7263 printf("TestCase %s()-%d line %d failed %s: ",
7264 __func__, i, __LINE__, "crypto op processing failed");
7270 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7273 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7277 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7278 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7279 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7280 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7286 rte_crypto_op_free(ut_params->op);
7287 ut_params->op = NULL;
7289 if (ut_params->sec_session)
7290 rte_security_session_destroy(ctx, ut_params->sec_session);
7291 ut_params->sec_session = NULL;
7293 rte_pktmbuf_free(ut_params->ibuf);
7294 ut_params->ibuf = NULL;
7296 rte_pktmbuf_free(ut_params->obuf);
7297 ut_params->obuf = NULL;
7304 test_pdcp_proto_SGL(int i, int oop,
7305 enum rte_crypto_cipher_operation opc,
7306 enum rte_crypto_auth_operation opa,
7308 unsigned int input_vec_len,
7309 uint8_t *output_vec,
7310 unsigned int output_vec_len,
7312 uint32_t fragsz_oop)
7314 struct crypto_testsuite_params *ts_params = &testsuite_params;
7315 struct crypto_unittest_params *ut_params = &unittest_params;
7317 struct rte_mbuf *buf, *buf_oop = NULL;
7318 int ret = TEST_SUCCESS;
7322 unsigned int trn_data = 0;
7323 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7324 rte_cryptodev_get_sec_ctx(
7325 ts_params->valid_devs[0]);
7327 /* Verify the capabilities */
7328 struct rte_security_capability_idx sec_cap_idx;
7330 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7331 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7332 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7333 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7336 if (fragsz > input_vec_len)
7337 fragsz = input_vec_len;
7339 uint16_t plaintext_len = fragsz;
7340 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7342 if (fragsz_oop > output_vec_len)
7343 frag_size_oop = output_vec_len;
7346 if (input_vec_len % fragsz != 0) {
7347 if (input_vec_len / fragsz + 1 > 16)
7349 } else if (input_vec_len / fragsz > 16)
7352 /* Out of place support */
7355 * For out-op-place we need to alloc another mbuf
7357 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7358 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7359 buf_oop = ut_params->obuf;
7362 /* Generate test mbuf data */
7363 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7365 /* clear mbuf payload */
7366 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7367 rte_pktmbuf_tailroom(ut_params->ibuf));
7369 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7371 memcpy(plaintext, input_vec, plaintext_len);
7372 trn_data += plaintext_len;
7374 buf = ut_params->ibuf;
7377 * Loop until no more fragments
7380 while (trn_data < input_vec_len) {
7382 to_trn = (input_vec_len - trn_data < fragsz) ?
7383 (input_vec_len - trn_data) : fragsz;
7385 to_trn_tbl[ecx++] = to_trn;
7387 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7390 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7391 rte_pktmbuf_tailroom(buf));
7394 if (oop && !fragsz_oop) {
7396 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7397 buf_oop = buf_oop->next;
7398 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7399 0, rte_pktmbuf_tailroom(buf_oop));
7400 rte_pktmbuf_append(buf_oop, to_trn);
7403 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7406 memcpy(plaintext, input_vec + trn_data, to_trn);
7410 ut_params->ibuf->nb_segs = segs;
7413 if (fragsz_oop && oop) {
7417 trn_data = frag_size_oop;
7418 while (trn_data < output_vec_len) {
7421 (output_vec_len - trn_data <
7423 (output_vec_len - trn_data) :
7426 to_trn_tbl[ecx++] = to_trn;
7429 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7430 buf_oop = buf_oop->next;
7431 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7432 0, rte_pktmbuf_tailroom(buf_oop));
7433 rte_pktmbuf_append(buf_oop, to_trn);
7437 ut_params->obuf->nb_segs = segs;
7440 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7442 /* Setup Cipher Parameters */
7443 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7444 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7445 ut_params->cipher_xform.cipher.op = opc;
7446 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7447 ut_params->cipher_xform.cipher.key.length =
7448 pdcp_test_params[i].cipher_key_len;
7449 ut_params->cipher_xform.cipher.iv.length = 0;
7451 /* Setup HMAC Parameters if ICV header is required */
7452 if (pdcp_test_params[i].auth_alg != 0) {
7453 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7454 ut_params->auth_xform.next = NULL;
7455 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7456 ut_params->auth_xform.auth.op = opa;
7457 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7458 ut_params->auth_xform.auth.key.length =
7459 pdcp_test_params[i].auth_key_len;
7461 ut_params->cipher_xform.next = &ut_params->auth_xform;
7463 ut_params->cipher_xform.next = NULL;
7466 struct rte_security_session_conf sess_conf = {
7467 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7468 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7470 .bearer = pdcp_test_bearer[i],
7471 .domain = pdcp_test_params[i].domain,
7472 .pkt_dir = pdcp_test_packet_direction[i],
7473 .sn_size = pdcp_test_data_sn_size[i],
7474 .hfn = pdcp_test_hfn[i],
7475 .hfn_threshold = pdcp_test_hfn_threshold[i],
7477 .crypto_xform = &ut_params->cipher_xform
7480 /* Create security session */
7481 ut_params->sec_session = rte_security_session_create(ctx,
7482 &sess_conf, ts_params->session_priv_mpool);
7484 if (!ut_params->sec_session) {
7485 printf("TestCase %s()-%d line %d failed %s: ",
7486 __func__, i, __LINE__, "Failed to allocate session");
7491 /* Generate crypto op data structure */
7492 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7493 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7494 if (!ut_params->op) {
7495 printf("TestCase %s()-%d line %d failed %s: ",
7496 __func__, i, __LINE__,
7497 "Failed to allocate symmetric crypto operation struct");
7502 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7504 /* set crypto operation source mbuf */
7505 ut_params->op->sym->m_src = ut_params->ibuf;
7507 ut_params->op->sym->m_dst = ut_params->obuf;
7509 /* Process crypto operation */
7510 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7512 printf("TestCase %s()-%d line %d failed %s: ",
7513 __func__, i, __LINE__,
7514 "failed to process sym crypto op");
7519 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7520 printf("TestCase %s()-%d line %d failed %s: ",
7521 __func__, i, __LINE__, "crypto op processing failed");
7527 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7530 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7534 fragsz = frag_size_oop;
7535 if (memcmp(ciphertext, output_vec, fragsz)) {
7536 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7537 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7538 rte_hexdump(stdout, "reference", output_vec, fragsz);
7543 buf = ut_params->op->sym->m_src->next;
7545 buf = ut_params->op->sym->m_dst->next;
7547 unsigned int off = fragsz;
7551 ciphertext = rte_pktmbuf_mtod(buf,
7553 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7554 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7555 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7556 rte_hexdump(stdout, "reference", output_vec + off,
7561 off += to_trn_tbl[ecx++];
7565 rte_crypto_op_free(ut_params->op);
7566 ut_params->op = NULL;
7568 if (ut_params->sec_session)
7569 rte_security_session_destroy(ctx, ut_params->sec_session);
7570 ut_params->sec_session = NULL;
7572 rte_pktmbuf_free(ut_params->ibuf);
7573 ut_params->ibuf = NULL;
7575 rte_pktmbuf_free(ut_params->obuf);
7576 ut_params->obuf = NULL;
7583 test_pdcp_proto_cplane_encap(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7587 RTE_CRYPTO_AUTH_OP_GENERATE,
7588 pdcp_test_data_in[i],
7589 pdcp_test_data_in_len[i],
7590 pdcp_test_data_out[i],
7591 pdcp_test_data_in_len[i]+4);
7595 test_pdcp_proto_uplane_encap(int i)
7597 return test_pdcp_proto(i, 0,
7598 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7599 RTE_CRYPTO_AUTH_OP_GENERATE,
7600 pdcp_test_data_in[i],
7601 pdcp_test_data_in_len[i],
7602 pdcp_test_data_out[i],
7603 pdcp_test_data_in_len[i]);
7608 test_pdcp_proto_uplane_encap_with_int(int i)
7610 return test_pdcp_proto(i, 0,
7611 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7612 RTE_CRYPTO_AUTH_OP_GENERATE,
7613 pdcp_test_data_in[i],
7614 pdcp_test_data_in_len[i],
7615 pdcp_test_data_out[i],
7616 pdcp_test_data_in_len[i] + 4);
7620 test_pdcp_proto_cplane_decap(int i)
7622 return test_pdcp_proto(i, 0,
7623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7624 RTE_CRYPTO_AUTH_OP_VERIFY,
7625 pdcp_test_data_out[i],
7626 pdcp_test_data_in_len[i] + 4,
7627 pdcp_test_data_in[i],
7628 pdcp_test_data_in_len[i]);
7632 test_pdcp_proto_uplane_decap(int i)
7634 return test_pdcp_proto(i, 0,
7635 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7636 RTE_CRYPTO_AUTH_OP_VERIFY,
7637 pdcp_test_data_out[i],
7638 pdcp_test_data_in_len[i],
7639 pdcp_test_data_in[i],
7640 pdcp_test_data_in_len[i]);
7644 test_pdcp_proto_uplane_decap_with_int(int i)
7646 return test_pdcp_proto(i, 0,
7647 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7648 RTE_CRYPTO_AUTH_OP_VERIFY,
7649 pdcp_test_data_out[i],
7650 pdcp_test_data_in_len[i] + 4,
7651 pdcp_test_data_in[i],
7652 pdcp_test_data_in_len[i]);
7656 test_PDCP_PROTO_SGL_in_place_32B(void)
7658 /* i can be used for running any PDCP case
7659 * In this case it is uplane 12-bit AES-SNOW DL encap
7661 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7662 return test_pdcp_proto_SGL(i, IN_PLACE,
7663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 RTE_CRYPTO_AUTH_OP_GENERATE,
7665 pdcp_test_data_in[i],
7666 pdcp_test_data_in_len[i],
7667 pdcp_test_data_out[i],
7668 pdcp_test_data_in_len[i]+4,
7672 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7674 /* i can be used for running any PDCP case
7675 * In this case it is uplane 18-bit NULL-NULL DL encap
7677 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7678 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7679 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7680 RTE_CRYPTO_AUTH_OP_GENERATE,
7681 pdcp_test_data_in[i],
7682 pdcp_test_data_in_len[i],
7683 pdcp_test_data_out[i],
7684 pdcp_test_data_in_len[i]+4,
7688 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7690 /* i can be used for running any PDCP case
7691 * In this case it is uplane 18-bit AES DL encap
7693 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7695 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7697 RTE_CRYPTO_AUTH_OP_GENERATE,
7698 pdcp_test_data_in[i],
7699 pdcp_test_data_in_len[i],
7700 pdcp_test_data_out[i],
7701 pdcp_test_data_in_len[i],
7705 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7707 /* i can be used for running any PDCP case
7708 * In this case it is cplane 12-bit AES-ZUC DL encap
7710 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7711 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7712 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7713 RTE_CRYPTO_AUTH_OP_GENERATE,
7714 pdcp_test_data_in[i],
7715 pdcp_test_data_in_len[i],
7716 pdcp_test_data_out[i],
7717 pdcp_test_data_in_len[i]+4,
7723 test_AES_GCM_authenticated_encryption_test_case_1(void)
7725 return test_authenticated_encryption(&gcm_test_case_1);
7729 test_AES_GCM_authenticated_encryption_test_case_2(void)
7731 return test_authenticated_encryption(&gcm_test_case_2);
7735 test_AES_GCM_authenticated_encryption_test_case_3(void)
7737 return test_authenticated_encryption(&gcm_test_case_3);
7741 test_AES_GCM_authenticated_encryption_test_case_4(void)
7743 return test_authenticated_encryption(&gcm_test_case_4);
7747 test_AES_GCM_authenticated_encryption_test_case_5(void)
7749 return test_authenticated_encryption(&gcm_test_case_5);
7753 test_AES_GCM_authenticated_encryption_test_case_6(void)
7755 return test_authenticated_encryption(&gcm_test_case_6);
7759 test_AES_GCM_authenticated_encryption_test_case_7(void)
7761 return test_authenticated_encryption(&gcm_test_case_7);
7765 test_AES_GCM_authenticated_encryption_test_case_8(void)
7767 return test_authenticated_encryption(&gcm_test_case_8);
7771 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7773 return test_authenticated_encryption(&gcm_J0_test_case_1);
7777 test_AES_GCM_auth_encryption_test_case_192_1(void)
7779 return test_authenticated_encryption(&gcm_test_case_192_1);
7783 test_AES_GCM_auth_encryption_test_case_192_2(void)
7785 return test_authenticated_encryption(&gcm_test_case_192_2);
7789 test_AES_GCM_auth_encryption_test_case_192_3(void)
7791 return test_authenticated_encryption(&gcm_test_case_192_3);
7795 test_AES_GCM_auth_encryption_test_case_192_4(void)
7797 return test_authenticated_encryption(&gcm_test_case_192_4);
7801 test_AES_GCM_auth_encryption_test_case_192_5(void)
7803 return test_authenticated_encryption(&gcm_test_case_192_5);
7807 test_AES_GCM_auth_encryption_test_case_192_6(void)
7809 return test_authenticated_encryption(&gcm_test_case_192_6);
7813 test_AES_GCM_auth_encryption_test_case_192_7(void)
7815 return test_authenticated_encryption(&gcm_test_case_192_7);
7819 test_AES_GCM_auth_encryption_test_case_256_1(void)
7821 return test_authenticated_encryption(&gcm_test_case_256_1);
7825 test_AES_GCM_auth_encryption_test_case_256_2(void)
7827 return test_authenticated_encryption(&gcm_test_case_256_2);
7831 test_AES_GCM_auth_encryption_test_case_256_3(void)
7833 return test_authenticated_encryption(&gcm_test_case_256_3);
7837 test_AES_GCM_auth_encryption_test_case_256_4(void)
7839 return test_authenticated_encryption(&gcm_test_case_256_4);
7843 test_AES_GCM_auth_encryption_test_case_256_5(void)
7845 return test_authenticated_encryption(&gcm_test_case_256_5);
7849 test_AES_GCM_auth_encryption_test_case_256_6(void)
7851 return test_authenticated_encryption(&gcm_test_case_256_6);
7855 test_AES_GCM_auth_encryption_test_case_256_7(void)
7857 return test_authenticated_encryption(&gcm_test_case_256_7);
7861 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7863 return test_authenticated_encryption(&gcm_test_case_aad_1);
7867 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7869 return test_authenticated_encryption(&gcm_test_case_aad_2);
7873 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7875 struct aead_test_data tdata;
7878 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7879 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7880 tdata.iv.data[0] += 1;
7881 res = test_authenticated_encryption(&tdata);
7882 if (res == -ENOTSUP)
7884 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7885 return TEST_SUCCESS;
7889 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7891 struct aead_test_data tdata;
7894 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7895 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7896 tdata.plaintext.data[0] += 1;
7897 res = test_authenticated_encryption(&tdata);
7898 if (res == -ENOTSUP)
7900 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7901 return TEST_SUCCESS;
7905 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7907 struct aead_test_data tdata;
7910 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7911 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7912 tdata.ciphertext.data[0] += 1;
7913 res = test_authenticated_encryption(&tdata);
7914 if (res == -ENOTSUP)
7916 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7917 return TEST_SUCCESS;
7921 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7923 struct aead_test_data tdata;
7926 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7927 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7929 res = test_authenticated_encryption(&tdata);
7930 if (res == -ENOTSUP)
7932 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7933 return TEST_SUCCESS;
7937 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7939 struct aead_test_data tdata;
7940 uint8_t aad[gcm_test_case_7.aad.len];
7943 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7944 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7945 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7947 tdata.aad.data = aad;
7948 res = test_authenticated_encryption(&tdata);
7949 if (res == -ENOTSUP)
7951 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7952 return TEST_SUCCESS;
7956 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7958 struct aead_test_data tdata;
7961 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7962 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7963 tdata.auth_tag.data[0] += 1;
7964 res = test_authenticated_encryption(&tdata);
7965 if (res == -ENOTSUP)
7967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7968 return TEST_SUCCESS;
7972 test_authenticated_decryption(const struct aead_test_data *tdata)
7974 struct crypto_testsuite_params *ts_params = &testsuite_params;
7975 struct crypto_unittest_params *ut_params = &unittest_params;
7981 /* Verify the capabilities */
7982 struct rte_cryptodev_sym_capability_idx cap_idx;
7983 const struct rte_cryptodev_symmetric_capability *capability;
7984 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7985 cap_idx.algo.aead = tdata->algo;
7986 capability = rte_cryptodev_sym_capability_get(
7987 ts_params->valid_devs[0], &cap_idx);
7988 if (capability == NULL)
7990 if (rte_cryptodev_sym_capability_check_aead(
7991 capability, tdata->key.len, tdata->auth_tag.len,
7992 tdata->aad.len, tdata->iv.len))
7995 /* Create AEAD session */
7996 retval = create_aead_session(ts_params->valid_devs[0],
7998 RTE_CRYPTO_AEAD_OP_DECRYPT,
7999 tdata->key.data, tdata->key.len,
8000 tdata->aad.len, tdata->auth_tag.len,
8005 /* alloc mbuf and set payload */
8006 if (tdata->aad.len > MBUF_SIZE) {
8007 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8008 /* Populate full size of add data */
8009 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8010 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8012 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8014 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8015 rte_pktmbuf_tailroom(ut_params->ibuf));
8017 /* Create AEAD operation */
8018 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8022 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8024 ut_params->op->sym->m_src = ut_params->ibuf;
8026 /* Process crypto operation */
8027 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8028 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8030 TEST_ASSERT_NOT_NULL(
8031 process_crypto_request(ts_params->valid_devs[0],
8032 ut_params->op), "failed to process sym crypto op");
8034 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8035 "crypto op processing failed");
8037 if (ut_params->op->sym->m_dst)
8038 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8041 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8043 ut_params->op->sym->cipher.data.offset);
8045 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8050 tdata->plaintext.data,
8051 tdata->plaintext.len,
8052 "Plaintext data not as expected");
8054 TEST_ASSERT_EQUAL(ut_params->op->status,
8055 RTE_CRYPTO_OP_STATUS_SUCCESS,
8056 "Authentication failed");
8062 test_AES_GCM_authenticated_decryption_test_case_1(void)
8064 return test_authenticated_decryption(&gcm_test_case_1);
8068 test_AES_GCM_authenticated_decryption_test_case_2(void)
8070 return test_authenticated_decryption(&gcm_test_case_2);
8074 test_AES_GCM_authenticated_decryption_test_case_3(void)
8076 return test_authenticated_decryption(&gcm_test_case_3);
8080 test_AES_GCM_authenticated_decryption_test_case_4(void)
8082 return test_authenticated_decryption(&gcm_test_case_4);
8086 test_AES_GCM_authenticated_decryption_test_case_5(void)
8088 return test_authenticated_decryption(&gcm_test_case_5);
8092 test_AES_GCM_authenticated_decryption_test_case_6(void)
8094 return test_authenticated_decryption(&gcm_test_case_6);
8098 test_AES_GCM_authenticated_decryption_test_case_7(void)
8100 return test_authenticated_decryption(&gcm_test_case_7);
8104 test_AES_GCM_authenticated_decryption_test_case_8(void)
8106 return test_authenticated_decryption(&gcm_test_case_8);
8110 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8112 return test_authenticated_decryption(&gcm_J0_test_case_1);
8116 test_AES_GCM_auth_decryption_test_case_192_1(void)
8118 return test_authenticated_decryption(&gcm_test_case_192_1);
8122 test_AES_GCM_auth_decryption_test_case_192_2(void)
8124 return test_authenticated_decryption(&gcm_test_case_192_2);
8128 test_AES_GCM_auth_decryption_test_case_192_3(void)
8130 return test_authenticated_decryption(&gcm_test_case_192_3);
8134 test_AES_GCM_auth_decryption_test_case_192_4(void)
8136 return test_authenticated_decryption(&gcm_test_case_192_4);
8140 test_AES_GCM_auth_decryption_test_case_192_5(void)
8142 return test_authenticated_decryption(&gcm_test_case_192_5);
8146 test_AES_GCM_auth_decryption_test_case_192_6(void)
8148 return test_authenticated_decryption(&gcm_test_case_192_6);
8152 test_AES_GCM_auth_decryption_test_case_192_7(void)
8154 return test_authenticated_decryption(&gcm_test_case_192_7);
8158 test_AES_GCM_auth_decryption_test_case_256_1(void)
8160 return test_authenticated_decryption(&gcm_test_case_256_1);
8164 test_AES_GCM_auth_decryption_test_case_256_2(void)
8166 return test_authenticated_decryption(&gcm_test_case_256_2);
8170 test_AES_GCM_auth_decryption_test_case_256_3(void)
8172 return test_authenticated_decryption(&gcm_test_case_256_3);
8176 test_AES_GCM_auth_decryption_test_case_256_4(void)
8178 return test_authenticated_decryption(&gcm_test_case_256_4);
8182 test_AES_GCM_auth_decryption_test_case_256_5(void)
8184 return test_authenticated_decryption(&gcm_test_case_256_5);
8188 test_AES_GCM_auth_decryption_test_case_256_6(void)
8190 return test_authenticated_decryption(&gcm_test_case_256_6);
8194 test_AES_GCM_auth_decryption_test_case_256_7(void)
8196 return test_authenticated_decryption(&gcm_test_case_256_7);
8200 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8202 return test_authenticated_decryption(&gcm_test_case_aad_1);
8206 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8208 return test_authenticated_decryption(&gcm_test_case_aad_2);
8212 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8214 struct aead_test_data tdata;
8217 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8218 tdata.iv.data[0] += 1;
8219 res = test_authenticated_decryption(&tdata);
8220 if (res == -ENOTSUP)
8222 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8223 return TEST_SUCCESS;
8227 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8229 struct aead_test_data tdata;
8232 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8233 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8234 tdata.plaintext.data[0] += 1;
8235 res = test_authenticated_decryption(&tdata);
8236 if (res == -ENOTSUP)
8238 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8239 return TEST_SUCCESS;
8243 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8245 struct aead_test_data tdata;
8248 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8249 tdata.ciphertext.data[0] += 1;
8250 res = test_authenticated_decryption(&tdata);
8251 if (res == -ENOTSUP)
8253 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8254 return TEST_SUCCESS;
8258 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8260 struct aead_test_data tdata;
8263 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8265 res = test_authenticated_decryption(&tdata);
8266 if (res == -ENOTSUP)
8268 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8269 return TEST_SUCCESS;
8273 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8275 struct aead_test_data tdata;
8276 uint8_t aad[gcm_test_case_7.aad.len];
8279 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8280 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8282 tdata.aad.data = aad;
8283 res = test_authenticated_decryption(&tdata);
8284 if (res == -ENOTSUP)
8286 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8287 return TEST_SUCCESS;
8291 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8293 struct aead_test_data tdata;
8296 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8297 tdata.auth_tag.data[0] += 1;
8298 res = test_authenticated_decryption(&tdata);
8299 if (res == -ENOTSUP)
8301 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8302 return TEST_SUCCESS;
8306 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8308 struct crypto_testsuite_params *ts_params = &testsuite_params;
8309 struct crypto_unittest_params *ut_params = &unittest_params;
8312 uint8_t *ciphertext, *auth_tag;
8313 uint16_t plaintext_pad_len;
8315 /* Verify the capabilities */
8316 struct rte_cryptodev_sym_capability_idx cap_idx;
8317 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8318 cap_idx.algo.aead = tdata->algo;
8319 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8323 /* not supported with CPU crypto */
8324 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8327 /* Create AEAD session */
8328 retval = create_aead_session(ts_params->valid_devs[0],
8330 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8331 tdata->key.data, tdata->key.len,
8332 tdata->aad.len, tdata->auth_tag.len,
8337 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8338 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8340 /* clear mbuf payload */
8341 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8342 rte_pktmbuf_tailroom(ut_params->ibuf));
8343 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8344 rte_pktmbuf_tailroom(ut_params->obuf));
8346 /* Create AEAD operation */
8347 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8351 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8353 ut_params->op->sym->m_src = ut_params->ibuf;
8354 ut_params->op->sym->m_dst = ut_params->obuf;
8356 /* Process crypto operation */
8357 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8358 ut_params->op), "failed to process sym crypto op");
8360 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8361 "crypto op processing failed");
8363 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8365 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8366 ut_params->op->sym->cipher.data.offset);
8367 auth_tag = ciphertext + plaintext_pad_len;
8369 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8370 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8373 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8375 tdata->ciphertext.data,
8376 tdata->ciphertext.len,
8377 "Ciphertext data not as expected");
8379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8381 tdata->auth_tag.data,
8382 tdata->auth_tag.len,
8383 "Generated auth tag not as expected");
8390 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8392 return test_authenticated_encryption_oop(&gcm_test_case_5);
8396 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8398 struct crypto_testsuite_params *ts_params = &testsuite_params;
8399 struct crypto_unittest_params *ut_params = &unittest_params;
8404 /* Verify the capabilities */
8405 struct rte_cryptodev_sym_capability_idx cap_idx;
8406 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8407 cap_idx.algo.aead = tdata->algo;
8408 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8412 /* not supported with CPU crypto */
8413 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8416 /* Create AEAD session */
8417 retval = create_aead_session(ts_params->valid_devs[0],
8419 RTE_CRYPTO_AEAD_OP_DECRYPT,
8420 tdata->key.data, tdata->key.len,
8421 tdata->aad.len, tdata->auth_tag.len,
8426 /* alloc mbuf and set payload */
8427 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8428 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8430 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8431 rte_pktmbuf_tailroom(ut_params->ibuf));
8432 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8433 rte_pktmbuf_tailroom(ut_params->obuf));
8435 /* Create AEAD operation */
8436 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8440 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8442 ut_params->op->sym->m_src = ut_params->ibuf;
8443 ut_params->op->sym->m_dst = ut_params->obuf;
8445 /* Process crypto operation */
8446 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8447 ut_params->op), "failed to process sym crypto op");
8449 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8450 "crypto op processing failed");
8452 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8453 ut_params->op->sym->cipher.data.offset);
8455 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8458 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8460 tdata->plaintext.data,
8461 tdata->plaintext.len,
8462 "Plaintext data not as expected");
8464 TEST_ASSERT_EQUAL(ut_params->op->status,
8465 RTE_CRYPTO_OP_STATUS_SUCCESS,
8466 "Authentication failed");
8471 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8473 return test_authenticated_decryption_oop(&gcm_test_case_5);
8477 test_authenticated_encryption_sessionless(
8478 const struct aead_test_data *tdata)
8480 struct crypto_testsuite_params *ts_params = &testsuite_params;
8481 struct crypto_unittest_params *ut_params = &unittest_params;
8484 uint8_t *ciphertext, *auth_tag;
8485 uint16_t plaintext_pad_len;
8486 uint8_t key[tdata->key.len + 1];
8488 /* This test is for AESNI MB and AESNI GCM PMDs only */
8489 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8490 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8491 (gbl_driver_id != rte_cryptodev_driver_id_get(
8492 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8495 /* not supported with CPU crypto */
8496 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8499 /* Verify the capabilities */
8500 struct rte_cryptodev_sym_capability_idx cap_idx;
8501 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8502 cap_idx.algo.aead = tdata->algo;
8503 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8507 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8509 /* clear mbuf payload */
8510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8511 rte_pktmbuf_tailroom(ut_params->ibuf));
8513 /* Create AEAD operation */
8514 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8518 /* Create GCM xform */
8519 memcpy(key, tdata->key.data, tdata->key.len);
8520 retval = create_aead_xform(ut_params->op,
8522 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8523 key, tdata->key.len,
8524 tdata->aad.len, tdata->auth_tag.len,
8529 ut_params->op->sym->m_src = ut_params->ibuf;
8531 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8532 RTE_CRYPTO_OP_SESSIONLESS,
8533 "crypto op session type not sessionless");
8535 /* Process crypto operation */
8536 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8537 ut_params->op), "failed to process sym crypto op");
8539 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8541 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8542 "crypto op status not success");
8544 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8546 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8547 ut_params->op->sym->cipher.data.offset);
8548 auth_tag = ciphertext + plaintext_pad_len;
8550 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8551 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8554 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8556 tdata->ciphertext.data,
8557 tdata->ciphertext.len,
8558 "Ciphertext data not as expected");
8560 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8562 tdata->auth_tag.data,
8563 tdata->auth_tag.len,
8564 "Generated auth tag not as expected");
8571 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8573 return test_authenticated_encryption_sessionless(
8578 test_authenticated_decryption_sessionless(
8579 const struct aead_test_data *tdata)
8581 struct crypto_testsuite_params *ts_params = &testsuite_params;
8582 struct crypto_unittest_params *ut_params = &unittest_params;
8586 uint8_t key[tdata->key.len + 1];
8588 /* This test is for AESNI MB and AESNI GCM PMDs only */
8589 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8590 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8591 (gbl_driver_id != rte_cryptodev_driver_id_get(
8592 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8595 /* not supported with CPU crypto */
8596 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8599 /* Verify the capabilities */
8600 struct rte_cryptodev_sym_capability_idx cap_idx;
8601 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8602 cap_idx.algo.aead = tdata->algo;
8603 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8607 /* alloc mbuf and set payload */
8608 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8611 rte_pktmbuf_tailroom(ut_params->ibuf));
8613 /* Create AEAD operation */
8614 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8618 /* Create AEAD xform */
8619 memcpy(key, tdata->key.data, tdata->key.len);
8620 retval = create_aead_xform(ut_params->op,
8622 RTE_CRYPTO_AEAD_OP_DECRYPT,
8623 key, tdata->key.len,
8624 tdata->aad.len, tdata->auth_tag.len,
8629 ut_params->op->sym->m_src = ut_params->ibuf;
8631 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8632 RTE_CRYPTO_OP_SESSIONLESS,
8633 "crypto op session type not sessionless");
8635 /* Process crypto operation */
8636 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8637 ut_params->op), "failed to process sym crypto op");
8639 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8641 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8642 "crypto op status not success");
8644 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8645 ut_params->op->sym->cipher.data.offset);
8647 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8652 tdata->plaintext.data,
8653 tdata->plaintext.len,
8654 "Plaintext data not as expected");
8656 TEST_ASSERT_EQUAL(ut_params->op->status,
8657 RTE_CRYPTO_OP_STATUS_SUCCESS,
8658 "Authentication failed");
8663 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8665 return test_authenticated_decryption_sessionless(
8670 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8672 return test_authenticated_encryption(&ccm_test_case_128_1);
8676 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8678 return test_authenticated_encryption(&ccm_test_case_128_2);
8682 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8684 return test_authenticated_encryption(&ccm_test_case_128_3);
8688 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8690 return test_authenticated_decryption(&ccm_test_case_128_1);
8694 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8696 return test_authenticated_decryption(&ccm_test_case_128_2);
8700 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8702 return test_authenticated_decryption(&ccm_test_case_128_3);
8706 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8708 return test_authenticated_encryption(&ccm_test_case_192_1);
8712 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8714 return test_authenticated_encryption(&ccm_test_case_192_2);
8718 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8720 return test_authenticated_encryption(&ccm_test_case_192_3);
8724 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8726 return test_authenticated_decryption(&ccm_test_case_192_1);
8730 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8732 return test_authenticated_decryption(&ccm_test_case_192_2);
8736 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8738 return test_authenticated_decryption(&ccm_test_case_192_3);
8742 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8744 return test_authenticated_encryption(&ccm_test_case_256_1);
8748 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8750 return test_authenticated_encryption(&ccm_test_case_256_2);
8754 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8756 return test_authenticated_encryption(&ccm_test_case_256_3);
8760 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8762 return test_authenticated_decryption(&ccm_test_case_256_1);
8766 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8768 return test_authenticated_decryption(&ccm_test_case_256_2);
8772 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8774 return test_authenticated_decryption(&ccm_test_case_256_3);
8780 struct crypto_testsuite_params *ts_params = &testsuite_params;
8781 struct rte_cryptodev_stats stats;
8782 struct rte_cryptodev *dev;
8783 cryptodev_stats_get_t temp_pfn;
8785 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8788 /* Verify the capabilities */
8789 struct rte_cryptodev_sym_capability_idx cap_idx;
8790 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8791 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8792 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8795 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8796 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8797 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8801 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8802 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8803 &stats) == -ENODEV),
8804 "rte_cryptodev_stats_get invalid dev failed");
8805 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8806 "rte_cryptodev_stats_get invalid Param failed");
8807 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8808 temp_pfn = dev->dev_ops->stats_get;
8809 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8810 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8812 "rte_cryptodev_stats_get invalid Param failed");
8813 dev->dev_ops->stats_get = temp_pfn;
8815 /* Test expected values */
8817 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8819 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8821 "rte_cryptodev_stats_get failed");
8822 TEST_ASSERT((stats.enqueued_count == 1),
8823 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8824 TEST_ASSERT((stats.dequeued_count == 1),
8825 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8826 TEST_ASSERT((stats.enqueue_err_count == 0),
8827 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8828 TEST_ASSERT((stats.dequeue_err_count == 0),
8829 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8831 /* invalid device but should ignore and not reset device stats*/
8832 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8833 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8835 "rte_cryptodev_stats_get failed");
8836 TEST_ASSERT((stats.enqueued_count == 1),
8837 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8839 /* check that a valid reset clears stats */
8840 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8841 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8843 "rte_cryptodev_stats_get failed");
8844 TEST_ASSERT((stats.enqueued_count == 0),
8845 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8846 TEST_ASSERT((stats.dequeued_count == 0),
8847 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8849 return TEST_SUCCESS;
8852 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8853 struct crypto_unittest_params *ut_params,
8854 enum rte_crypto_auth_operation op,
8855 const struct HMAC_MD5_vector *test_case)
8859 memcpy(key, test_case->key.data, test_case->key.len);
8861 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8862 ut_params->auth_xform.next = NULL;
8863 ut_params->auth_xform.auth.op = op;
8865 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8867 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8868 ut_params->auth_xform.auth.key.length = test_case->key.len;
8869 ut_params->auth_xform.auth.key.data = key;
8871 ut_params->sess = rte_cryptodev_sym_session_create(
8872 ts_params->session_mpool);
8874 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8875 ut_params->sess, &ut_params->auth_xform,
8876 ts_params->session_priv_mpool);
8878 if (ut_params->sess == NULL)
8881 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8883 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8884 rte_pktmbuf_tailroom(ut_params->ibuf));
8889 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8890 const struct HMAC_MD5_vector *test_case,
8891 uint8_t **plaintext)
8893 uint16_t plaintext_pad_len;
8895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8897 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8900 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8902 memcpy(*plaintext, test_case->plaintext.data,
8903 test_case->plaintext.len);
8905 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8906 ut_params->ibuf, MD5_DIGEST_LEN);
8907 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8908 "no room to append digest");
8909 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8910 ut_params->ibuf, plaintext_pad_len);
8912 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8913 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8914 test_case->auth_tag.len);
8917 sym_op->auth.data.offset = 0;
8918 sym_op->auth.data.length = test_case->plaintext.len;
8920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8921 ut_params->op->sym->m_src = ut_params->ibuf;
8927 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8929 uint16_t plaintext_pad_len;
8930 uint8_t *plaintext, *auth_tag;
8932 struct crypto_testsuite_params *ts_params = &testsuite_params;
8933 struct crypto_unittest_params *ut_params = &unittest_params;
8935 /* Verify the capabilities */
8936 struct rte_cryptodev_sym_capability_idx cap_idx;
8937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8938 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8939 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8943 if (MD5_HMAC_create_session(ts_params, ut_params,
8944 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8947 /* Generate Crypto op data structure */
8948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8950 TEST_ASSERT_NOT_NULL(ut_params->op,
8951 "Failed to allocate symmetric crypto operation struct");
8953 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8956 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8959 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8960 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8963 TEST_ASSERT_NOT_NULL(
8964 process_crypto_request(ts_params->valid_devs[0],
8966 "failed to process sym crypto op");
8968 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8969 "crypto op processing failed");
8971 if (ut_params->op->sym->m_dst) {
8972 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8973 uint8_t *, plaintext_pad_len);
8975 auth_tag = plaintext + plaintext_pad_len;
8978 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8980 test_case->auth_tag.data,
8981 test_case->auth_tag.len,
8982 "HMAC_MD5 generated tag not as expected");
8984 return TEST_SUCCESS;
8988 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8992 struct crypto_testsuite_params *ts_params = &testsuite_params;
8993 struct crypto_unittest_params *ut_params = &unittest_params;
8995 /* Verify the capabilities */
8996 struct rte_cryptodev_sym_capability_idx cap_idx;
8997 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8998 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8999 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9003 if (MD5_HMAC_create_session(ts_params, ut_params,
9004 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9008 /* Generate Crypto op data structure */
9009 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9010 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9011 TEST_ASSERT_NOT_NULL(ut_params->op,
9012 "Failed to allocate symmetric crypto operation struct");
9014 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9017 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9018 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9021 TEST_ASSERT_NOT_NULL(
9022 process_crypto_request(ts_params->valid_devs[0],
9024 "failed to process sym crypto op");
9026 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9027 "HMAC_MD5 crypto op processing failed");
9029 return TEST_SUCCESS;
9033 test_MD5_HMAC_generate_case_1(void)
9035 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9039 test_MD5_HMAC_verify_case_1(void)
9041 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9045 test_MD5_HMAC_generate_case_2(void)
9047 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9051 test_MD5_HMAC_verify_case_2(void)
9053 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9057 test_multi_session(void)
9059 struct crypto_testsuite_params *ts_params = &testsuite_params;
9060 struct crypto_unittest_params *ut_params = &unittest_params;
9062 struct rte_cryptodev_info dev_info;
9063 struct rte_cryptodev_sym_session **sessions;
9067 /* Verify the capabilities */
9068 struct rte_cryptodev_sym_capability_idx cap_idx;
9069 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9070 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9071 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9074 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9075 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9076 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9080 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9081 aes_cbc_key, hmac_sha512_key);
9084 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9086 sessions = rte_malloc(NULL,
9087 (sizeof(struct rte_cryptodev_sym_session *) *
9088 MAX_NB_SESSIONS) + 1, 0);
9090 /* Create multiple crypto sessions*/
9091 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9093 sessions[i] = rte_cryptodev_sym_session_create(
9094 ts_params->session_mpool);
9096 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9097 sessions[i], &ut_params->auth_xform,
9098 ts_params->session_priv_mpool);
9099 TEST_ASSERT_NOT_NULL(sessions[i],
9100 "Session creation failed at session number %u",
9103 /* Attempt to send a request on each session */
9104 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9108 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9109 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9111 "Failed to perform decrypt on request number %u.", i);
9112 /* free crypto operation structure */
9114 rte_crypto_op_free(ut_params->op);
9117 * free mbuf - both obuf and ibuf are usually the same,
9118 * so check if they point at the same address is necessary,
9119 * to avoid freeing the mbuf twice.
9121 if (ut_params->obuf) {
9122 rte_pktmbuf_free(ut_params->obuf);
9123 if (ut_params->ibuf == ut_params->obuf)
9124 ut_params->ibuf = 0;
9125 ut_params->obuf = 0;
9127 if (ut_params->ibuf) {
9128 rte_pktmbuf_free(ut_params->ibuf);
9129 ut_params->ibuf = 0;
9133 /* Next session create should fail */
9134 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9135 sessions[i], &ut_params->auth_xform,
9136 ts_params->session_priv_mpool);
9137 TEST_ASSERT_NULL(sessions[i],
9138 "Session creation succeeded unexpectedly!");
9140 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9141 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9143 rte_cryptodev_sym_session_free(sessions[i]);
9148 return TEST_SUCCESS;
9151 struct multi_session_params {
9152 struct crypto_unittest_params ut_params;
9153 uint8_t *cipher_key;
9155 const uint8_t *cipher;
9156 const uint8_t *digest;
9160 #define MB_SESSION_NUMBER 3
9163 test_multi_session_random_usage(void)
9165 struct crypto_testsuite_params *ts_params = &testsuite_params;
9166 struct rte_cryptodev_info dev_info;
9167 struct rte_cryptodev_sym_session **sessions;
9169 struct multi_session_params ut_paramz[] = {
9172 .cipher_key = ms_aes_cbc_key0,
9173 .hmac_key = ms_hmac_key0,
9174 .cipher = ms_aes_cbc_cipher0,
9175 .digest = ms_hmac_digest0,
9176 .iv = ms_aes_cbc_iv0
9179 .cipher_key = ms_aes_cbc_key1,
9180 .hmac_key = ms_hmac_key1,
9181 .cipher = ms_aes_cbc_cipher1,
9182 .digest = ms_hmac_digest1,
9183 .iv = ms_aes_cbc_iv1
9186 .cipher_key = ms_aes_cbc_key2,
9187 .hmac_key = ms_hmac_key2,
9188 .cipher = ms_aes_cbc_cipher2,
9189 .digest = ms_hmac_digest2,
9190 .iv = ms_aes_cbc_iv2
9195 /* Verify the capabilities */
9196 struct rte_cryptodev_sym_capability_idx cap_idx;
9197 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9198 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9199 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9202 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9203 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9204 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9208 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9210 sessions = rte_malloc(NULL,
9211 (sizeof(struct rte_cryptodev_sym_session *)
9212 * MAX_NB_SESSIONS) + 1, 0);
9214 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9215 sessions[i] = rte_cryptodev_sym_session_create(
9216 ts_params->session_mpool);
9218 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9219 sizeof(struct crypto_unittest_params));
9221 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9222 &ut_paramz[i].ut_params,
9223 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9225 /* Create multiple crypto sessions*/
9226 rte_cryptodev_sym_session_init(
9227 ts_params->valid_devs[0],
9229 &ut_paramz[i].ut_params.auth_xform,
9230 ts_params->session_priv_mpool);
9232 TEST_ASSERT_NOT_NULL(sessions[i],
9233 "Session creation failed at session number %u",
9239 for (i = 0; i < 40000; i++) {
9241 j = rand() % MB_SESSION_NUMBER;
9243 TEST_ASSERT_SUCCESS(
9244 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9246 &ut_paramz[j].ut_params,
9247 ts_params, ut_paramz[j].cipher,
9248 ut_paramz[j].digest,
9250 "Failed to perform decrypt on request number %u.", i);
9252 if (ut_paramz[j].ut_params.op)
9253 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9256 * free mbuf - both obuf and ibuf are usually the same,
9257 * so check if they point at the same address is necessary,
9258 * to avoid freeing the mbuf twice.
9260 if (ut_paramz[j].ut_params.obuf) {
9261 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9262 if (ut_paramz[j].ut_params.ibuf
9263 == ut_paramz[j].ut_params.obuf)
9264 ut_paramz[j].ut_params.ibuf = 0;
9265 ut_paramz[j].ut_params.obuf = 0;
9267 if (ut_paramz[j].ut_params.ibuf) {
9268 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9269 ut_paramz[j].ut_params.ibuf = 0;
9273 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9274 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9276 rte_cryptodev_sym_session_free(sessions[i]);
9281 return TEST_SUCCESS;
9285 test_null_cipher_only_operation(void)
9287 struct crypto_testsuite_params *ts_params = &testsuite_params;
9288 struct crypto_unittest_params *ut_params = &unittest_params;
9290 /* Verify the capabilities */
9291 struct rte_cryptodev_sym_capability_idx cap_idx;
9292 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9293 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9294 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9298 /* Generate test mbuf data and space for digest */
9299 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9300 catch_22_quote, QUOTE_512_BYTES, 0);
9302 /* Setup Cipher Parameters */
9303 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9304 ut_params->cipher_xform.next = NULL;
9306 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9307 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9309 ut_params->sess = rte_cryptodev_sym_session_create(
9310 ts_params->session_mpool);
9312 /* Create Crypto session*/
9313 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9315 &ut_params->cipher_xform,
9316 ts_params->session_priv_mpool);
9317 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9319 /* Generate Crypto op data structure */
9320 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9321 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9322 TEST_ASSERT_NOT_NULL(ut_params->op,
9323 "Failed to allocate symmetric crypto operation struct");
9325 /* Set crypto operation data parameters */
9326 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9328 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9330 /* set crypto operation source mbuf */
9331 sym_op->m_src = ut_params->ibuf;
9333 sym_op->cipher.data.offset = 0;
9334 sym_op->cipher.data.length = QUOTE_512_BYTES;
9336 /* Process crypto operation */
9337 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9339 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9341 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9342 "crypto operation processing failed");
9345 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9346 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9349 "Ciphertext data not as expected");
9351 return TEST_SUCCESS;
9353 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9354 0xab, 0xab, 0xab, 0xab,
9355 0xab, 0xab, 0xab, 0xab,
9356 0xab, 0xab, 0xab, 0xab};
9358 test_null_auth_only_operation(void)
9360 struct crypto_testsuite_params *ts_params = &testsuite_params;
9361 struct crypto_unittest_params *ut_params = &unittest_params;
9364 /* Verify the capabilities */
9365 struct rte_cryptodev_sym_capability_idx cap_idx;
9366 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9367 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9368 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9372 /* Generate test mbuf data and space for digest */
9373 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9374 catch_22_quote, QUOTE_512_BYTES, 0);
9376 /* create a pointer for digest, but don't expect anything to be written
9377 * here in a NULL auth algo so no mbuf append done.
9379 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9381 /* prefill the memory pointed to by digest */
9382 memcpy(digest, orig_data, sizeof(orig_data));
9384 /* Setup HMAC Parameters */
9385 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9386 ut_params->auth_xform.next = NULL;
9388 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9389 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9391 ut_params->sess = rte_cryptodev_sym_session_create(
9392 ts_params->session_mpool);
9394 /* Create Crypto session*/
9395 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9396 ut_params->sess, &ut_params->auth_xform,
9397 ts_params->session_priv_mpool);
9398 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9400 /* Generate Crypto op data structure */
9401 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9402 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9403 TEST_ASSERT_NOT_NULL(ut_params->op,
9404 "Failed to allocate symmetric crypto operation struct");
9406 /* Set crypto operation data parameters */
9407 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9409 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9411 sym_op->m_src = ut_params->ibuf;
9413 sym_op->auth.data.offset = 0;
9414 sym_op->auth.data.length = QUOTE_512_BYTES;
9415 sym_op->auth.digest.data = digest;
9416 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9419 /* Process crypto operation */
9420 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9422 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9425 "crypto operation processing failed");
9426 /* Make sure memory pointed to by digest hasn't been overwritten */
9427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9431 "Memory at digest ptr overwritten unexpectedly");
9433 return TEST_SUCCESS;
9438 test_null_cipher_auth_operation(void)
9440 struct crypto_testsuite_params *ts_params = &testsuite_params;
9441 struct crypto_unittest_params *ut_params = &unittest_params;
9444 /* Verify the capabilities */
9445 struct rte_cryptodev_sym_capability_idx cap_idx;
9446 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9447 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9448 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9451 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9452 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9453 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9457 /* Generate test mbuf data and space for digest */
9458 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9459 catch_22_quote, QUOTE_512_BYTES, 0);
9461 /* create a pointer for digest, but don't expect anything to be written
9462 * here in a NULL auth algo so no mbuf append done.
9464 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9466 /* prefill the memory pointed to by digest */
9467 memcpy(digest, orig_data, sizeof(orig_data));
9469 /* Setup Cipher Parameters */
9470 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9471 ut_params->cipher_xform.next = &ut_params->auth_xform;
9473 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9474 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9476 /* Setup HMAC Parameters */
9477 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9478 ut_params->auth_xform.next = NULL;
9480 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9481 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9483 ut_params->sess = rte_cryptodev_sym_session_create(
9484 ts_params->session_mpool);
9486 /* Create Crypto session*/
9487 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9488 ut_params->sess, &ut_params->cipher_xform,
9489 ts_params->session_priv_mpool);
9490 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9492 /* Generate Crypto op data structure */
9493 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9494 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9495 TEST_ASSERT_NOT_NULL(ut_params->op,
9496 "Failed to allocate symmetric crypto operation struct");
9498 /* Set crypto operation data parameters */
9499 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9501 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9503 sym_op->m_src = ut_params->ibuf;
9505 sym_op->cipher.data.offset = 0;
9506 sym_op->cipher.data.length = QUOTE_512_BYTES;
9508 sym_op->auth.data.offset = 0;
9509 sym_op->auth.data.length = QUOTE_512_BYTES;
9510 sym_op->auth.digest.data = digest;
9511 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9514 /* Process crypto operation */
9515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9517 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9519 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9520 "crypto operation processing failed");
9523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9524 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9527 "Ciphertext data not as expected");
9528 /* Make sure memory pointed to by digest hasn't been overwritten */
9529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9533 "Memory at digest ptr overwritten unexpectedly");
9535 return TEST_SUCCESS;
9539 test_null_auth_cipher_operation(void)
9541 struct crypto_testsuite_params *ts_params = &testsuite_params;
9542 struct crypto_unittest_params *ut_params = &unittest_params;
9545 /* Verify the capabilities */
9546 struct rte_cryptodev_sym_capability_idx cap_idx;
9547 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9548 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9549 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9552 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9553 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9554 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9558 /* Generate test mbuf data */
9559 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9560 catch_22_quote, QUOTE_512_BYTES, 0);
9562 /* create a pointer for digest, but don't expect anything to be written
9563 * here in a NULL auth algo so no mbuf append done.
9565 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9567 /* prefill the memory pointed to by digest */
9568 memcpy(digest, orig_data, sizeof(orig_data));
9570 /* Setup Cipher Parameters */
9571 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9572 ut_params->cipher_xform.next = NULL;
9574 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9575 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9577 /* Setup HMAC Parameters */
9578 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9579 ut_params->auth_xform.next = &ut_params->cipher_xform;
9581 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9582 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9584 ut_params->sess = rte_cryptodev_sym_session_create(
9585 ts_params->session_mpool);
9587 /* Create Crypto session*/
9588 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9589 ut_params->sess, &ut_params->cipher_xform,
9590 ts_params->session_priv_mpool);
9591 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9593 /* Generate Crypto op data structure */
9594 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9595 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9596 TEST_ASSERT_NOT_NULL(ut_params->op,
9597 "Failed to allocate symmetric crypto operation struct");
9599 /* Set crypto operation data parameters */
9600 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9602 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9604 sym_op->m_src = ut_params->ibuf;
9606 sym_op->cipher.data.offset = 0;
9607 sym_op->cipher.data.length = QUOTE_512_BYTES;
9609 sym_op->auth.data.offset = 0;
9610 sym_op->auth.data.length = QUOTE_512_BYTES;
9611 sym_op->auth.digest.data = digest;
9612 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9615 /* Process crypto operation */
9616 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9618 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9620 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9621 "crypto operation processing failed");
9624 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9625 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9628 "Ciphertext data not as expected");
9629 /* Make sure memory pointed to by digest hasn't been overwritten */
9630 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9634 "Memory at digest ptr overwritten unexpectedly");
9636 return TEST_SUCCESS;
9641 test_null_invalid_operation(void)
9643 struct crypto_testsuite_params *ts_params = &testsuite_params;
9644 struct crypto_unittest_params *ut_params = &unittest_params;
9647 /* This test is for NULL PMD only */
9648 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9649 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9652 /* Setup Cipher Parameters */
9653 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9654 ut_params->cipher_xform.next = NULL;
9656 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9657 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9659 ut_params->sess = rte_cryptodev_sym_session_create(
9660 ts_params->session_mpool);
9662 /* Create Crypto session*/
9663 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9664 ut_params->sess, &ut_params->cipher_xform,
9665 ts_params->session_priv_mpool);
9666 TEST_ASSERT(ret < 0,
9667 "Session creation succeeded unexpectedly");
9670 /* Setup HMAC Parameters */
9671 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9672 ut_params->auth_xform.next = NULL;
9674 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9675 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9677 ut_params->sess = rte_cryptodev_sym_session_create(
9678 ts_params->session_mpool);
9680 /* Create Crypto session*/
9681 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9682 ut_params->sess, &ut_params->auth_xform,
9683 ts_params->session_priv_mpool);
9684 TEST_ASSERT(ret < 0,
9685 "Session creation succeeded unexpectedly");
9687 return TEST_SUCCESS;
9691 #define NULL_BURST_LENGTH (32)
9694 test_null_burst_operation(void)
9696 struct crypto_testsuite_params *ts_params = &testsuite_params;
9697 struct crypto_unittest_params *ut_params = &unittest_params;
9699 unsigned i, burst_len = NULL_BURST_LENGTH;
9701 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9702 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9704 /* This test is for NULL PMD only */
9705 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9706 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9709 /* Setup Cipher Parameters */
9710 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9711 ut_params->cipher_xform.next = &ut_params->auth_xform;
9713 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9714 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9716 /* Setup HMAC Parameters */
9717 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9718 ut_params->auth_xform.next = NULL;
9720 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9721 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9723 ut_params->sess = rte_cryptodev_sym_session_create(
9724 ts_params->session_mpool);
9726 /* Create Crypto session*/
9727 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9728 ut_params->sess, &ut_params->cipher_xform,
9729 ts_params->session_priv_mpool);
9730 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9732 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9733 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9734 burst_len, "failed to generate burst of crypto ops");
9736 /* Generate an operation for each mbuf in burst */
9737 for (i = 0; i < burst_len; i++) {
9738 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9740 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9742 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9746 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9748 burst[i]->sym->m_src = m;
9751 /* Process crypto operation */
9752 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9753 0, burst, burst_len),
9755 "Error enqueuing burst");
9757 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9758 0, burst_dequeued, burst_len),
9760 "Error dequeuing burst");
9763 for (i = 0; i < burst_len; i++) {
9765 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9766 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9768 "data not as expected");
9770 rte_pktmbuf_free(burst[i]->sym->m_src);
9771 rte_crypto_op_free(burst[i]);
9774 return TEST_SUCCESS;
9778 generate_gmac_large_plaintext(uint8_t *data)
9782 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9783 memcpy(&data[i], &data[0], 32);
9787 create_gmac_operation(enum rte_crypto_auth_operation op,
9788 const struct gmac_test_data *tdata)
9790 struct crypto_testsuite_params *ts_params = &testsuite_params;
9791 struct crypto_unittest_params *ut_params = &unittest_params;
9792 struct rte_crypto_sym_op *sym_op;
9794 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9796 /* Generate Crypto op data structure */
9797 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9798 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9799 TEST_ASSERT_NOT_NULL(ut_params->op,
9800 "Failed to allocate symmetric crypto operation struct");
9802 sym_op = ut_params->op->sym;
9804 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9805 ut_params->ibuf, tdata->gmac_tag.len);
9806 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9807 "no room to append digest");
9809 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9810 ut_params->ibuf, plaintext_pad_len);
9812 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9813 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9814 tdata->gmac_tag.len);
9815 debug_hexdump(stdout, "digest:",
9816 sym_op->auth.digest.data,
9817 tdata->gmac_tag.len);
9820 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9821 uint8_t *, IV_OFFSET);
9823 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9825 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9827 sym_op->cipher.data.length = 0;
9828 sym_op->cipher.data.offset = 0;
9830 sym_op->auth.data.offset = 0;
9831 sym_op->auth.data.length = tdata->plaintext.len;
9836 static int create_gmac_session(uint8_t dev_id,
9837 const struct gmac_test_data *tdata,
9838 enum rte_crypto_auth_operation auth_op)
9840 uint8_t auth_key[tdata->key.len];
9842 struct crypto_testsuite_params *ts_params = &testsuite_params;
9843 struct crypto_unittest_params *ut_params = &unittest_params;
9845 memcpy(auth_key, tdata->key.data, tdata->key.len);
9847 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9848 ut_params->auth_xform.next = NULL;
9850 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9851 ut_params->auth_xform.auth.op = auth_op;
9852 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9853 ut_params->auth_xform.auth.key.length = tdata->key.len;
9854 ut_params->auth_xform.auth.key.data = auth_key;
9855 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9856 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9859 ut_params->sess = rte_cryptodev_sym_session_create(
9860 ts_params->session_mpool);
9862 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9863 &ut_params->auth_xform,
9864 ts_params->session_priv_mpool);
9866 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9872 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9874 struct crypto_testsuite_params *ts_params = &testsuite_params;
9875 struct crypto_unittest_params *ut_params = &unittest_params;
9879 uint8_t *auth_tag, *plaintext;
9880 uint16_t plaintext_pad_len;
9882 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9883 "No GMAC length in the source data");
9885 /* Verify the capabilities */
9886 struct rte_cryptodev_sym_capability_idx cap_idx;
9887 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9888 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9889 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9893 retval = create_gmac_session(ts_params->valid_devs[0],
9894 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9899 if (tdata->plaintext.len > MBUF_SIZE)
9900 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9903 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9904 "Failed to allocate input buffer in mempool");
9906 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9907 rte_pktmbuf_tailroom(ut_params->ibuf));
9909 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9911 * Runtime generate the large plain text instead of use hard code
9912 * plain text vector. It is done to avoid create huge source file
9913 * with the test vector.
9915 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9916 generate_gmac_large_plaintext(tdata->plaintext.data);
9918 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9920 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9922 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9923 debug_hexdump(stdout, "plaintext:", plaintext,
9924 tdata->plaintext.len);
9926 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9934 ut_params->op->sym->m_src = ut_params->ibuf;
9936 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9937 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9940 TEST_ASSERT_NOT_NULL(
9941 process_crypto_request(ts_params->valid_devs[0],
9942 ut_params->op), "failed to process sym crypto op");
9944 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9945 "crypto op processing failed");
9947 if (ut_params->op->sym->m_dst) {
9948 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9949 uint8_t *, plaintext_pad_len);
9951 auth_tag = plaintext + plaintext_pad_len;
9954 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9956 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9958 tdata->gmac_tag.data,
9959 tdata->gmac_tag.len,
9960 "GMAC Generated auth tag not as expected");
9966 test_AES_GMAC_authentication_test_case_1(void)
9968 return test_AES_GMAC_authentication(&gmac_test_case_1);
9972 test_AES_GMAC_authentication_test_case_2(void)
9974 return test_AES_GMAC_authentication(&gmac_test_case_2);
9978 test_AES_GMAC_authentication_test_case_3(void)
9980 return test_AES_GMAC_authentication(&gmac_test_case_3);
9984 test_AES_GMAC_authentication_test_case_4(void)
9986 return test_AES_GMAC_authentication(&gmac_test_case_4);
9990 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9992 struct crypto_testsuite_params *ts_params = &testsuite_params;
9993 struct crypto_unittest_params *ut_params = &unittest_params;
9995 uint32_t plaintext_pad_len;
9998 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9999 "No GMAC length in the source data");
10001 /* Verify the capabilities */
10002 struct rte_cryptodev_sym_capability_idx cap_idx;
10003 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10004 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10005 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10009 retval = create_gmac_session(ts_params->valid_devs[0],
10010 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10015 if (tdata->plaintext.len > MBUF_SIZE)
10016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10019 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10020 "Failed to allocate input buffer in mempool");
10022 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10023 rte_pktmbuf_tailroom(ut_params->ibuf));
10025 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10028 * Runtime generate the large plain text instead of use hard code
10029 * plain text vector. It is done to avoid create huge source file
10030 * with the test vector.
10032 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10033 generate_gmac_large_plaintext(tdata->plaintext.data);
10035 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10036 plaintext_pad_len);
10037 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10039 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10040 debug_hexdump(stdout, "plaintext:", plaintext,
10041 tdata->plaintext.len);
10043 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10049 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10051 ut_params->op->sym->m_src = ut_params->ibuf;
10053 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10054 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10057 TEST_ASSERT_NOT_NULL(
10058 process_crypto_request(ts_params->valid_devs[0],
10059 ut_params->op), "failed to process sym crypto op");
10061 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10062 "crypto op processing failed");
10069 test_AES_GMAC_authentication_verify_test_case_1(void)
10071 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10075 test_AES_GMAC_authentication_verify_test_case_2(void)
10077 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10081 test_AES_GMAC_authentication_verify_test_case_3(void)
10083 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10087 test_AES_GMAC_authentication_verify_test_case_4(void)
10089 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10092 struct test_crypto_vector {
10093 enum rte_crypto_cipher_algorithm crypto_algo;
10094 unsigned int cipher_offset;
10095 unsigned int cipher_len;
10108 const uint8_t *data;
10113 const uint8_t *data;
10117 enum rte_crypto_auth_algorithm auth_algo;
10118 unsigned int auth_offset;
10126 const uint8_t *data;
10136 static const struct test_crypto_vector
10137 hmac_sha1_test_crypto_vector = {
10138 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10140 .data = plaintext_hash,
10145 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10146 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10147 0xDE, 0xF4, 0xDE, 0xAD
10153 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10154 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10155 0x3F, 0x91, 0x64, 0x59
10161 static const struct test_crypto_vector
10162 aes128_gmac_test_vector = {
10163 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10165 .data = plaintext_hash,
10170 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10171 0x08, 0x09, 0x0A, 0x0B
10177 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10178 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10184 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10185 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10191 static const struct test_crypto_vector
10192 aes128cbc_hmac_sha1_test_vector = {
10193 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10194 .cipher_offset = 0,
10198 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10199 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10205 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10206 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10211 .data = plaintext_hash,
10215 .data = ciphertext512_aes128cbc,
10218 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10222 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10223 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10224 0xDE, 0xF4, 0xDE, 0xAD
10230 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10231 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10232 0x18, 0x8C, 0x1D, 0x32
10238 static const struct test_crypto_vector
10239 aes128cbc_hmac_sha1_aad_test_vector = {
10240 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10241 .cipher_offset = 12,
10245 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10246 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10252 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10253 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10258 .data = plaintext_hash,
10262 .data = ciphertext512_aes128cbc_aad,
10265 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10269 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10270 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10271 0xDE, 0xF4, 0xDE, 0xAD
10277 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10278 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10279 0x62, 0x8D, 0x62, 0x65
10286 data_corruption(uint8_t *data)
10292 tag_corruption(uint8_t *data, unsigned int tag_offset)
10294 data[tag_offset] += 1;
10298 create_auth_session(struct crypto_unittest_params *ut_params,
10300 const struct test_crypto_vector *reference,
10301 enum rte_crypto_auth_operation auth_op)
10303 struct crypto_testsuite_params *ts_params = &testsuite_params;
10304 uint8_t auth_key[reference->auth_key.len + 1];
10306 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10308 /* Setup Authentication Parameters */
10309 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10310 ut_params->auth_xform.auth.op = auth_op;
10311 ut_params->auth_xform.next = NULL;
10312 ut_params->auth_xform.auth.algo = reference->auth_algo;
10313 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10314 ut_params->auth_xform.auth.key.data = auth_key;
10315 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10317 /* Create Crypto session*/
10318 ut_params->sess = rte_cryptodev_sym_session_create(
10319 ts_params->session_mpool);
10321 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10322 &ut_params->auth_xform,
10323 ts_params->session_priv_mpool);
10325 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10331 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10333 const struct test_crypto_vector *reference,
10334 enum rte_crypto_auth_operation auth_op,
10335 enum rte_crypto_cipher_operation cipher_op)
10337 struct crypto_testsuite_params *ts_params = &testsuite_params;
10338 uint8_t cipher_key[reference->cipher_key.len + 1];
10339 uint8_t auth_key[reference->auth_key.len + 1];
10341 memcpy(cipher_key, reference->cipher_key.data,
10342 reference->cipher_key.len);
10343 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10345 /* Setup Authentication Parameters */
10346 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10347 ut_params->auth_xform.auth.op = auth_op;
10348 ut_params->auth_xform.auth.algo = reference->auth_algo;
10349 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10350 ut_params->auth_xform.auth.key.data = auth_key;
10351 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10353 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10354 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10355 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10357 ut_params->auth_xform.next = &ut_params->cipher_xform;
10359 /* Setup Cipher Parameters */
10360 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10361 ut_params->cipher_xform.next = NULL;
10362 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10363 ut_params->cipher_xform.cipher.op = cipher_op;
10364 ut_params->cipher_xform.cipher.key.data = cipher_key;
10365 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10366 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10367 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10370 /* Create Crypto session*/
10371 ut_params->sess = rte_cryptodev_sym_session_create(
10372 ts_params->session_mpool);
10374 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10375 &ut_params->auth_xform,
10376 ts_params->session_priv_mpool);
10378 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10384 create_auth_operation(struct crypto_testsuite_params *ts_params,
10385 struct crypto_unittest_params *ut_params,
10386 const struct test_crypto_vector *reference,
10387 unsigned int auth_generate)
10389 /* Generate Crypto op data structure */
10390 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10391 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10392 TEST_ASSERT_NOT_NULL(ut_params->op,
10393 "Failed to allocate pktmbuf offload");
10395 /* Set crypto operation data parameters */
10396 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10398 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10400 /* set crypto operation source mbuf */
10401 sym_op->m_src = ut_params->ibuf;
10404 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10405 ut_params->ibuf, reference->digest.len);
10407 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10408 "no room to append auth tag");
10410 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10411 ut_params->ibuf, reference->plaintext.len);
10414 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10416 memcpy(sym_op->auth.digest.data,
10417 reference->digest.data,
10418 reference->digest.len);
10420 debug_hexdump(stdout, "digest:",
10421 sym_op->auth.digest.data,
10422 reference->digest.len);
10424 sym_op->auth.data.length = reference->plaintext.len;
10425 sym_op->auth.data.offset = 0;
10431 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10432 struct crypto_unittest_params *ut_params,
10433 const struct test_crypto_vector *reference,
10434 unsigned int auth_generate)
10436 /* Generate Crypto op data structure */
10437 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10438 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10439 TEST_ASSERT_NOT_NULL(ut_params->op,
10440 "Failed to allocate pktmbuf offload");
10442 /* Set crypto operation data parameters */
10443 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10445 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10447 /* set crypto operation source mbuf */
10448 sym_op->m_src = ut_params->ibuf;
10451 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10452 ut_params->ibuf, reference->digest.len);
10454 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10455 "no room to append auth tag");
10457 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10458 ut_params->ibuf, reference->ciphertext.len);
10461 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10463 memcpy(sym_op->auth.digest.data,
10464 reference->digest.data,
10465 reference->digest.len);
10467 debug_hexdump(stdout, "digest:",
10468 sym_op->auth.digest.data,
10469 reference->digest.len);
10471 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10472 reference->iv.data, reference->iv.len);
10474 sym_op->cipher.data.length = 0;
10475 sym_op->cipher.data.offset = 0;
10477 sym_op->auth.data.length = reference->plaintext.len;
10478 sym_op->auth.data.offset = 0;
10484 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10485 struct crypto_unittest_params *ut_params,
10486 const struct test_crypto_vector *reference,
10487 unsigned int auth_generate)
10489 /* Generate Crypto op data structure */
10490 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10491 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10492 TEST_ASSERT_NOT_NULL(ut_params->op,
10493 "Failed to allocate pktmbuf offload");
10495 /* Set crypto operation data parameters */
10496 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10498 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10500 /* set crypto operation source mbuf */
10501 sym_op->m_src = ut_params->ibuf;
10504 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10505 ut_params->ibuf, reference->digest.len);
10507 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10508 "no room to append auth tag");
10510 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10511 ut_params->ibuf, reference->ciphertext.len);
10514 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10516 memcpy(sym_op->auth.digest.data,
10517 reference->digest.data,
10518 reference->digest.len);
10520 debug_hexdump(stdout, "digest:",
10521 sym_op->auth.digest.data,
10522 reference->digest.len);
10524 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10525 reference->iv.data, reference->iv.len);
10527 sym_op->cipher.data.length = reference->cipher_len;
10528 sym_op->cipher.data.offset = reference->cipher_offset;
10530 sym_op->auth.data.length = reference->plaintext.len;
10531 sym_op->auth.data.offset = reference->auth_offset;
10537 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10538 struct crypto_unittest_params *ut_params,
10539 const struct test_crypto_vector *reference)
10541 return create_auth_operation(ts_params, ut_params, reference, 0);
10545 create_auth_verify_GMAC_operation(
10546 struct crypto_testsuite_params *ts_params,
10547 struct crypto_unittest_params *ut_params,
10548 const struct test_crypto_vector *reference)
10550 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10554 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10555 struct crypto_unittest_params *ut_params,
10556 const struct test_crypto_vector *reference)
10558 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10562 test_authentication_verify_fail_when_data_corruption(
10563 struct crypto_testsuite_params *ts_params,
10564 struct crypto_unittest_params *ut_params,
10565 const struct test_crypto_vector *reference,
10566 unsigned int data_corrupted)
10570 uint8_t *plaintext;
10572 /* Verify the capabilities */
10573 struct rte_cryptodev_sym_capability_idx cap_idx;
10574 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10575 cap_idx.algo.auth = reference->auth_algo;
10576 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10580 /* Create session */
10581 retval = create_auth_session(ut_params,
10582 ts_params->valid_devs[0],
10584 RTE_CRYPTO_AUTH_OP_VERIFY);
10588 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10589 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10590 "Failed to allocate input buffer in mempool");
10592 /* clear mbuf payload */
10593 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10594 rte_pktmbuf_tailroom(ut_params->ibuf));
10596 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10597 reference->plaintext.len);
10598 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10599 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10601 debug_hexdump(stdout, "plaintext:", plaintext,
10602 reference->plaintext.len);
10604 /* Create operation */
10605 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10610 if (data_corrupted)
10611 data_corruption(plaintext);
10613 tag_corruption(plaintext, reference->plaintext.len);
10615 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10616 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10618 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10619 RTE_CRYPTO_OP_STATUS_SUCCESS,
10620 "authentication not failed");
10622 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10624 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10631 test_authentication_verify_GMAC_fail_when_corruption(
10632 struct crypto_testsuite_params *ts_params,
10633 struct crypto_unittest_params *ut_params,
10634 const struct test_crypto_vector *reference,
10635 unsigned int data_corrupted)
10638 uint8_t *plaintext;
10640 /* Verify the capabilities */
10641 struct rte_cryptodev_sym_capability_idx cap_idx;
10642 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10643 cap_idx.algo.auth = reference->auth_algo;
10644 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10648 /* Create session */
10649 retval = create_auth_cipher_session(ut_params,
10650 ts_params->valid_devs[0],
10652 RTE_CRYPTO_AUTH_OP_VERIFY,
10653 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10657 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10658 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10659 "Failed to allocate input buffer in mempool");
10661 /* clear mbuf payload */
10662 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10663 rte_pktmbuf_tailroom(ut_params->ibuf));
10665 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10666 reference->plaintext.len);
10667 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10668 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10670 debug_hexdump(stdout, "plaintext:", plaintext,
10671 reference->plaintext.len);
10673 /* Create operation */
10674 retval = create_auth_verify_GMAC_operation(ts_params,
10681 if (data_corrupted)
10682 data_corruption(plaintext);
10684 tag_corruption(plaintext, reference->aad.len);
10686 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10687 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10689 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10690 RTE_CRYPTO_OP_STATUS_SUCCESS,
10691 "authentication not failed");
10693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10695 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10702 test_authenticated_decryption_fail_when_corruption(
10703 struct crypto_testsuite_params *ts_params,
10704 struct crypto_unittest_params *ut_params,
10705 const struct test_crypto_vector *reference,
10706 unsigned int data_corrupted)
10710 uint8_t *ciphertext;
10712 /* Verify the capabilities */
10713 struct rte_cryptodev_sym_capability_idx cap_idx;
10714 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10715 cap_idx.algo.auth = reference->auth_algo;
10716 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10719 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10720 cap_idx.algo.cipher = reference->crypto_algo;
10721 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10725 /* Create session */
10726 retval = create_auth_cipher_session(ut_params,
10727 ts_params->valid_devs[0],
10729 RTE_CRYPTO_AUTH_OP_VERIFY,
10730 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10734 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10735 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10736 "Failed to allocate input buffer in mempool");
10738 /* clear mbuf payload */
10739 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10740 rte_pktmbuf_tailroom(ut_params->ibuf));
10742 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10743 reference->ciphertext.len);
10744 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10745 memcpy(ciphertext, reference->ciphertext.data,
10746 reference->ciphertext.len);
10748 /* Create operation */
10749 retval = create_cipher_auth_verify_operation(ts_params,
10756 if (data_corrupted)
10757 data_corruption(ciphertext);
10759 tag_corruption(ciphertext, reference->ciphertext.len);
10761 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10762 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10764 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10765 RTE_CRYPTO_OP_STATUS_SUCCESS,
10766 "authentication not failed");
10768 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10770 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10777 test_authenticated_encryt_with_esn(
10778 struct crypto_testsuite_params *ts_params,
10779 struct crypto_unittest_params *ut_params,
10780 const struct test_crypto_vector *reference)
10784 uint8_t *authciphertext, *plaintext, *auth_tag;
10785 uint16_t plaintext_pad_len;
10786 uint8_t cipher_key[reference->cipher_key.len + 1];
10787 uint8_t auth_key[reference->auth_key.len + 1];
10789 /* Verify the capabilities */
10790 struct rte_cryptodev_sym_capability_idx cap_idx;
10791 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10792 cap_idx.algo.auth = reference->auth_algo;
10793 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10796 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10797 cap_idx.algo.cipher = reference->crypto_algo;
10798 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10802 /* Create session */
10803 memcpy(cipher_key, reference->cipher_key.data,
10804 reference->cipher_key.len);
10805 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10807 /* Setup Cipher Parameters */
10808 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10809 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10810 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10811 ut_params->cipher_xform.cipher.key.data = cipher_key;
10812 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10813 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10814 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10816 ut_params->cipher_xform.next = &ut_params->auth_xform;
10818 /* Setup Authentication Parameters */
10819 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10820 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10821 ut_params->auth_xform.auth.algo = reference->auth_algo;
10822 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10823 ut_params->auth_xform.auth.key.data = auth_key;
10824 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10825 ut_params->auth_xform.next = NULL;
10827 /* Create Crypto session*/
10828 ut_params->sess = rte_cryptodev_sym_session_create(
10829 ts_params->session_mpool);
10831 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10833 &ut_params->cipher_xform,
10834 ts_params->session_priv_mpool);
10836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10838 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10840 "Failed to allocate input buffer in mempool");
10842 /* clear mbuf payload */
10843 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10844 rte_pktmbuf_tailroom(ut_params->ibuf));
10846 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10847 reference->plaintext.len);
10848 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10849 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10851 /* Create operation */
10852 retval = create_cipher_auth_operation(ts_params,
10859 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10860 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10863 ut_params->op = process_crypto_request(
10864 ts_params->valid_devs[0], ut_params->op);
10866 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10868 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10869 "crypto op processing failed");
10871 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10873 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10874 ut_params->op->sym->auth.data.offset);
10875 auth_tag = authciphertext + plaintext_pad_len;
10876 debug_hexdump(stdout, "ciphertext:", authciphertext,
10877 reference->ciphertext.len);
10878 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10880 /* Validate obuf */
10881 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10883 reference->ciphertext.data,
10884 reference->ciphertext.len,
10885 "Ciphertext data not as expected");
10887 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10889 reference->digest.data,
10890 reference->digest.len,
10891 "Generated digest not as expected");
10893 return TEST_SUCCESS;
10898 test_authenticated_decrypt_with_esn(
10899 struct crypto_testsuite_params *ts_params,
10900 struct crypto_unittest_params *ut_params,
10901 const struct test_crypto_vector *reference)
10905 uint8_t *ciphertext;
10906 uint8_t cipher_key[reference->cipher_key.len + 1];
10907 uint8_t auth_key[reference->auth_key.len + 1];
10909 /* Verify the capabilities */
10910 struct rte_cryptodev_sym_capability_idx cap_idx;
10911 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10912 cap_idx.algo.auth = reference->auth_algo;
10913 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10916 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10917 cap_idx.algo.cipher = reference->crypto_algo;
10918 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10922 /* Create session */
10923 memcpy(cipher_key, reference->cipher_key.data,
10924 reference->cipher_key.len);
10925 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10927 /* Setup Authentication Parameters */
10928 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10929 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10930 ut_params->auth_xform.auth.algo = reference->auth_algo;
10931 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10932 ut_params->auth_xform.auth.key.data = auth_key;
10933 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10934 ut_params->auth_xform.next = &ut_params->cipher_xform;
10936 /* Setup Cipher Parameters */
10937 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10938 ut_params->cipher_xform.next = NULL;
10939 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10940 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10941 ut_params->cipher_xform.cipher.key.data = cipher_key;
10942 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10943 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10944 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10946 /* Create Crypto session*/
10947 ut_params->sess = rte_cryptodev_sym_session_create(
10948 ts_params->session_mpool);
10950 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10952 &ut_params->auth_xform,
10953 ts_params->session_priv_mpool);
10955 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10957 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10958 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10959 "Failed to allocate input buffer in mempool");
10961 /* clear mbuf payload */
10962 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10963 rte_pktmbuf_tailroom(ut_params->ibuf));
10965 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10966 reference->ciphertext.len);
10967 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10968 memcpy(ciphertext, reference->ciphertext.data,
10969 reference->ciphertext.len);
10971 /* Create operation */
10972 retval = create_cipher_auth_verify_operation(ts_params,
10979 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10980 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10983 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10986 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10987 TEST_ASSERT_EQUAL(ut_params->op->status,
10988 RTE_CRYPTO_OP_STATUS_SUCCESS,
10989 "crypto op processing passed");
10991 ut_params->obuf = ut_params->op->sym->m_src;
10992 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10998 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10999 const struct aead_test_data *tdata,
11000 void *digest_mem, uint64_t digest_phys)
11002 struct crypto_testsuite_params *ts_params = &testsuite_params;
11003 struct crypto_unittest_params *ut_params = &unittest_params;
11005 const unsigned int auth_tag_len = tdata->auth_tag.len;
11006 const unsigned int iv_len = tdata->iv.len;
11007 unsigned int aad_len = tdata->aad.len;
11008 unsigned int aad_len_pad = 0;
11010 /* Generate Crypto op data structure */
11011 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11012 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11013 TEST_ASSERT_NOT_NULL(ut_params->op,
11014 "Failed to allocate symmetric crypto operation struct");
11016 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11018 sym_op->aead.digest.data = digest_mem;
11020 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11021 "no room to append digest");
11023 sym_op->aead.digest.phys_addr = digest_phys;
11025 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11026 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11028 debug_hexdump(stdout, "digest:",
11029 sym_op->aead.digest.data,
11033 /* Append aad data */
11034 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11035 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11036 uint8_t *, IV_OFFSET);
11038 /* Copy IV 1 byte after the IV pointer, according to the API */
11039 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11041 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11043 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11044 ut_params->ibuf, aad_len);
11045 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11046 "no room to prepend aad");
11047 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11050 memset(sym_op->aead.aad.data, 0, aad_len);
11051 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11052 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11054 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11055 debug_hexdump(stdout, "aad:",
11056 sym_op->aead.aad.data, aad_len);
11058 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11059 uint8_t *, IV_OFFSET);
11061 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11063 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11065 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11066 ut_params->ibuf, aad_len_pad);
11067 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11068 "no room to prepend aad");
11069 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11072 memset(sym_op->aead.aad.data, 0, aad_len);
11073 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11075 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11076 debug_hexdump(stdout, "aad:",
11077 sym_op->aead.aad.data, aad_len);
11080 sym_op->aead.data.length = tdata->plaintext.len;
11081 sym_op->aead.data.offset = aad_len_pad;
11086 #define SGL_MAX_NO 16
11089 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11090 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11092 struct crypto_testsuite_params *ts_params = &testsuite_params;
11093 struct crypto_unittest_params *ut_params = &unittest_params;
11094 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11097 int to_trn_tbl[SGL_MAX_NO];
11099 unsigned int trn_data = 0;
11100 uint8_t *plaintext, *ciphertext, *auth_tag;
11101 struct rte_cryptodev_info dev_info;
11103 /* Verify the capabilities */
11104 struct rte_cryptodev_sym_capability_idx cap_idx;
11105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11106 cap_idx.algo.aead = tdata->algo;
11107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11111 /* OOP not supported with CPU crypto */
11112 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11115 /* Detailed check for the particular SGL support flag */
11116 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11118 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11119 if (sgl_in && (!(dev_info.feature_flags &
11120 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11123 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11124 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11125 tdata->plaintext.len;
11126 if (sgl_in && !sgl_out) {
11127 if (!(dev_info.feature_flags &
11128 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11130 } else if (!sgl_in && sgl_out) {
11131 if (!(dev_info.feature_flags &
11132 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11134 } else if (sgl_in && sgl_out) {
11135 if (!(dev_info.feature_flags &
11136 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11141 if (fragsz > tdata->plaintext.len)
11142 fragsz = tdata->plaintext.len;
11144 uint16_t plaintext_len = fragsz;
11145 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11147 if (fragsz_oop > tdata->plaintext.len)
11148 frag_size_oop = tdata->plaintext.len;
11151 void *digest_mem = NULL;
11153 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11155 if (tdata->plaintext.len % fragsz != 0) {
11156 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11159 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11164 * For out-op-place we need to alloc another mbuf
11167 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11168 rte_pktmbuf_append(ut_params->obuf,
11169 frag_size_oop + prepend_len);
11170 buf_oop = ut_params->obuf;
11173 /* Create AEAD session */
11174 retval = create_aead_session(ts_params->valid_devs[0],
11176 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11177 tdata->key.data, tdata->key.len,
11178 tdata->aad.len, tdata->auth_tag.len,
11183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11185 /* clear mbuf payload */
11186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11187 rte_pktmbuf_tailroom(ut_params->ibuf));
11189 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11192 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11194 trn_data += plaintext_len;
11196 buf = ut_params->ibuf;
11199 * Loop until no more fragments
11202 while (trn_data < tdata->plaintext.len) {
11204 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11205 (tdata->plaintext.len - trn_data) : fragsz;
11207 to_trn_tbl[ecx++] = to_trn;
11209 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11212 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11213 rte_pktmbuf_tailroom(buf));
11216 if (oop && !fragsz_oop) {
11217 buf_last_oop = buf_oop->next =
11218 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11219 buf_oop = buf_oop->next;
11220 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11221 0, rte_pktmbuf_tailroom(buf_oop));
11222 rte_pktmbuf_append(buf_oop, to_trn);
11225 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11228 memcpy(plaintext, tdata->plaintext.data + trn_data,
11230 trn_data += to_trn;
11231 if (trn_data == tdata->plaintext.len) {
11234 digest_mem = rte_pktmbuf_append(buf_oop,
11235 tdata->auth_tag.len);
11237 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11238 tdata->auth_tag.len);
11242 uint64_t digest_phys = 0;
11244 ut_params->ibuf->nb_segs = segs;
11247 if (fragsz_oop && oop) {
11251 if (frag_size_oop == tdata->plaintext.len) {
11252 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11253 tdata->auth_tag.len);
11255 digest_phys = rte_pktmbuf_iova_offset(
11257 tdata->plaintext.len + prepend_len);
11260 trn_data = frag_size_oop;
11261 while (trn_data < tdata->plaintext.len) {
11264 (tdata->plaintext.len - trn_data <
11266 (tdata->plaintext.len - trn_data) :
11269 to_trn_tbl[ecx++] = to_trn;
11271 buf_last_oop = buf_oop->next =
11272 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11273 buf_oop = buf_oop->next;
11274 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11275 0, rte_pktmbuf_tailroom(buf_oop));
11276 rte_pktmbuf_append(buf_oop, to_trn);
11278 trn_data += to_trn;
11280 if (trn_data == tdata->plaintext.len) {
11281 digest_mem = rte_pktmbuf_append(buf_oop,
11282 tdata->auth_tag.len);
11286 ut_params->obuf->nb_segs = segs;
11290 * Place digest at the end of the last buffer
11293 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11294 if (oop && buf_last_oop)
11295 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11297 if (!digest_mem && !oop) {
11298 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11299 + tdata->auth_tag.len);
11300 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11301 tdata->plaintext.len);
11304 /* Create AEAD operation */
11305 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11306 tdata, digest_mem, digest_phys);
11311 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11313 ut_params->op->sym->m_src = ut_params->ibuf;
11315 ut_params->op->sym->m_dst = ut_params->obuf;
11317 /* Process crypto operation */
11318 if (oop == IN_PLACE &&
11319 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11320 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11322 TEST_ASSERT_NOT_NULL(
11323 process_crypto_request(ts_params->valid_devs[0],
11324 ut_params->op), "failed to process sym crypto op");
11326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11327 "crypto op processing failed");
11330 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11331 uint8_t *, prepend_len);
11333 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11334 uint8_t *, prepend_len);
11338 fragsz = fragsz_oop;
11340 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11342 tdata->ciphertext.data,
11344 "Ciphertext data not as expected");
11346 buf = ut_params->op->sym->m_src->next;
11348 buf = ut_params->op->sym->m_dst->next;
11350 unsigned int off = fragsz;
11354 ciphertext = rte_pktmbuf_mtod(buf,
11357 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11359 tdata->ciphertext.data + off,
11361 "Ciphertext data not as expected");
11363 off += to_trn_tbl[ecx++];
11367 auth_tag = digest_mem;
11368 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11370 tdata->auth_tag.data,
11371 tdata->auth_tag.len,
11372 "Generated auth tag not as expected");
11378 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11380 return test_authenticated_encryption_SGL(
11381 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11385 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11387 return test_authenticated_encryption_SGL(
11388 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11392 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11394 return test_authenticated_encryption_SGL(
11395 &gcm_test_case_8, OUT_OF_PLACE, 400,
11396 gcm_test_case_8.plaintext.len);
11400 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11402 /* This test is not for OPENSSL PMD */
11403 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11404 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11407 return test_authenticated_encryption_SGL(
11408 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11412 test_authentication_verify_fail_when_data_corrupted(
11413 struct crypto_testsuite_params *ts_params,
11414 struct crypto_unittest_params *ut_params,
11415 const struct test_crypto_vector *reference)
11417 return test_authentication_verify_fail_when_data_corruption(
11418 ts_params, ut_params, reference, 1);
11422 test_authentication_verify_fail_when_tag_corrupted(
11423 struct crypto_testsuite_params *ts_params,
11424 struct crypto_unittest_params *ut_params,
11425 const struct test_crypto_vector *reference)
11427 return test_authentication_verify_fail_when_data_corruption(
11428 ts_params, ut_params, reference, 0);
11432 test_authentication_verify_GMAC_fail_when_data_corrupted(
11433 struct crypto_testsuite_params *ts_params,
11434 struct crypto_unittest_params *ut_params,
11435 const struct test_crypto_vector *reference)
11437 return test_authentication_verify_GMAC_fail_when_corruption(
11438 ts_params, ut_params, reference, 1);
11442 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11443 struct crypto_testsuite_params *ts_params,
11444 struct crypto_unittest_params *ut_params,
11445 const struct test_crypto_vector *reference)
11447 return test_authentication_verify_GMAC_fail_when_corruption(
11448 ts_params, ut_params, reference, 0);
11452 test_authenticated_decryption_fail_when_data_corrupted(
11453 struct crypto_testsuite_params *ts_params,
11454 struct crypto_unittest_params *ut_params,
11455 const struct test_crypto_vector *reference)
11457 return test_authenticated_decryption_fail_when_corruption(
11458 ts_params, ut_params, reference, 1);
11462 test_authenticated_decryption_fail_when_tag_corrupted(
11463 struct crypto_testsuite_params *ts_params,
11464 struct crypto_unittest_params *ut_params,
11465 const struct test_crypto_vector *reference)
11467 return test_authenticated_decryption_fail_when_corruption(
11468 ts_params, ut_params, reference, 0);
11472 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11474 return test_authentication_verify_fail_when_data_corrupted(
11475 &testsuite_params, &unittest_params,
11476 &hmac_sha1_test_crypto_vector);
11480 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11482 return test_authentication_verify_fail_when_tag_corrupted(
11483 &testsuite_params, &unittest_params,
11484 &hmac_sha1_test_crypto_vector);
11488 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11490 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11491 &testsuite_params, &unittest_params,
11492 &aes128_gmac_test_vector);
11496 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11498 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11499 &testsuite_params, &unittest_params,
11500 &aes128_gmac_test_vector);
11504 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11506 return test_authenticated_decryption_fail_when_data_corrupted(
11509 &aes128cbc_hmac_sha1_test_vector);
11513 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11515 return test_authenticated_decryption_fail_when_tag_corrupted(
11518 &aes128cbc_hmac_sha1_test_vector);
11522 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11524 return test_authenticated_encryt_with_esn(
11527 &aes128cbc_hmac_sha1_aad_test_vector);
11531 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11533 return test_authenticated_decrypt_with_esn(
11536 &aes128cbc_hmac_sha1_aad_test_vector);
11539 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11541 /* global AESNI slave IDs for the scheduler test */
11542 uint8_t aesni_ids[2];
11545 test_scheduler_attach_slave_op(void)
11547 struct crypto_testsuite_params *ts_params = &testsuite_params;
11548 uint8_t sched_id = ts_params->valid_devs[0];
11549 uint32_t nb_devs, i, nb_devs_attached = 0;
11551 char vdev_name[32];
11553 /* create 2 AESNI_MB if necessary */
11554 nb_devs = rte_cryptodev_device_count_by_driver(
11555 rte_cryptodev_driver_id_get(
11556 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11558 for (i = nb_devs; i < 2; i++) {
11559 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11560 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11562 ret = rte_vdev_init(vdev_name, NULL);
11564 TEST_ASSERT(ret == 0,
11565 "Failed to create instance %u of"
11567 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11571 /* attach 2 AESNI_MB cdevs */
11572 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11574 struct rte_cryptodev_info info;
11575 unsigned int session_size;
11577 rte_cryptodev_info_get(i, &info);
11578 if (info.driver_id != rte_cryptodev_driver_id_get(
11579 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11582 session_size = rte_cryptodev_sym_get_private_session_size(i);
11584 * Create the session mempool again, since now there are new devices
11585 * to use the mempool.
11587 if (ts_params->session_mpool) {
11588 rte_mempool_free(ts_params->session_mpool);
11589 ts_params->session_mpool = NULL;
11591 if (ts_params->session_priv_mpool) {
11592 rte_mempool_free(ts_params->session_priv_mpool);
11593 ts_params->session_priv_mpool = NULL;
11596 if (info.sym.max_nb_sessions != 0 &&
11597 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11598 RTE_LOG(ERR, USER1,
11599 "Device does not support "
11600 "at least %u sessions\n",
11602 return TEST_FAILED;
11605 * Create mempool with maximum number of sessions,
11606 * to include the session headers
11608 if (ts_params->session_mpool == NULL) {
11609 ts_params->session_mpool =
11610 rte_cryptodev_sym_session_pool_create(
11612 MAX_NB_SESSIONS, 0, 0, 0,
11614 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11615 "session mempool allocation failed");
11619 * Create mempool with maximum number of sessions,
11620 * to include device specific session private data
11622 if (ts_params->session_priv_mpool == NULL) {
11623 ts_params->session_priv_mpool = rte_mempool_create(
11624 "test_sess_mp_priv",
11627 0, 0, NULL, NULL, NULL,
11628 NULL, SOCKET_ID_ANY,
11631 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11632 "session mempool allocation failed");
11635 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11636 ts_params->qp_conf.mp_session_private =
11637 ts_params->session_priv_mpool;
11639 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11642 TEST_ASSERT(ret == 0,
11643 "Failed to attach device %u of pmd : %s", i,
11644 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11646 aesni_ids[nb_devs_attached] = (uint8_t)i;
11648 nb_devs_attached++;
11655 test_scheduler_detach_slave_op(void)
11657 struct crypto_testsuite_params *ts_params = &testsuite_params;
11658 uint8_t sched_id = ts_params->valid_devs[0];
11662 for (i = 0; i < 2; i++) {
11663 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11665 TEST_ASSERT(ret == 0,
11666 "Failed to detach device %u", aesni_ids[i]);
11673 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11675 struct crypto_testsuite_params *ts_params = &testsuite_params;
11676 uint8_t sched_id = ts_params->valid_devs[0];
11678 return rte_cryptodev_scheduler_mode_set(sched_id,
11683 test_scheduler_mode_roundrobin_op(void)
11685 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11686 0, "Failed to set roundrobin mode");
11692 test_scheduler_mode_multicore_op(void)
11694 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11695 0, "Failed to set multicore mode");
11701 test_scheduler_mode_failover_op(void)
11703 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11704 0, "Failed to set failover mode");
11710 test_scheduler_mode_pkt_size_distr_op(void)
11712 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11713 0, "Failed to set pktsize mode");
11718 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11719 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11720 .setup = testsuite_setup,
11721 .teardown = testsuite_teardown,
11722 .unit_test_cases = {
11724 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11725 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11726 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11727 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11728 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11729 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11732 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11733 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11734 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11735 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11736 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11737 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11740 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11741 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11743 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11744 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11745 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11748 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11749 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11750 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11751 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11752 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11753 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11755 TEST_CASES_END() /**< NULL terminate unit test array */
11759 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11761 static struct unit_test_suite cryptodev_testsuite = {
11762 .suite_name = "Crypto Unit Test Suite",
11763 .setup = testsuite_setup,
11764 .teardown = testsuite_teardown,
11765 .unit_test_cases = {
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_device_configure_invalid_dev_id),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_device_configure_invalid_queue_pair_ids),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_queue_pair_descriptor_setup),
11773 TEST_CASE_ST(ut_setup, ut_teardown,
11774 test_multi_session),
11775 TEST_CASE_ST(ut_setup, ut_teardown,
11776 test_multi_session_random_usage),
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_null_invalid_operation),
11780 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11782 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11783 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11784 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11785 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11786 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11787 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11788 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11789 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11790 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11792 /** AES CCM Authenticated Encryption 128 bits key */
11793 TEST_CASE_ST(ut_setup, ut_teardown,
11794 test_AES_CCM_authenticated_encryption_test_case_128_1),
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_AES_CCM_authenticated_encryption_test_case_128_2),
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_AES_CCM_authenticated_encryption_test_case_128_3),
11800 /** AES CCM Authenticated Decryption 128 bits key*/
11801 TEST_CASE_ST(ut_setup, ut_teardown,
11802 test_AES_CCM_authenticated_decryption_test_case_128_1),
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_AES_CCM_authenticated_decryption_test_case_128_2),
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_AES_CCM_authenticated_decryption_test_case_128_3),
11808 /** AES CCM Authenticated Encryption 192 bits key */
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_AES_CCM_authenticated_encryption_test_case_192_1),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_AES_CCM_authenticated_encryption_test_case_192_2),
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_AES_CCM_authenticated_encryption_test_case_192_3),
11816 /** AES CCM Authenticated Decryption 192 bits key*/
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_CCM_authenticated_decryption_test_case_192_1),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_AES_CCM_authenticated_decryption_test_case_192_2),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_CCM_authenticated_decryption_test_case_192_3),
11824 /** AES CCM Authenticated Encryption 256 bits key */
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_CCM_authenticated_encryption_test_case_256_1),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_CCM_authenticated_encryption_test_case_256_2),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_CCM_authenticated_encryption_test_case_256_3),
11832 /** AES CCM Authenticated Decryption 256 bits key*/
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_CCM_authenticated_decryption_test_case_256_1),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_CCM_authenticated_decryption_test_case_256_2),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_CCM_authenticated_decryption_test_case_256_3),
11840 /** AES GCM Authenticated Encryption */
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_GCM_authenticated_encryption_test_case_1),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_GCM_authenticated_encryption_test_case_2),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_GCM_authenticated_encryption_test_case_3),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_GCM_authenticated_encryption_test_case_4),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_AES_GCM_authenticated_encryption_test_case_5),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_authenticated_encryption_test_case_6),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_authenticated_encryption_test_case_7),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_authenticated_encryption_test_case_8),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11868 /** AES GCM Authenticated Decryption */
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_authenticated_decryption_test_case_1),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_authenticated_decryption_test_case_2),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_AES_GCM_authenticated_decryption_test_case_3),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_authenticated_decryption_test_case_4),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_authenticated_decryption_test_case_5),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_authenticated_decryption_test_case_6),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_authenticated_decryption_test_case_7),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_authenticated_decryption_test_case_8),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11888 /** AES GCM Authenticated Encryption 192 bits key */
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_auth_encryption_test_case_192_1),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_auth_encryption_test_case_192_2),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_auth_encryption_test_case_192_3),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_auth_encryption_test_case_192_4),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_auth_encryption_test_case_192_5),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_auth_encryption_test_case_192_6),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_auth_encryption_test_case_192_7),
11904 /** AES GCM Authenticated Decryption 192 bits key */
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_auth_decryption_test_case_192_1),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_decryption_test_case_192_2),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_decryption_test_case_192_3),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_decryption_test_case_192_4),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_decryption_test_case_192_5),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_decryption_test_case_192_6),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_decryption_test_case_192_7),
11920 /** AES GCM Authenticated Encryption 256 bits key */
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_auth_encryption_test_case_256_1),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_encryption_test_case_256_2),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_encryption_test_case_256_3),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_encryption_test_case_256_4),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_encryption_test_case_256_5),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_encryption_test_case_256_6),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_encryption_test_case_256_7),
11936 /** AES GCM Authenticated Decryption 256 bits key */
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_auth_decryption_test_case_256_1),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_auth_decryption_test_case_256_2),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_auth_decryption_test_case_256_3),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_decryption_test_case_256_4),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_decryption_test_case_256_5),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_decryption_test_case_256_6),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_decryption_test_case_256_7),
11952 /** AES GCM Authenticated Encryption big aad size */
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_encryption_test_case_aad_1),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GCM_auth_encryption_test_case_aad_2),
11958 /** AES GCM Authenticated Decryption big aad size */
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_decryption_test_case_aad_1),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GCM_auth_decryption_test_case_aad_2),
11964 /** Out of place tests */
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11970 /** Session-less tests */
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11976 /** AES GMAC Authentication */
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_GMAC_authentication_test_case_1),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_AES_GMAC_authentication_verify_test_case_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GMAC_authentication_test_case_2),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GMAC_authentication_verify_test_case_2),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_GMAC_authentication_test_case_3),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GMAC_authentication_verify_test_case_3),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GMAC_authentication_test_case_4),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_GMAC_authentication_verify_test_case_4),
11994 /** SNOW 3G encrypt only (UEA2) */
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_snow3g_encryption_test_case_1),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_snow3g_encryption_test_case_2),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_encryption_test_case_3),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_encryption_test_case_4),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_snow3g_encryption_test_case_5),
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_snow3g_encryption_test_case_1_oop),
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_snow3g_encryption_test_case_1_oop_sgl),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_snow3g_encryption_test_case_1_offset_oop),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_snow3g_decryption_test_case_1_oop),
12015 /** SNOW 3G generate auth, then encrypt (UEA2) */
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_snow3g_auth_cipher_test_case_1),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_snow3g_auth_cipher_test_case_2),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_snow3g_auth_cipher_test_case_2_oop),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_snow3g_auth_cipher_part_digest_enc),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_snow3g_auth_cipher_part_digest_enc_oop),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_auth_cipher_test_case_3_sgl),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_snow3g_auth_cipher_part_digest_enc_sgl),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12035 /** SNOW 3G decrypt (UEA2), then verify auth */
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_auth_cipher_verify_test_case_1),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_auth_cipher_verify_test_case_2),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_auth_cipher_verify_test_case_2_oop),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_verify_part_digest_enc),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12055 /** SNOW 3G decrypt only (UEA2) */
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_decryption_test_case_1),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_decryption_test_case_2),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_decryption_test_case_3),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_decryption_test_case_4),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_decryption_test_case_5),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_decryption_with_digest_test_case_1),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_hash_generate_test_case_1),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_hash_generate_test_case_2),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_hash_generate_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_generate_test_case_4),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_snow3g_hash_generate_test_case_5),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_snow3g_hash_generate_test_case_6),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_hash_verify_test_case_1),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_hash_verify_test_case_2),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_snow3g_hash_verify_test_case_3),
12087 /* Tests with buffers which length is not byte-aligned */
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_snow3g_hash_verify_test_case_4),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_snow3g_hash_verify_test_case_5),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_snow3g_hash_verify_test_case_6),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_snow3g_cipher_auth_test_case_1),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_snow3g_auth_cipher_with_digest_test_case_1),
12099 /** ZUC encrypt only (EEA3) */
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_zuc_encryption_test_case_1),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_zuc_encryption_test_case_2),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_zuc_encryption_test_case_3),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_zuc_encryption_test_case_4),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_zuc_encryption_test_case_5),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_zuc_encryption_test_case_6_sgl),
12113 /** ZUC authenticate (EIA3) */
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_zuc_hash_generate_test_case_1),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_zuc_hash_generate_test_case_2),
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_zuc_hash_generate_test_case_3),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_hash_generate_test_case_4),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_hash_generate_test_case_5),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_hash_generate_test_case_6),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_hash_generate_test_case_7),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_zuc_hash_generate_test_case_8),
12131 /** ZUC alg-chain (EEA3/EIA3) */
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_zuc_cipher_auth_test_case_1),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_cipher_auth_test_case_2),
12137 /** ZUC generate auth, then encrypt (EEA3) */
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_auth_cipher_test_case_1),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_auth_cipher_test_case_1_oop),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_auth_cipher_test_case_1_sgl),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_auth_cipher_test_case_1_oop_sgl),
12147 /** ZUC decrypt (EEA3), then verify auth */
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_auth_cipher_verify_test_case_1),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_zuc_auth_cipher_verify_test_case_1_oop),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_zuc_auth_cipher_verify_test_case_1_sgl),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12157 /** HMAC_MD5 Authentication */
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_MD5_HMAC_generate_case_1),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_MD5_HMAC_verify_case_1),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_MD5_HMAC_generate_case_2),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_MD5_HMAC_verify_case_2),
12167 /** KASUMI hash only (UIA1) */
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_kasumi_hash_generate_test_case_1),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_kasumi_hash_generate_test_case_2),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_hash_generate_test_case_3),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_hash_generate_test_case_4),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_hash_generate_test_case_5),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_kasumi_hash_generate_test_case_6),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_kasumi_hash_verify_test_case_1),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_kasumi_hash_verify_test_case_2),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_kasumi_hash_verify_test_case_3),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_verify_test_case_4),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_verify_test_case_5),
12192 /** KASUMI encrypt only (UEA1) */
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_encryption_test_case_1),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_kasumi_encryption_test_case_1_sgl),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_kasumi_encryption_test_case_1_oop),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_encryption_test_case_1_oop_sgl),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_encryption_test_case_2),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_encryption_test_case_3),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_encryption_test_case_4),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_encryption_test_case_5),
12210 /** KASUMI decrypt only (UEA1) */
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_decryption_test_case_1),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_decryption_test_case_2),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_decryption_test_case_3),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_decryption_test_case_4),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_decryption_test_case_5),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_decryption_test_case_1_oop),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_kasumi_cipher_auth_test_case_1),
12227 /** KASUMI generate auth, then encrypt (F8) */
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 test_kasumi_auth_cipher_test_case_1),
12230 TEST_CASE_ST(ut_setup, ut_teardown,
12231 test_kasumi_auth_cipher_test_case_2),
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_kasumi_auth_cipher_test_case_2_oop),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_kasumi_auth_cipher_test_case_2_sgl),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12239 /** KASUMI decrypt (F8), then verify auth */
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_kasumi_auth_cipher_verify_test_case_1),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_kasumi_auth_cipher_verify_test_case_2),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_kasumi_auth_cipher_verify_test_case_2_oop),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12251 /** ESN Testcase */
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12257 /** Negative tests */
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 authentication_verify_AES128_GMAC_fail_data_corrupt),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12295 /** Mixed CIPHER + HASH algorithms */
12296 /** AUTH AES CMAC + CIPHER AES CTR */
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12314 /** AUTH ZUC + CIPHER SNOW3G */
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_auth_zuc_cipher_snow_test_case_1),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_verify_auth_zuc_cipher_snow_test_case_1),
12319 /** AUTH AES CMAC + CIPHER SNOW3G */
12320 TEST_CASE_ST(ut_setup, ut_teardown,
12321 test_auth_aes_cmac_cipher_snow_test_case_1),
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12324 /** AUTH ZUC + CIPHER AES CTR */
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_auth_zuc_cipher_aes_ctr_test_case_1),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12329 /** AUTH SNOW3G + CIPHER AES CTR */
12330 TEST_CASE_ST(ut_setup, ut_teardown,
12331 test_auth_snow_cipher_aes_ctr_test_case_1),
12332 TEST_CASE_ST(ut_setup, ut_teardown,
12333 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12334 /** AUTH SNOW3G + CIPHER ZUC */
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_auth_snow_cipher_zuc_test_case_1),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_verify_auth_snow_cipher_zuc_test_case_1),
12339 /** AUTH AES CMAC + CIPHER ZUC */
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_auth_aes_cmac_cipher_zuc_test_case_1),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12345 /** AUTH NULL + CIPHER SNOW3G */
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_auth_null_cipher_snow_test_case_1),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_verify_auth_null_cipher_snow_test_case_1),
12350 /** AUTH NULL + CIPHER ZUC */
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_auth_null_cipher_zuc_test_case_1),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_verify_auth_null_cipher_zuc_test_case_1),
12355 /** AUTH SNOW3G + CIPHER NULL */
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_auth_snow_cipher_null_test_case_1),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_verify_auth_snow_cipher_null_test_case_1),
12360 /** AUTH ZUC + CIPHER NULL */
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_auth_zuc_cipher_null_test_case_1),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_verify_auth_zuc_cipher_null_test_case_1),
12365 /** AUTH NULL + CIPHER AES CTR */
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_auth_null_cipher_aes_ctr_test_case_1),
12368 TEST_CASE_ST(ut_setup, ut_teardown,
12369 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12370 /** AUTH AES CMAC + CIPHER NULL */
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_auth_aes_cmac_cipher_null_test_case_1),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12376 TEST_CASES_END() /**< NULL terminate unit test array */
12380 static struct unit_test_suite cryptodev_virtio_testsuite = {
12381 .suite_name = "Crypto VIRTIO Unit Test Suite",
12382 .setup = testsuite_setup,
12383 .teardown = testsuite_teardown,
12384 .unit_test_cases = {
12385 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12387 TEST_CASES_END() /**< NULL terminate unit test array */
12391 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12392 .suite_name = "Crypto CAAM JR Unit Test Suite",
12393 .setup = testsuite_setup,
12394 .teardown = testsuite_teardown,
12395 .unit_test_cases = {
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 test_device_configure_invalid_dev_id),
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_multi_session),
12401 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12402 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12403 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12404 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12405 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12407 TEST_CASES_END() /**< NULL terminate unit test array */
12411 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12412 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12413 .setup = testsuite_setup,
12414 .teardown = testsuite_teardown,
12415 .unit_test_cases = {
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_device_configure_invalid_dev_id),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_multi_session),
12421 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12422 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12423 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12424 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12425 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12427 #ifdef RTE_LIBRTE_SECURITY
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_PDCP_PROTO_cplane_encap_all),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_PDCP_PROTO_cplane_decap_all),
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_PDCP_PROTO_uplane_encap_all),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_PDCP_PROTO_uplane_decap_all),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_PDCP_PROTO_SGL_in_place_32B),
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_PDCP_PROTO_SGL_oop_32B_128B),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_PDCP_PROTO_SGL_oop_32B_40B),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_PDCP_PROTO_SGL_oop_128B_32B),
12449 /** AES GCM Authenticated Encryption */
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_AES_GCM_authenticated_encryption_test_case_1),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_authenticated_encryption_test_case_2),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_AES_GCM_authenticated_encryption_test_case_3),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_AES_GCM_authenticated_encryption_test_case_4),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_AES_GCM_authenticated_encryption_test_case_5),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_AES_GCM_authenticated_encryption_test_case_6),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_AES_GCM_authenticated_encryption_test_case_7),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_AES_GCM_authenticated_encryption_test_case_8),
12475 /** AES GCM Authenticated Decryption */
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_GCM_authenticated_decryption_test_case_1),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_AES_GCM_authenticated_decryption_test_case_2),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_AES_GCM_authenticated_decryption_test_case_3),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_AES_GCM_authenticated_decryption_test_case_4),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_AES_GCM_authenticated_decryption_test_case_5),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_GCM_authenticated_decryption_test_case_6),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_AES_GCM_authenticated_decryption_test_case_7),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_AES_GCM_authenticated_decryption_test_case_8),
12493 /** AES GCM Authenticated Encryption 192 bits key */
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_AES_GCM_auth_encryption_test_case_192_1),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_AES_GCM_auth_encryption_test_case_192_2),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_AES_GCM_auth_encryption_test_case_192_3),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_auth_encryption_test_case_192_4),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_auth_encryption_test_case_192_5),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_auth_encryption_test_case_192_6),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_auth_encryption_test_case_192_7),
12509 /** AES GCM Authenticated Decryption 192 bits key */
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_auth_decryption_test_case_192_1),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_auth_decryption_test_case_192_2),
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_AES_GCM_auth_decryption_test_case_192_3),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_auth_decryption_test_case_192_4),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_auth_decryption_test_case_192_5),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_decryption_test_case_192_6),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_decryption_test_case_192_7),
12525 /** AES GCM Authenticated Encryption 256 bits key */
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_auth_encryption_test_case_256_1),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_auth_encryption_test_case_256_2),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_auth_encryption_test_case_256_3),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_auth_encryption_test_case_256_4),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_auth_encryption_test_case_256_5),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_encryption_test_case_256_6),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_encryption_test_case_256_7),
12541 /** AES GCM Authenticated Decryption 256 bits key */
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_decryption_test_case_256_1),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_auth_decryption_test_case_256_2),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_auth_decryption_test_case_256_3),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_auth_decryption_test_case_256_4),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_auth_decryption_test_case_256_5),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_decryption_test_case_256_6),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_decryption_test_case_256_7),
12557 /** Out of place tests */
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12563 /** SNOW 3G encrypt only (UEA2) */
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_snow3g_encryption_test_case_1),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_snow3g_encryption_test_case_2),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_snow3g_encryption_test_case_3),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_snow3g_encryption_test_case_4),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_encryption_test_case_5),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_snow3g_encryption_test_case_1_oop),
12577 TEST_CASE_ST(ut_setup, ut_teardown,
12578 test_snow3g_encryption_test_case_1_oop_sgl),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_snow3g_decryption_test_case_1_oop),
12582 /** SNOW 3G decrypt only (UEA2) */
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_snow3g_decryption_test_case_1),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_snow3g_decryption_test_case_2),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_snow3g_decryption_test_case_3),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_snow3g_decryption_test_case_4),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_snow3g_decryption_test_case_5),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_snow3g_hash_generate_test_case_1),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_snow3g_hash_generate_test_case_2),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_snow3g_hash_generate_test_case_3),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_snow3g_hash_verify_test_case_1),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_snow3g_hash_verify_test_case_2),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_snow3g_hash_verify_test_case_3),
12607 /** ZUC encrypt only (EEA3) */
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_zuc_encryption_test_case_1),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_zuc_encryption_test_case_2),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_zuc_encryption_test_case_3),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_zuc_encryption_test_case_4),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_zuc_encryption_test_case_5),
12619 /** ZUC authenticate (EIA3) */
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_zuc_hash_generate_test_case_6),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_zuc_hash_generate_test_case_7),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_zuc_hash_generate_test_case_8),
12627 /** Negative tests */
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12667 TEST_CASES_END() /**< NULL terminate unit test array */
12671 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12672 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12673 .setup = testsuite_setup,
12674 .teardown = testsuite_teardown,
12675 .unit_test_cases = {
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 test_device_configure_invalid_dev_id),
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 test_multi_session),
12680 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12681 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12682 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12683 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12684 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12686 #ifdef RTE_LIBRTE_SECURITY
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_PDCP_PROTO_cplane_encap_all),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_PDCP_PROTO_cplane_decap_all),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_PDCP_PROTO_uplane_encap_all),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_PDCP_PROTO_uplane_decap_all),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_PDCP_PROTO_SGL_in_place_32B),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_PDCP_PROTO_SGL_oop_32B_128B),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_PDCP_PROTO_SGL_oop_32B_40B),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_PDCP_PROTO_SGL_oop_128B_32B),
12708 /** AES GCM Authenticated Encryption */
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_authenticated_encryption_test_case_1),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_authenticated_encryption_test_case_2),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_authenticated_encryption_test_case_3),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_authenticated_encryption_test_case_4),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_authenticated_encryption_test_case_5),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_authenticated_encryption_test_case_6),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_authenticated_encryption_test_case_7),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_authenticated_encryption_test_case_8),
12734 /** AES GCM Authenticated Decryption */
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_authenticated_decryption_test_case_1),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_AES_GCM_authenticated_decryption_test_case_2),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_authenticated_decryption_test_case_3),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_authenticated_decryption_test_case_4),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_authenticated_decryption_test_case_5),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_decryption_test_case_6),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_decryption_test_case_7),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_authenticated_decryption_test_case_8),
12752 /** AES GCM Authenticated Encryption 192 bits key */
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_auth_encryption_test_case_192_1),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_auth_encryption_test_case_192_2),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_encryption_test_case_192_3),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_encryption_test_case_192_4),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_192_5),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_192_6),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_192_7),
12768 /** AES GCM Authenticated Decryption 192 bits key */
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_auth_decryption_test_case_192_1),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_auth_decryption_test_case_192_2),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_auth_decryption_test_case_192_3),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_auth_decryption_test_case_192_4),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_192_5),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_192_6),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_192_7),
12784 /** AES GCM Authenticated Encryption 256 bits key */
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_auth_encryption_test_case_256_1),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_auth_encryption_test_case_256_2),
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_AES_GCM_auth_encryption_test_case_256_3),
12791 TEST_CASE_ST(ut_setup, ut_teardown,
12792 test_AES_GCM_auth_encryption_test_case_256_4),
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_auth_encryption_test_case_256_5),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_AES_GCM_auth_encryption_test_case_256_6),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_AES_GCM_auth_encryption_test_case_256_7),
12800 /** AES GCM Authenticated Decryption 256 bits key */
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GCM_auth_decryption_test_case_256_1),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_AES_GCM_auth_decryption_test_case_256_2),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_AES_GCM_auth_decryption_test_case_256_3),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_AES_GCM_auth_decryption_test_case_256_4),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_AES_GCM_auth_decryption_test_case_256_5),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_AES_GCM_auth_decryption_test_case_256_6),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_AES_GCM_auth_decryption_test_case_256_7),
12816 /** Out of place tests */
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12822 /** SNOW 3G encrypt only (UEA2) */
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_snow3g_encryption_test_case_1),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_snow3g_encryption_test_case_2),
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_snow3g_encryption_test_case_3),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_encryption_test_case_4),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_snow3g_encryption_test_case_5),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_snow3g_encryption_test_case_1_oop),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_snow3g_encryption_test_case_1_oop_sgl),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_snow3g_decryption_test_case_1_oop),
12841 /** SNOW 3G decrypt only (UEA2) */
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_snow3g_decryption_test_case_1),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_snow3g_decryption_test_case_2),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_snow3g_decryption_test_case_3),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_snow3g_decryption_test_case_4),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_snow3g_decryption_test_case_5),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_snow3g_hash_generate_test_case_1),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_snow3g_hash_generate_test_case_2),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_snow3g_hash_generate_test_case_3),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_snow3g_hash_verify_test_case_1),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_snow3g_hash_verify_test_case_2),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_snow3g_hash_verify_test_case_3),
12866 /** ZUC encrypt only (EEA3) */
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_zuc_encryption_test_case_1),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_zuc_encryption_test_case_2),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_zuc_encryption_test_case_3),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_zuc_encryption_test_case_4),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_zuc_encryption_test_case_5),
12878 /** ZUC authenticate (EIA3) */
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_zuc_hash_generate_test_case_6),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_zuc_hash_generate_test_case_7),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_zuc_hash_generate_test_case_8),
12886 /** HMAC_MD5 Authentication */
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_MD5_HMAC_generate_case_1),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_MD5_HMAC_verify_case_1),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_MD5_HMAC_generate_case_2),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_MD5_HMAC_verify_case_2),
12896 /** Negative tests */
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12911 TEST_CASE_ST(ut_setup, ut_teardown,
12912 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12937 TEST_CASES_END() /**< NULL terminate unit test array */
12941 static struct unit_test_suite cryptodev_armv8_testsuite = {
12942 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12943 .setup = testsuite_setup,
12944 .teardown = testsuite_teardown,
12945 .unit_test_cases = {
12946 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12948 /** Negative tests */
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12954 TEST_CASES_END() /**< NULL terminate unit test array */
12958 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12959 .suite_name = "Crypto Device Marvell Component Test Suite",
12960 .setup = testsuite_setup,
12961 .teardown = testsuite_teardown,
12962 .unit_test_cases = {
12963 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_multi_session_random_usage),
12966 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12967 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12968 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12969 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12970 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12972 /** Negative tests */
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12982 TEST_CASES_END() /**< NULL terminate unit test array */
12986 static struct unit_test_suite cryptodev_ccp_testsuite = {
12987 .suite_name = "Crypto Device CCP Unit Test Suite",
12988 .setup = testsuite_setup,
12989 .teardown = testsuite_teardown,
12990 .unit_test_cases = {
12991 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_multi_session_random_usage),
12994 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12995 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12996 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12997 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12998 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13000 /** Negative tests */
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13010 TEST_CASES_END() /**< NULL terminate unit test array */
13014 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13015 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13016 .setup = testsuite_setup,
13017 .teardown = testsuite_teardown,
13018 .unit_test_cases = {
13019 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13020 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13021 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13022 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13023 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13025 /** AES GCM Authenticated Encryption */
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_GCM_authenticated_encryption_test_case_1),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_AES_GCM_authenticated_encryption_test_case_2),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GCM_authenticated_encryption_test_case_3),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_authenticated_encryption_test_case_4),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GCM_authenticated_encryption_test_case_5),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_authenticated_encryption_test_case_6),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GCM_authenticated_encryption_test_case_7),
13041 /** AES GCM Authenticated Decryption */
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_authenticated_decryption_test_case_1),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GCM_authenticated_decryption_test_case_2),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_AES_GCM_authenticated_decryption_test_case_3),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_authenticated_decryption_test_case_4),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_decryption_test_case_5),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_decryption_test_case_6),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_decryption_test_case_7),
13056 /** AES GMAC Authentication */
13057 TEST_CASE_ST(ut_setup, ut_teardown,
13058 test_AES_GMAC_authentication_test_case_1),
13059 TEST_CASE_ST(ut_setup, ut_teardown,
13060 test_AES_GMAC_authentication_verify_test_case_1),
13061 TEST_CASE_ST(ut_setup, ut_teardown,
13062 test_AES_GMAC_authentication_test_case_2),
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_AES_GMAC_authentication_verify_test_case_2),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_AES_GMAC_authentication_test_case_3),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_AES_GMAC_authentication_verify_test_case_3),
13070 /** SNOW 3G encrypt only (UEA2) */
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_snow3g_encryption_test_case_1),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_snow3g_encryption_test_case_2),
13075 TEST_CASE_ST(ut_setup, ut_teardown,
13076 test_snow3g_encryption_test_case_3),
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_snow3g_encryption_test_case_4),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_encryption_test_case_5),
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_snow3g_encryption_test_case_1_oop),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_snow3g_decryption_test_case_1_oop),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_snow3g_encryption_test_case_1_oop_sgl),
13089 /** SNOW 3G decrypt only (UEA2) */
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_snow3g_decryption_test_case_1),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_snow3g_decryption_test_case_2),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_snow3g_decryption_test_case_3),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_snow3g_decryption_test_case_4),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_snow3g_decryption_test_case_5),
13101 TEST_CASE_ST(ut_setup, ut_teardown,
13102 test_snow3g_hash_generate_test_case_1),
13103 TEST_CASE_ST(ut_setup, ut_teardown,
13104 test_snow3g_hash_generate_test_case_2),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_snow3g_hash_generate_test_case_3),
13107 TEST_CASE_ST(ut_setup, ut_teardown,
13108 test_snow3g_hash_verify_test_case_1),
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_snow3g_hash_verify_test_case_2),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_snow3g_hash_verify_test_case_3),
13114 /** ZUC encrypt only (EEA3) */
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_zuc_encryption_test_case_1),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_zuc_encryption_test_case_2),
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 test_zuc_encryption_test_case_3),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_zuc_encryption_test_case_4),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_zuc_encryption_test_case_5),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_zuc_hash_generate_test_case_1),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_zuc_hash_generate_test_case_2),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_zuc_hash_generate_test_case_3),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_zuc_hash_generate_test_case_4),
13133 TEST_CASE_ST(ut_setup, ut_teardown,
13134 test_zuc_hash_generate_test_case_5),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_zuc_encryption_test_case_6_sgl),
13138 /** KASUMI encrypt only (UEA1) */
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_kasumi_encryption_test_case_1),
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_kasumi_encryption_test_case_2),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_kasumi_encryption_test_case_3),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_kasumi_encryption_test_case_4),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_kasumi_encryption_test_case_5),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_kasumi_encryption_test_case_1_sgl),
13151 TEST_CASE_ST(ut_setup, ut_teardown,
13152 test_kasumi_encryption_test_case_1_oop_sgl),
13153 /** KASUMI decrypt only (UEA1) */
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_kasumi_decryption_test_case_1),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_kasumi_decryption_test_case_2),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_kasumi_decryption_test_case_3),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_decryption_test_case_4),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_kasumi_decryption_test_case_5),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_kasumi_encryption_test_case_1_oop),
13167 TEST_CASE_ST(ut_setup, ut_teardown,
13168 test_kasumi_decryption_test_case_1_oop),
13170 /** KASUMI hash only (UIA1) */
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_kasumi_hash_generate_test_case_1),
13173 TEST_CASE_ST(ut_setup, ut_teardown,
13174 test_kasumi_hash_generate_test_case_2),
13175 TEST_CASE_ST(ut_setup, ut_teardown,
13176 test_kasumi_hash_generate_test_case_3),
13177 TEST_CASE_ST(ut_setup, ut_teardown,
13178 test_kasumi_hash_generate_test_case_4),
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 test_kasumi_hash_generate_test_case_5),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_kasumi_hash_generate_test_case_6),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_kasumi_hash_verify_test_case_1),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 test_kasumi_hash_verify_test_case_2),
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_kasumi_hash_verify_test_case_3),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_kasumi_hash_verify_test_case_4),
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_kasumi_hash_verify_test_case_5),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_null_cipher_only_operation),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_null_auth_only_operation),
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_null_cipher_auth_operation),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_null_auth_cipher_operation),
13204 /** Negative tests */
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 authentication_verify_AES128_GMAC_fail_data_corrupt),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13217 TEST_CASES_END() /**< NULL terminate unit test array */
13221 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13222 .suite_name = "Crypto NITROX Unit Test Suite",
13223 .setup = testsuite_setup,
13224 .teardown = testsuite_teardown,
13225 .unit_test_cases = {
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_device_configure_invalid_dev_id),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_device_configure_invalid_queue_pair_ids),
13230 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13231 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13233 TEST_CASES_END() /**< NULL terminate unit test array */
13237 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13238 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13239 .setup = testsuite_setup,
13240 .teardown = testsuite_teardown,
13241 .unit_test_cases = {
13242 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13243 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13244 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13245 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13246 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13248 /** AES GCM Authenticated Encryption */
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 test_AES_GCM_authenticated_encryption_test_case_1),
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_AES_GCM_authenticated_encryption_test_case_2),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_AES_GCM_authenticated_encryption_test_case_3),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_AES_GCM_authenticated_encryption_test_case_4),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_AES_GCM_authenticated_encryption_test_case_5),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_AES_GCM_authenticated_encryption_test_case_6),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_AES_GCM_authenticated_encryption_test_case_7),
13264 /** AES GCM Authenticated Decryption */
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_AES_GCM_authenticated_decryption_test_case_1),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_AES_GCM_authenticated_decryption_test_case_2),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_AES_GCM_authenticated_decryption_test_case_3),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_AES_GCM_authenticated_decryption_test_case_4),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_AES_GCM_authenticated_decryption_test_case_5),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_AES_GCM_authenticated_decryption_test_case_6),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_AES_GCM_authenticated_decryption_test_case_7),
13279 /** AES GMAC Authentication */
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_AES_GMAC_authentication_test_case_1),
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_AES_GMAC_authentication_verify_test_case_1),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_AES_GMAC_authentication_test_case_2),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_AES_GMAC_authentication_verify_test_case_2),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_AES_GMAC_authentication_test_case_3),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_AES_GMAC_authentication_verify_test_case_3),
13293 /** SNOW 3G encrypt only (UEA2) */
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_encryption_test_case_1),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_snow3g_encryption_test_case_2),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_snow3g_encryption_test_case_3),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_encryption_test_case_4),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_encryption_test_case_5),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_snow3g_encryption_test_case_1_oop),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_snow3g_decryption_test_case_1_oop),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_snow3g_encryption_test_case_1_oop_sgl),
13312 /** SNOW 3G decrypt only (UEA2) */
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_snow3g_decryption_test_case_1),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_snow3g_decryption_test_case_2),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_snow3g_decryption_test_case_3),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_snow3g_decryption_test_case_4),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_snow3g_decryption_test_case_5),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_snow3g_hash_generate_test_case_1),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_snow3g_hash_generate_test_case_2),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_snow3g_hash_generate_test_case_3),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_snow3g_hash_verify_test_case_1),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_snow3g_hash_verify_test_case_2),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_snow3g_hash_verify_test_case_3),
13337 /** ZUC encrypt only (EEA3) */
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_zuc_encryption_test_case_1),
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 test_zuc_encryption_test_case_2),
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_zuc_encryption_test_case_3),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_zuc_encryption_test_case_4),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_zuc_encryption_test_case_5),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_zuc_hash_generate_test_case_1),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_zuc_hash_generate_test_case_2),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_zuc_hash_generate_test_case_3),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_zuc_hash_generate_test_case_4),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_zuc_hash_generate_test_case_5),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_zuc_encryption_test_case_6_sgl),
13361 /** KASUMI encrypt only (UEA1) */
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_kasumi_encryption_test_case_1),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_kasumi_encryption_test_case_2),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_kasumi_encryption_test_case_3),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_kasumi_encryption_test_case_4),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_kasumi_encryption_test_case_5),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_encryption_test_case_1_sgl),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_kasumi_encryption_test_case_1_oop_sgl),
13376 /** KASUMI decrypt only (UEA1) */
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_kasumi_decryption_test_case_1),
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 test_kasumi_decryption_test_case_2),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_kasumi_decryption_test_case_3),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_kasumi_decryption_test_case_4),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_kasumi_decryption_test_case_5),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_kasumi_encryption_test_case_1_oop),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_kasumi_decryption_test_case_1_oop),
13393 /** KASUMI hash only (UIA1) */
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_kasumi_hash_generate_test_case_1),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_kasumi_hash_generate_test_case_2),
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_kasumi_hash_generate_test_case_3),
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_kasumi_hash_generate_test_case_4),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_kasumi_hash_generate_test_case_5),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_kasumi_hash_generate_test_case_6),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_kasumi_hash_verify_test_case_1),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_kasumi_hash_verify_test_case_2),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_kasumi_hash_verify_test_case_3),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_kasumi_hash_verify_test_case_4),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_kasumi_hash_verify_test_case_5),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_null_cipher_only_operation),
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_null_auth_only_operation),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_null_cipher_auth_operation),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_null_auth_cipher_operation),
13427 /** Negative tests */
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 authentication_verify_AES128_GMAC_fail_data_corrupt),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13440 TEST_CASES_END() /**< NULL terminate unit test array */
13445 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13447 gbl_driver_id = rte_cryptodev_driver_id_get(
13448 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13450 if (gbl_driver_id == -1) {
13451 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13452 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13453 "are enabled in config file to run this testsuite.\n");
13454 return TEST_SKIPPED;
13457 return unit_test_suite_runner(&cryptodev_testsuite);
13461 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13463 gbl_driver_id = rte_cryptodev_driver_id_get(
13464 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13466 if (gbl_driver_id == -1) {
13467 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13468 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13469 "in config file to run this testsuite.\n");
13470 return TEST_FAILED;
13473 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13477 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13479 gbl_driver_id = rte_cryptodev_driver_id_get(
13480 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13482 if (gbl_driver_id == -1) {
13483 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13484 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13485 "in config file to run this testsuite.\n");
13486 return TEST_SKIPPED;
13489 return unit_test_suite_runner(&cryptodev_testsuite);
13493 test_cryptodev_cpu_aesni_mb(void)
13496 enum rte_security_session_action_type at;
13498 gbl_driver_id = rte_cryptodev_driver_id_get(
13499 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13501 if (gbl_driver_id == -1) {
13502 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13503 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13504 "in config file to run this testsuite.\n");
13505 return TEST_SKIPPED;
13508 at = gbl_action_type;
13509 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13510 rc = unit_test_suite_runner(&cryptodev_testsuite);
13511 gbl_action_type = at;
13516 test_cryptodev_openssl(void)
13518 gbl_driver_id = rte_cryptodev_driver_id_get(
13519 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13521 if (gbl_driver_id == -1) {
13522 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13523 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13524 "in config file to run this testsuite.\n");
13525 return TEST_SKIPPED;
13528 return unit_test_suite_runner(&cryptodev_testsuite);
13532 test_cryptodev_aesni_gcm(void)
13534 gbl_driver_id = rte_cryptodev_driver_id_get(
13535 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13537 if (gbl_driver_id == -1) {
13538 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13539 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13540 "in config file to run this testsuite.\n");
13541 return TEST_SKIPPED;
13544 return unit_test_suite_runner(&cryptodev_testsuite);
13548 test_cryptodev_cpu_aesni_gcm(void)
13551 enum rte_security_session_action_type at;
13553 gbl_driver_id = rte_cryptodev_driver_id_get(
13554 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13556 if (gbl_driver_id == -1) {
13557 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13558 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13559 "in config file to run this testsuite.\n");
13560 return TEST_SKIPPED;
13563 at = gbl_action_type;
13564 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13565 rc = unit_test_suite_runner(&cryptodev_testsuite);
13566 gbl_action_type = at;
13571 test_cryptodev_null(void)
13573 gbl_driver_id = rte_cryptodev_driver_id_get(
13574 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13576 if (gbl_driver_id == -1) {
13577 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13578 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13579 "in config file to run this testsuite.\n");
13580 return TEST_SKIPPED;
13583 return unit_test_suite_runner(&cryptodev_testsuite);
13587 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13589 gbl_driver_id = rte_cryptodev_driver_id_get(
13590 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13592 if (gbl_driver_id == -1) {
13593 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13594 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13595 "in config file to run this testsuite.\n");
13596 return TEST_SKIPPED;
13599 return unit_test_suite_runner(&cryptodev_testsuite);
13603 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13605 gbl_driver_id = rte_cryptodev_driver_id_get(
13606 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13608 if (gbl_driver_id == -1) {
13609 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13610 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13611 "in config file to run this testsuite.\n");
13612 return TEST_SKIPPED;
13615 return unit_test_suite_runner(&cryptodev_testsuite);
13619 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13621 gbl_driver_id = rte_cryptodev_driver_id_get(
13622 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13624 if (gbl_driver_id == -1) {
13625 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13626 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13627 "in config file to run this testsuite.\n");
13628 return TEST_SKIPPED;
13631 return unit_test_suite_runner(&cryptodev_testsuite);
13635 test_cryptodev_armv8(void)
13637 gbl_driver_id = rte_cryptodev_driver_id_get(
13638 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13640 if (gbl_driver_id == -1) {
13641 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13642 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13643 "in config file to run this testsuite.\n");
13644 return TEST_SKIPPED;
13647 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13651 test_cryptodev_mrvl(void)
13653 gbl_driver_id = rte_cryptodev_driver_id_get(
13654 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13656 if (gbl_driver_id == -1) {
13657 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13658 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13659 "in config file to run this testsuite.\n");
13660 return TEST_SKIPPED;
13663 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13666 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13669 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13671 gbl_driver_id = rte_cryptodev_driver_id_get(
13672 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13674 if (gbl_driver_id == -1) {
13675 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13676 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13677 "in config file to run this testsuite.\n");
13678 return TEST_SKIPPED;
13681 if (rte_cryptodev_driver_id_get(
13682 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13683 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13684 " enabled in config file to run this testsuite.\n");
13685 return TEST_SKIPPED;
13687 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13690 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13695 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13697 gbl_driver_id = rte_cryptodev_driver_id_get(
13698 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13700 if (gbl_driver_id == -1) {
13701 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13702 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13703 "in config file to run this testsuite.\n");
13704 return TEST_SKIPPED;
13707 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13711 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13713 gbl_driver_id = rte_cryptodev_driver_id_get(
13714 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13716 if (gbl_driver_id == -1) {
13717 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13718 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13719 "in config file to run this testsuite.\n");
13720 return TEST_SKIPPED;
13723 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13727 test_cryptodev_ccp(void)
13729 gbl_driver_id = rte_cryptodev_driver_id_get(
13730 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13732 if (gbl_driver_id == -1) {
13733 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13734 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13735 "in config file to run this testsuite.\n");
13736 return TEST_FAILED;
13739 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13743 test_cryptodev_octeontx(void)
13745 gbl_driver_id = rte_cryptodev_driver_id_get(
13746 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13747 if (gbl_driver_id == -1) {
13748 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13749 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13750 "enabled in config file to run this "
13752 return TEST_FAILED;
13754 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13758 test_cryptodev_octeontx2(void)
13760 gbl_driver_id = rte_cryptodev_driver_id_get(
13761 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13762 if (gbl_driver_id == -1) {
13763 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13764 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13765 "enabled in config file to run this "
13767 return TEST_FAILED;
13769 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13773 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13775 gbl_driver_id = rte_cryptodev_driver_id_get(
13776 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13778 if (gbl_driver_id == -1) {
13779 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13780 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13781 "in config file to run this testsuite.\n");
13782 return TEST_FAILED;
13785 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13789 test_cryptodev_nitrox(void)
13791 gbl_driver_id = rte_cryptodev_driver_id_get(
13792 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13794 if (gbl_driver_id == -1) {
13795 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13796 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13797 "in config file to run this testsuite.\n");
13798 return TEST_FAILED;
13801 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13804 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13805 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13806 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13807 test_cryptodev_cpu_aesni_mb);
13808 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13809 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13810 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13811 test_cryptodev_cpu_aesni_gcm);
13812 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13813 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13814 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13815 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13816 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13817 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13818 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13819 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13820 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13821 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13822 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13823 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13824 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13825 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);