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;
2465 /* QAT PMD supports byte-aligned data only */
2466 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2467 (gbl_driver_id == rte_cryptodev_driver_id_get(
2468 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2471 /* Verify the capabilities */
2472 struct rte_cryptodev_sym_capability_idx cap_idx;
2473 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2474 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2479 /* Create SNOW 3G session */
2480 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2481 tdata->key.data, tdata->key.len,
2482 tdata->auth_iv.len, tdata->digest.len,
2483 RTE_CRYPTO_AUTH_OP_GENERATE,
2484 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2488 /* alloc mbuf and set payload */
2489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2491 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2492 rte_pktmbuf_tailroom(ut_params->ibuf));
2494 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2495 /* Append data which is padded to a multiple of */
2496 /* the algorithms block size */
2497 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2498 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2500 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2502 /* Create SNOW 3G operation */
2503 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2504 tdata->auth_iv.data, tdata->auth_iv.len,
2505 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2506 tdata->validAuthLenInBits.len,
2511 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2513 ut_params->obuf = ut_params->op->sym->m_src;
2514 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2515 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2516 + plaintext_pad_len;
2519 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2522 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2523 "SNOW 3G Generated auth tag not as expected");
2529 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2531 struct crypto_testsuite_params *ts_params = &testsuite_params;
2532 struct crypto_unittest_params *ut_params = &unittest_params;
2535 unsigned plaintext_pad_len;
2536 unsigned plaintext_len;
2539 /* QAT PMD supports byte-aligned data only */
2540 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2541 (gbl_driver_id == rte_cryptodev_driver_id_get(
2542 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2545 /* Verify the capabilities */
2546 struct rte_cryptodev_sym_capability_idx cap_idx;
2547 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2548 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2549 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2553 /* Create SNOW 3G session */
2554 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2555 tdata->key.data, tdata->key.len,
2556 tdata->auth_iv.len, tdata->digest.len,
2557 RTE_CRYPTO_AUTH_OP_VERIFY,
2558 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2561 /* alloc mbuf and set payload */
2562 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2564 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2565 rte_pktmbuf_tailroom(ut_params->ibuf));
2567 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2568 /* Append data which is padded to a multiple of */
2569 /* the algorithms block size */
2570 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2571 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2573 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2575 /* Create SNOW 3G operation */
2576 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2578 tdata->auth_iv.data, tdata->auth_iv.len,
2580 RTE_CRYPTO_AUTH_OP_VERIFY,
2581 tdata->validAuthLenInBits.len,
2586 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2588 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2589 ut_params->obuf = ut_params->op->sym->m_src;
2590 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2591 + plaintext_pad_len;
2594 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2603 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2605 struct crypto_testsuite_params *ts_params = &testsuite_params;
2606 struct crypto_unittest_params *ut_params = &unittest_params;
2609 unsigned plaintext_pad_len;
2610 unsigned plaintext_len;
2613 /* Verify the capabilities */
2614 struct rte_cryptodev_sym_capability_idx cap_idx;
2615 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2616 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2617 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2621 /* Create KASUMI session */
2622 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2623 tdata->key.data, tdata->key.len,
2624 0, tdata->digest.len,
2625 RTE_CRYPTO_AUTH_OP_GENERATE,
2626 RTE_CRYPTO_AUTH_KASUMI_F9);
2630 /* alloc mbuf and set payload */
2631 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2633 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2634 rte_pktmbuf_tailroom(ut_params->ibuf));
2636 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2637 /* Append data which is padded to a multiple of */
2638 /* the algorithms block size */
2639 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2640 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2642 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2644 /* Create KASUMI operation */
2645 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2647 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2648 tdata->plaintext.len,
2653 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2654 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2657 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2660 ut_params->obuf = ut_params->op->sym->m_src;
2661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2662 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2663 + plaintext_pad_len;
2666 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2669 DIGEST_BYTE_LENGTH_KASUMI_F9,
2670 "KASUMI Generated auth tag not as expected");
2676 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2678 struct crypto_testsuite_params *ts_params = &testsuite_params;
2679 struct crypto_unittest_params *ut_params = &unittest_params;
2682 unsigned plaintext_pad_len;
2683 unsigned plaintext_len;
2686 /* Verify the capabilities */
2687 struct rte_cryptodev_sym_capability_idx cap_idx;
2688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2689 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2694 /* Create KASUMI session */
2695 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2696 tdata->key.data, tdata->key.len,
2697 0, tdata->digest.len,
2698 RTE_CRYPTO_AUTH_OP_VERIFY,
2699 RTE_CRYPTO_AUTH_KASUMI_F9);
2702 /* alloc mbuf and set payload */
2703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2706 rte_pktmbuf_tailroom(ut_params->ibuf));
2708 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2709 /* Append data which is padded to a multiple */
2710 /* of the algorithms block size */
2711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2712 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2714 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2716 /* Create KASUMI operation */
2717 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2721 RTE_CRYPTO_AUTH_OP_VERIFY,
2722 tdata->plaintext.len,
2727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2729 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2730 ut_params->obuf = ut_params->op->sym->m_src;
2731 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2732 + plaintext_pad_len;
2735 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2744 test_snow3g_hash_generate_test_case_1(void)
2746 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2750 test_snow3g_hash_generate_test_case_2(void)
2752 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2756 test_snow3g_hash_generate_test_case_3(void)
2758 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2762 test_snow3g_hash_generate_test_case_4(void)
2764 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2768 test_snow3g_hash_generate_test_case_5(void)
2770 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2774 test_snow3g_hash_generate_test_case_6(void)
2776 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2780 test_snow3g_hash_verify_test_case_1(void)
2782 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2787 test_snow3g_hash_verify_test_case_2(void)
2789 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2793 test_snow3g_hash_verify_test_case_3(void)
2795 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2799 test_snow3g_hash_verify_test_case_4(void)
2801 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2805 test_snow3g_hash_verify_test_case_5(void)
2807 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2811 test_snow3g_hash_verify_test_case_6(void)
2813 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2817 test_kasumi_hash_generate_test_case_1(void)
2819 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2823 test_kasumi_hash_generate_test_case_2(void)
2825 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2829 test_kasumi_hash_generate_test_case_3(void)
2831 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2835 test_kasumi_hash_generate_test_case_4(void)
2837 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2841 test_kasumi_hash_generate_test_case_5(void)
2843 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2847 test_kasumi_hash_generate_test_case_6(void)
2849 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2853 test_kasumi_hash_verify_test_case_1(void)
2855 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2859 test_kasumi_hash_verify_test_case_2(void)
2861 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2865 test_kasumi_hash_verify_test_case_3(void)
2867 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2871 test_kasumi_hash_verify_test_case_4(void)
2873 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2877 test_kasumi_hash_verify_test_case_5(void)
2879 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2883 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2885 struct crypto_testsuite_params *ts_params = &testsuite_params;
2886 struct crypto_unittest_params *ut_params = &unittest_params;
2889 uint8_t *plaintext, *ciphertext;
2890 unsigned plaintext_pad_len;
2891 unsigned plaintext_len;
2893 /* Verify the capabilities */
2894 struct rte_cryptodev_sym_capability_idx cap_idx;
2895 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2896 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2897 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2901 /* Create KASUMI session */
2902 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2903 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2904 RTE_CRYPTO_CIPHER_KASUMI_F8,
2905 tdata->key.data, tdata->key.len,
2906 tdata->cipher_iv.len);
2910 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2912 /* Clear mbuf payload */
2913 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2914 rte_pktmbuf_tailroom(ut_params->ibuf));
2916 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2917 /* Append data which is padded to a multiple */
2918 /* of the algorithms block size */
2919 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2920 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2922 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2924 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2926 /* Create KASUMI operation */
2927 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2928 tdata->cipher_iv.len,
2929 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2930 tdata->validCipherOffsetInBits.len);
2934 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2936 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2938 ut_params->obuf = ut_params->op->sym->m_dst;
2939 if (ut_params->obuf)
2940 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2942 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2944 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2946 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2947 (tdata->validCipherOffsetInBits.len >> 3);
2949 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2951 reference_ciphertext,
2952 tdata->validCipherLenInBits.len,
2953 "KASUMI Ciphertext data not as expected");
2958 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2960 struct crypto_testsuite_params *ts_params = &testsuite_params;
2961 struct crypto_unittest_params *ut_params = &unittest_params;
2965 unsigned int plaintext_pad_len;
2966 unsigned int plaintext_len;
2968 uint8_t buffer[10000];
2969 const uint8_t *ciphertext;
2971 struct rte_cryptodev_info dev_info;
2973 /* Verify the capabilities */
2974 struct rte_cryptodev_sym_capability_idx cap_idx;
2975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2976 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2981 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2983 uint64_t feat_flags = dev_info.feature_flags;
2985 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2986 printf("Device doesn't support in-place scatter-gather. "
2991 /* Create KASUMI session */
2992 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2993 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2994 RTE_CRYPTO_CIPHER_KASUMI_F8,
2995 tdata->key.data, tdata->key.len,
2996 tdata->cipher_iv.len);
3000 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3003 /* Append data which is padded to a multiple */
3004 /* of the algorithms block size */
3005 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3007 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3008 plaintext_pad_len, 10, 0);
3010 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3012 /* Create KASUMI operation */
3013 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3014 tdata->cipher_iv.len,
3015 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3016 tdata->validCipherOffsetInBits.len);
3020 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3022 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3024 ut_params->obuf = ut_params->op->sym->m_dst;
3026 if (ut_params->obuf)
3027 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3028 plaintext_len, buffer);
3030 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3031 tdata->validCipherOffsetInBits.len >> 3,
3032 plaintext_len, buffer);
3035 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3037 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3038 (tdata->validCipherOffsetInBits.len >> 3);
3040 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3042 reference_ciphertext,
3043 tdata->validCipherLenInBits.len,
3044 "KASUMI Ciphertext data not as expected");
3049 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3051 struct crypto_testsuite_params *ts_params = &testsuite_params;
3052 struct crypto_unittest_params *ut_params = &unittest_params;
3055 uint8_t *plaintext, *ciphertext;
3056 unsigned plaintext_pad_len;
3057 unsigned plaintext_len;
3059 /* Verify the capabilities */
3060 struct rte_cryptodev_sym_capability_idx cap_idx;
3061 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3062 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3063 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3067 /* Create KASUMI session */
3068 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3069 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3070 RTE_CRYPTO_CIPHER_KASUMI_F8,
3071 tdata->key.data, tdata->key.len,
3072 tdata->cipher_iv.len);
3076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3077 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3079 /* Clear mbuf payload */
3080 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3081 rte_pktmbuf_tailroom(ut_params->ibuf));
3083 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3084 /* Append data which is padded to a multiple */
3085 /* of the algorithms block size */
3086 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3087 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3089 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3090 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3092 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3094 /* Create KASUMI operation */
3095 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3096 tdata->cipher_iv.len,
3097 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3098 tdata->validCipherOffsetInBits.len);
3102 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3104 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3106 ut_params->obuf = ut_params->op->sym->m_dst;
3107 if (ut_params->obuf)
3108 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3110 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3112 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3114 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3115 (tdata->validCipherOffsetInBits.len >> 3);
3117 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3119 reference_ciphertext,
3120 tdata->validCipherLenInBits.len,
3121 "KASUMI Ciphertext data not as expected");
3126 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3128 struct crypto_testsuite_params *ts_params = &testsuite_params;
3129 struct crypto_unittest_params *ut_params = &unittest_params;
3132 unsigned int plaintext_pad_len;
3133 unsigned int plaintext_len;
3135 const uint8_t *ciphertext;
3136 uint8_t buffer[2048];
3138 struct rte_cryptodev_info dev_info;
3140 /* Verify the capabilities */
3141 struct rte_cryptodev_sym_capability_idx cap_idx;
3142 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3143 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3144 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3148 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3150 uint64_t feat_flags = dev_info.feature_flags;
3151 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3152 printf("Device doesn't support out-of-place scatter-gather "
3153 "in both input and output mbufs. "
3158 /* Create KASUMI session */
3159 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3160 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3161 RTE_CRYPTO_CIPHER_KASUMI_F8,
3162 tdata->key.data, tdata->key.len,
3163 tdata->cipher_iv.len);
3167 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3168 /* Append data which is padded to a multiple */
3169 /* of the algorithms block size */
3170 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3172 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3173 plaintext_pad_len, 10, 0);
3174 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3175 plaintext_pad_len, 3, 0);
3177 /* Append data which is padded to a multiple */
3178 /* of the algorithms block size */
3179 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3181 /* Create KASUMI operation */
3182 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3183 tdata->cipher_iv.len,
3184 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3185 tdata->validCipherOffsetInBits.len);
3189 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3193 ut_params->obuf = ut_params->op->sym->m_dst;
3194 if (ut_params->obuf)
3195 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3196 plaintext_pad_len, buffer);
3198 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3199 tdata->validCipherOffsetInBits.len >> 3,
3200 plaintext_pad_len, buffer);
3202 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3203 (tdata->validCipherOffsetInBits.len >> 3);
3205 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3207 reference_ciphertext,
3208 tdata->validCipherLenInBits.len,
3209 "KASUMI Ciphertext data not as expected");
3215 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3217 struct crypto_testsuite_params *ts_params = &testsuite_params;
3218 struct crypto_unittest_params *ut_params = &unittest_params;
3221 uint8_t *ciphertext, *plaintext;
3222 unsigned ciphertext_pad_len;
3223 unsigned ciphertext_len;
3225 /* Verify the capabilities */
3226 struct rte_cryptodev_sym_capability_idx cap_idx;
3227 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3228 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3229 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3233 /* Create KASUMI session */
3234 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3235 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3236 RTE_CRYPTO_CIPHER_KASUMI_F8,
3237 tdata->key.data, tdata->key.len,
3238 tdata->cipher_iv.len);
3242 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3243 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3245 /* Clear mbuf payload */
3246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3247 rte_pktmbuf_tailroom(ut_params->ibuf));
3249 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3250 /* Append data which is padded to a multiple */
3251 /* of the algorithms block size */
3252 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3253 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3254 ciphertext_pad_len);
3255 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3256 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3258 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3260 /* Create KASUMI operation */
3261 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3262 tdata->cipher_iv.len,
3263 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3264 tdata->validCipherOffsetInBits.len);
3268 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3270 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3272 ut_params->obuf = ut_params->op->sym->m_dst;
3273 if (ut_params->obuf)
3274 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3276 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3278 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3280 const uint8_t *reference_plaintext = tdata->plaintext.data +
3281 (tdata->validCipherOffsetInBits.len >> 3);
3283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3285 reference_plaintext,
3286 tdata->validCipherLenInBits.len,
3287 "KASUMI Plaintext data not as expected");
3292 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3294 struct crypto_testsuite_params *ts_params = &testsuite_params;
3295 struct crypto_unittest_params *ut_params = &unittest_params;
3298 uint8_t *ciphertext, *plaintext;
3299 unsigned ciphertext_pad_len;
3300 unsigned ciphertext_len;
3302 /* Verify the capabilities */
3303 struct rte_cryptodev_sym_capability_idx cap_idx;
3304 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3305 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3306 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3310 /* Create KASUMI session */
3311 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3312 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3313 RTE_CRYPTO_CIPHER_KASUMI_F8,
3314 tdata->key.data, tdata->key.len,
3315 tdata->cipher_iv.len);
3319 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3321 /* Clear mbuf payload */
3322 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3323 rte_pktmbuf_tailroom(ut_params->ibuf));
3325 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3326 /* Append data which is padded to a multiple */
3327 /* of the algorithms block size */
3328 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3329 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3330 ciphertext_pad_len);
3331 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3333 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3335 /* Create KASUMI operation */
3336 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3337 tdata->cipher_iv.len,
3338 tdata->ciphertext.len,
3339 tdata->validCipherOffsetInBits.len);
3343 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3345 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3347 ut_params->obuf = ut_params->op->sym->m_dst;
3348 if (ut_params->obuf)
3349 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3351 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3353 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3355 const uint8_t *reference_plaintext = tdata->plaintext.data +
3356 (tdata->validCipherOffsetInBits.len >> 3);
3358 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3360 reference_plaintext,
3361 tdata->validCipherLenInBits.len,
3362 "KASUMI Plaintext data not as expected");
3367 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3369 struct crypto_testsuite_params *ts_params = &testsuite_params;
3370 struct crypto_unittest_params *ut_params = &unittest_params;
3373 uint8_t *plaintext, *ciphertext;
3374 unsigned plaintext_pad_len;
3375 unsigned plaintext_len;
3377 /* Verify the capabilities */
3378 struct rte_cryptodev_sym_capability_idx cap_idx;
3379 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3380 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3381 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3385 /* Create SNOW 3G session */
3386 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3387 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3388 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3389 tdata->key.data, tdata->key.len,
3390 tdata->cipher_iv.len);
3394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3396 /* Clear mbuf payload */
3397 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3398 rte_pktmbuf_tailroom(ut_params->ibuf));
3400 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3401 /* Append data which is padded to a multiple of */
3402 /* the algorithms block size */
3403 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3404 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3406 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3408 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3410 /* Create SNOW 3G operation */
3411 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3412 tdata->cipher_iv.len,
3413 tdata->validCipherLenInBits.len,
3418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3422 ut_params->obuf = ut_params->op->sym->m_dst;
3423 if (ut_params->obuf)
3424 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3426 ciphertext = plaintext;
3428 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3431 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3433 tdata->ciphertext.data,
3434 tdata->validDataLenInBits.len,
3435 "SNOW 3G Ciphertext data not as expected");
3441 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3443 struct crypto_testsuite_params *ts_params = &testsuite_params;
3444 struct crypto_unittest_params *ut_params = &unittest_params;
3445 uint8_t *plaintext, *ciphertext;
3448 unsigned plaintext_pad_len;
3449 unsigned plaintext_len;
3451 /* Verify the capabilities */
3452 struct rte_cryptodev_sym_capability_idx cap_idx;
3453 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3454 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3459 /* Create SNOW 3G session */
3460 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3461 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3462 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3463 tdata->key.data, tdata->key.len,
3464 tdata->cipher_iv.len);
3468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3469 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3471 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3472 "Failed to allocate input buffer in mempool");
3473 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3474 "Failed to allocate output buffer in mempool");
3476 /* Clear mbuf payload */
3477 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3478 rte_pktmbuf_tailroom(ut_params->ibuf));
3480 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3481 /* Append data which is padded to a multiple of */
3482 /* the algorithms block size */
3483 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3484 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3486 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3489 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3491 /* Create SNOW 3G operation */
3492 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3493 tdata->cipher_iv.len,
3494 tdata->validCipherLenInBits.len,
3499 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3503 ut_params->obuf = ut_params->op->sym->m_dst;
3504 if (ut_params->obuf)
3505 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3507 ciphertext = plaintext;
3509 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3512 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3514 tdata->ciphertext.data,
3515 tdata->validDataLenInBits.len,
3516 "SNOW 3G Ciphertext data not as expected");
3521 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3523 struct crypto_testsuite_params *ts_params = &testsuite_params;
3524 struct crypto_unittest_params *ut_params = &unittest_params;
3527 unsigned int plaintext_pad_len;
3528 unsigned int plaintext_len;
3529 uint8_t buffer[10000];
3530 const uint8_t *ciphertext;
3532 struct rte_cryptodev_info dev_info;
3534 /* Verify the capabilities */
3535 struct rte_cryptodev_sym_capability_idx cap_idx;
3536 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3537 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3538 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3542 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3544 uint64_t feat_flags = dev_info.feature_flags;
3546 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3547 printf("Device doesn't support out-of-place scatter-gather "
3548 "in both input and output mbufs. "
3553 /* Create SNOW 3G session */
3554 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3555 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3556 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3557 tdata->key.data, tdata->key.len,
3558 tdata->cipher_iv.len);
3562 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3563 /* Append data which is padded to a multiple of */
3564 /* the algorithms block size */
3565 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3567 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3568 plaintext_pad_len, 10, 0);
3569 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3570 plaintext_pad_len, 3, 0);
3572 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3573 "Failed to allocate input buffer in mempool");
3574 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3575 "Failed to allocate output buffer in mempool");
3577 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3579 /* Create SNOW 3G operation */
3580 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3581 tdata->cipher_iv.len,
3582 tdata->validCipherLenInBits.len,
3587 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3589 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3591 ut_params->obuf = ut_params->op->sym->m_dst;
3592 if (ut_params->obuf)
3593 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3594 plaintext_len, buffer);
3596 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3597 plaintext_len, buffer);
3599 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3602 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3604 tdata->ciphertext.data,
3605 tdata->validDataLenInBits.len,
3606 "SNOW 3G Ciphertext data not as expected");
3611 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3613 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3615 uint8_t curr_byte, prev_byte;
3616 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3617 uint8_t lower_byte_mask = (1 << offset) - 1;
3620 prev_byte = buffer[0];
3621 buffer[0] >>= offset;
3623 for (i = 1; i < length_in_bytes; i++) {
3624 curr_byte = buffer[i];
3625 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3626 (curr_byte >> offset);
3627 prev_byte = curr_byte;
3632 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3634 struct crypto_testsuite_params *ts_params = &testsuite_params;
3635 struct crypto_unittest_params *ut_params = &unittest_params;
3636 uint8_t *plaintext, *ciphertext;
3638 uint32_t plaintext_len;
3639 uint32_t plaintext_pad_len;
3640 uint8_t extra_offset = 4;
3641 uint8_t *expected_ciphertext_shifted;
3643 /* QAT PMD supports byte-aligned data only */
3644 if (gbl_driver_id == rte_cryptodev_driver_id_get(
3645 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
3648 /* Verify the capabilities */
3649 struct rte_cryptodev_sym_capability_idx cap_idx;
3650 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3651 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3652 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3656 /* Create SNOW 3G session */
3657 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3658 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3659 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3660 tdata->key.data, tdata->key.len,
3661 tdata->cipher_iv.len);
3665 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3666 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3668 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3669 "Failed to allocate input buffer in mempool");
3670 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3671 "Failed to allocate output buffer in mempool");
3673 /* Clear mbuf payload */
3674 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3675 rte_pktmbuf_tailroom(ut_params->ibuf));
3677 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3679 * Append data which is padded to a
3680 * multiple of the algorithms block size
3682 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3684 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3687 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3689 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3690 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3692 #ifdef RTE_APP_TEST_DEBUG
3693 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3695 /* Create SNOW 3G operation */
3696 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3697 tdata->cipher_iv.len,
3698 tdata->validCipherLenInBits.len,
3703 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3705 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3707 ut_params->obuf = ut_params->op->sym->m_dst;
3708 if (ut_params->obuf)
3709 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3711 ciphertext = plaintext;
3713 #ifdef RTE_APP_TEST_DEBUG
3714 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3717 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3719 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3720 "failed to reserve memory for ciphertext shifted\n");
3722 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3723 ceil_byte_length(tdata->ciphertext.len));
3724 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3727 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3729 expected_ciphertext_shifted,
3730 tdata->validDataLenInBits.len,
3732 "SNOW 3G Ciphertext data not as expected");
3736 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3738 struct crypto_testsuite_params *ts_params = &testsuite_params;
3739 struct crypto_unittest_params *ut_params = &unittest_params;
3743 uint8_t *plaintext, *ciphertext;
3744 unsigned ciphertext_pad_len;
3745 unsigned ciphertext_len;
3747 /* Verify the capabilities */
3748 struct rte_cryptodev_sym_capability_idx cap_idx;
3749 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3750 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3751 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3755 /* Create SNOW 3G session */
3756 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3757 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3758 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3759 tdata->key.data, tdata->key.len,
3760 tdata->cipher_iv.len);
3764 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3766 /* Clear mbuf payload */
3767 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3768 rte_pktmbuf_tailroom(ut_params->ibuf));
3770 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3771 /* Append data which is padded to a multiple of */
3772 /* the algorithms block size */
3773 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3774 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3775 ciphertext_pad_len);
3776 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3778 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3780 /* Create SNOW 3G operation */
3781 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3782 tdata->cipher_iv.len,
3783 tdata->validCipherLenInBits.len,
3784 tdata->cipher.offset_bits);
3788 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3790 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3791 ut_params->obuf = ut_params->op->sym->m_dst;
3792 if (ut_params->obuf)
3793 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3795 plaintext = ciphertext;
3797 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3800 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3801 tdata->plaintext.data,
3802 tdata->validDataLenInBits.len,
3803 "SNOW 3G Plaintext data not as expected");
3807 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3809 struct crypto_testsuite_params *ts_params = &testsuite_params;
3810 struct crypto_unittest_params *ut_params = &unittest_params;
3814 uint8_t *plaintext, *ciphertext;
3815 unsigned ciphertext_pad_len;
3816 unsigned ciphertext_len;
3818 /* Verify the capabilities */
3819 struct rte_cryptodev_sym_capability_idx cap_idx;
3820 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3821 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3822 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3826 /* Create SNOW 3G session */
3827 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3828 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3829 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3830 tdata->key.data, tdata->key.len,
3831 tdata->cipher_iv.len);
3835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3836 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3838 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3839 "Failed to allocate input buffer");
3840 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3841 "Failed to allocate output buffer");
3843 /* Clear mbuf payload */
3844 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3845 rte_pktmbuf_tailroom(ut_params->ibuf));
3847 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3848 rte_pktmbuf_tailroom(ut_params->obuf));
3850 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3851 /* Append data which is padded to a multiple of */
3852 /* the algorithms block size */
3853 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3854 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3855 ciphertext_pad_len);
3856 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3857 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3859 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3861 /* Create SNOW 3G operation */
3862 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3863 tdata->cipher_iv.len,
3864 tdata->validCipherLenInBits.len,
3869 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3871 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3872 ut_params->obuf = ut_params->op->sym->m_dst;
3873 if (ut_params->obuf)
3874 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3876 plaintext = ciphertext;
3878 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3881 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3882 tdata->plaintext.data,
3883 tdata->validDataLenInBits.len,
3884 "SNOW 3G Plaintext data not as expected");
3889 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3891 struct crypto_testsuite_params *ts_params = &testsuite_params;
3892 struct crypto_unittest_params *ut_params = &unittest_params;
3896 uint8_t *plaintext, *ciphertext;
3897 unsigned int plaintext_pad_len;
3898 unsigned int plaintext_len;
3900 struct rte_cryptodev_sym_capability_idx cap_idx;
3902 /* Check if device supports ZUC EEA3 */
3903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3904 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3906 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3910 /* Check if device supports ZUC EIA3 */
3911 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3912 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3914 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3918 /* Create ZUC session */
3919 retval = create_zuc_cipher_auth_encrypt_generate_session(
3920 ts_params->valid_devs[0],
3924 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3926 /* clear mbuf payload */
3927 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3928 rte_pktmbuf_tailroom(ut_params->ibuf));
3930 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3931 /* Append data which is padded to a multiple of */
3932 /* the algorithms block size */
3933 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3934 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3936 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3938 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3940 /* Create ZUC operation */
3941 retval = create_zuc_cipher_hash_generate_operation(tdata);
3945 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3948 ut_params->obuf = ut_params->op->sym->m_src;
3949 if (ut_params->obuf)
3950 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3952 ciphertext = plaintext;
3954 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3956 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3958 tdata->ciphertext.data,
3959 tdata->validDataLenInBits.len,
3960 "ZUC Ciphertext data not as expected");
3962 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3963 + plaintext_pad_len;
3966 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3970 "ZUC Generated auth tag not as expected");
3975 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3977 struct crypto_testsuite_params *ts_params = &testsuite_params;
3978 struct crypto_unittest_params *ut_params = &unittest_params;
3982 uint8_t *plaintext, *ciphertext;
3983 unsigned plaintext_pad_len;
3984 unsigned plaintext_len;
3986 /* Verify the capabilities */
3987 struct rte_cryptodev_sym_capability_idx cap_idx;
3988 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3989 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3990 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3993 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3994 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3995 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3999 /* Create SNOW 3G session */
4000 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4002 RTE_CRYPTO_AUTH_OP_GENERATE,
4003 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4004 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4005 tdata->key.data, tdata->key.len,
4006 tdata->auth_iv.len, tdata->digest.len,
4007 tdata->cipher_iv.len);
4010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4012 /* clear mbuf payload */
4013 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4014 rte_pktmbuf_tailroom(ut_params->ibuf));
4016 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4017 /* Append data which is padded to a multiple of */
4018 /* the algorithms block size */
4019 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4020 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4022 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4024 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4026 /* Create SNOW 3G operation */
4027 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4028 tdata->digest.len, tdata->auth_iv.data,
4030 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4031 tdata->cipher_iv.data, tdata->cipher_iv.len,
4032 tdata->validCipherLenInBits.len,
4034 tdata->validAuthLenInBits.len,
4040 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4042 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4043 ut_params->obuf = ut_params->op->sym->m_src;
4044 if (ut_params->obuf)
4045 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4047 ciphertext = plaintext;
4049 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4051 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4053 tdata->ciphertext.data,
4054 tdata->validDataLenInBits.len,
4055 "SNOW 3G Ciphertext data not as expected");
4057 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4058 + plaintext_pad_len;
4061 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4064 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4065 "SNOW 3G Generated auth tag not as expected");
4070 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4071 uint8_t op_mode, uint8_t verify)
4073 struct crypto_testsuite_params *ts_params = &testsuite_params;
4074 struct crypto_unittest_params *ut_params = &unittest_params;
4078 uint8_t *plaintext = NULL, *ciphertext = NULL;
4079 unsigned int plaintext_pad_len;
4080 unsigned int plaintext_len;
4081 unsigned int ciphertext_pad_len;
4082 unsigned int ciphertext_len;
4084 struct rte_cryptodev_info dev_info;
4086 /* Verify the capabilities */
4087 struct rte_cryptodev_sym_capability_idx cap_idx;
4088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4089 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4090 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4093 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4094 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4095 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4099 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4101 uint64_t feat_flags = dev_info.feature_flags;
4103 if (op_mode == OUT_OF_PLACE) {
4104 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4105 printf("Device doesn't support digest encrypted.\n");
4110 /* Create SNOW 3G session */
4111 retval = create_wireless_algo_auth_cipher_session(
4112 ts_params->valid_devs[0],
4113 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4114 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4115 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4116 : RTE_CRYPTO_AUTH_OP_GENERATE),
4117 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4118 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4119 tdata->key.data, tdata->key.len,
4120 tdata->auth_iv.len, tdata->digest.len,
4121 tdata->cipher_iv.len);
4126 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4127 if (op_mode == OUT_OF_PLACE)
4128 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4130 /* clear mbuf payload */
4131 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4132 rte_pktmbuf_tailroom(ut_params->ibuf));
4133 if (op_mode == OUT_OF_PLACE)
4134 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4135 rte_pktmbuf_tailroom(ut_params->obuf));
4137 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4138 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4139 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4140 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4143 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4144 ciphertext_pad_len);
4145 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4146 if (op_mode == OUT_OF_PLACE)
4147 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4148 debug_hexdump(stdout, "ciphertext:", ciphertext,
4151 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4153 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4154 if (op_mode == OUT_OF_PLACE)
4155 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4156 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4159 /* Create SNOW 3G operation */
4160 retval = create_wireless_algo_auth_cipher_operation(
4161 tdata->digest.data, tdata->digest.len,
4162 tdata->cipher_iv.data, tdata->cipher_iv.len,
4163 tdata->auth_iv.data, tdata->auth_iv.len,
4164 (tdata->digest.offset_bytes == 0 ?
4165 (verify ? ciphertext_pad_len : plaintext_pad_len)
4166 : tdata->digest.offset_bytes),
4167 tdata->validCipherLenInBits.len,
4168 tdata->cipher.offset_bits,
4169 tdata->validAuthLenInBits.len,
4170 tdata->auth.offset_bits,
4171 op_mode, 0, verify);
4176 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4179 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4181 ut_params->obuf = (op_mode == IN_PLACE ?
4182 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4185 if (ut_params->obuf)
4186 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4189 plaintext = ciphertext +
4190 (tdata->cipher.offset_bits >> 3);
4192 debug_hexdump(stdout, "plaintext:", plaintext,
4193 (tdata->plaintext.len >> 3) - tdata->digest.len);
4194 debug_hexdump(stdout, "plaintext expected:",
4195 tdata->plaintext.data,
4196 (tdata->plaintext.len >> 3) - tdata->digest.len);
4198 if (ut_params->obuf)
4199 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4202 ciphertext = plaintext;
4204 debug_hexdump(stdout, "ciphertext:", ciphertext,
4206 debug_hexdump(stdout, "ciphertext expected:",
4207 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4209 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4210 + (tdata->digest.offset_bytes == 0 ?
4211 plaintext_pad_len : tdata->digest.offset_bytes);
4213 debug_hexdump(stdout, "digest:", ut_params->digest,
4215 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4223 tdata->plaintext.data,
4224 tdata->plaintext.len >> 3,
4225 "SNOW 3G Plaintext data not as expected");
4227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4229 tdata->ciphertext.data,
4230 tdata->validDataLenInBits.len,
4231 "SNOW 3G Ciphertext data not as expected");
4233 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4236 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4237 "SNOW 3G Generated auth tag not as expected");
4243 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4244 uint8_t op_mode, uint8_t verify)
4246 struct crypto_testsuite_params *ts_params = &testsuite_params;
4247 struct crypto_unittest_params *ut_params = &unittest_params;
4251 const uint8_t *plaintext = NULL;
4252 const uint8_t *ciphertext = NULL;
4253 const uint8_t *digest = NULL;
4254 unsigned int plaintext_pad_len;
4255 unsigned int plaintext_len;
4256 unsigned int ciphertext_pad_len;
4257 unsigned int ciphertext_len;
4258 uint8_t buffer[10000];
4259 uint8_t digest_buffer[10000];
4261 struct rte_cryptodev_info dev_info;
4263 /* Verify the capabilities */
4264 struct rte_cryptodev_sym_capability_idx cap_idx;
4265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4266 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4270 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4271 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4272 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4276 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4278 uint64_t feat_flags = dev_info.feature_flags;
4280 if (op_mode == IN_PLACE) {
4281 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4282 printf("Device doesn't support in-place scatter-gather "
4283 "in both input and output mbufs.\n");
4287 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4288 printf("Device doesn't support out-of-place scatter-gather "
4289 "in both input and output mbufs.\n");
4292 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4293 printf("Device doesn't support digest encrypted.\n");
4298 /* Create SNOW 3G session */
4299 retval = create_wireless_algo_auth_cipher_session(
4300 ts_params->valid_devs[0],
4301 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4302 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4303 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4304 : RTE_CRYPTO_AUTH_OP_GENERATE),
4305 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4306 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4307 tdata->key.data, tdata->key.len,
4308 tdata->auth_iv.len, tdata->digest.len,
4309 tdata->cipher_iv.len);
4314 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4315 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4316 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4317 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4319 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4320 plaintext_pad_len, 15, 0);
4321 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4322 "Failed to allocate input buffer in mempool");
4324 if (op_mode == OUT_OF_PLACE) {
4325 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4326 plaintext_pad_len, 15, 0);
4327 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4328 "Failed to allocate output buffer in mempool");
4332 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4333 tdata->ciphertext.data);
4334 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4335 ciphertext_len, buffer);
4336 debug_hexdump(stdout, "ciphertext:", ciphertext,
4339 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4340 tdata->plaintext.data);
4341 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4342 plaintext_len, buffer);
4343 debug_hexdump(stdout, "plaintext:", plaintext,
4346 memset(buffer, 0, sizeof(buffer));
4348 /* Create SNOW 3G operation */
4349 retval = create_wireless_algo_auth_cipher_operation(
4350 tdata->digest.data, tdata->digest.len,
4351 tdata->cipher_iv.data, tdata->cipher_iv.len,
4352 tdata->auth_iv.data, tdata->auth_iv.len,
4353 (tdata->digest.offset_bytes == 0 ?
4354 (verify ? ciphertext_pad_len : plaintext_pad_len)
4355 : tdata->digest.offset_bytes),
4356 tdata->validCipherLenInBits.len,
4357 tdata->cipher.offset_bits,
4358 tdata->validAuthLenInBits.len,
4359 tdata->auth.offset_bits,
4360 op_mode, 1, verify);
4365 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4368 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4370 ut_params->obuf = (op_mode == IN_PLACE ?
4371 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4374 if (ut_params->obuf)
4375 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4376 plaintext_len, buffer);
4378 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4379 plaintext_len, buffer);
4381 debug_hexdump(stdout, "plaintext:", plaintext,
4382 (tdata->plaintext.len >> 3) - tdata->digest.len);
4383 debug_hexdump(stdout, "plaintext expected:",
4384 tdata->plaintext.data,
4385 (tdata->plaintext.len >> 3) - tdata->digest.len);
4387 if (ut_params->obuf)
4388 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4389 ciphertext_len, buffer);
4391 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4392 ciphertext_len, buffer);
4394 debug_hexdump(stdout, "ciphertext:", ciphertext,
4396 debug_hexdump(stdout, "ciphertext expected:",
4397 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4399 if (ut_params->obuf)
4400 digest = rte_pktmbuf_read(ut_params->obuf,
4401 (tdata->digest.offset_bytes == 0 ?
4402 plaintext_pad_len : tdata->digest.offset_bytes),
4403 tdata->digest.len, digest_buffer);
4405 digest = rte_pktmbuf_read(ut_params->ibuf,
4406 (tdata->digest.offset_bytes == 0 ?
4407 plaintext_pad_len : tdata->digest.offset_bytes),
4408 tdata->digest.len, digest_buffer);
4410 debug_hexdump(stdout, "digest:", digest,
4412 debug_hexdump(stdout, "digest expected:",
4413 tdata->digest.data, tdata->digest.len);
4418 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4420 tdata->plaintext.data,
4421 tdata->plaintext.len >> 3,
4422 "SNOW 3G Plaintext data not as expected");
4424 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4426 tdata->ciphertext.data,
4427 tdata->validDataLenInBits.len,
4428 "SNOW 3G Ciphertext data not as expected");
4430 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4433 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4434 "SNOW 3G Generated auth tag not as expected");
4440 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4441 uint8_t op_mode, uint8_t verify)
4443 struct crypto_testsuite_params *ts_params = &testsuite_params;
4444 struct crypto_unittest_params *ut_params = &unittest_params;
4448 uint8_t *plaintext = NULL, *ciphertext = NULL;
4449 unsigned int plaintext_pad_len;
4450 unsigned int plaintext_len;
4451 unsigned int ciphertext_pad_len;
4452 unsigned int ciphertext_len;
4454 struct rte_cryptodev_info dev_info;
4456 /* Verify the capabilities */
4457 struct rte_cryptodev_sym_capability_idx cap_idx;
4458 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4459 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4460 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4464 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4471 uint64_t feat_flags = dev_info.feature_flags;
4473 if (op_mode == OUT_OF_PLACE) {
4474 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4475 printf("Device doesn't support digest encrypted.\n");
4480 /* Create KASUMI session */
4481 retval = create_wireless_algo_auth_cipher_session(
4482 ts_params->valid_devs[0],
4483 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4484 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4485 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4486 : RTE_CRYPTO_AUTH_OP_GENERATE),
4487 RTE_CRYPTO_AUTH_KASUMI_F9,
4488 RTE_CRYPTO_CIPHER_KASUMI_F8,
4489 tdata->key.data, tdata->key.len,
4490 0, tdata->digest.len,
4491 tdata->cipher_iv.len);
4496 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4497 if (op_mode == OUT_OF_PLACE)
4498 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4500 /* clear mbuf payload */
4501 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4502 rte_pktmbuf_tailroom(ut_params->ibuf));
4503 if (op_mode == OUT_OF_PLACE)
4504 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4505 rte_pktmbuf_tailroom(ut_params->obuf));
4507 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4508 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4509 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4510 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4513 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4514 ciphertext_pad_len);
4515 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4516 if (op_mode == OUT_OF_PLACE)
4517 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4518 debug_hexdump(stdout, "ciphertext:", ciphertext,
4521 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4523 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4524 if (op_mode == OUT_OF_PLACE)
4525 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4526 debug_hexdump(stdout, "plaintext:", plaintext,
4530 /* Create KASUMI operation */
4531 retval = create_wireless_algo_auth_cipher_operation(
4532 tdata->digest.data, tdata->digest.len,
4533 tdata->cipher_iv.data, tdata->cipher_iv.len,
4535 (tdata->digest.offset_bytes == 0 ?
4536 (verify ? ciphertext_pad_len : plaintext_pad_len)
4537 : tdata->digest.offset_bytes),
4538 tdata->validCipherLenInBits.len,
4539 tdata->validCipherOffsetInBits.len,
4540 tdata->validAuthLenInBits.len,
4542 op_mode, 0, verify);
4547 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4550 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4552 ut_params->obuf = (op_mode == IN_PLACE ?
4553 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4557 if (ut_params->obuf)
4558 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4561 plaintext = ciphertext;
4563 debug_hexdump(stdout, "plaintext:", plaintext,
4564 (tdata->plaintext.len >> 3) - tdata->digest.len);
4565 debug_hexdump(stdout, "plaintext expected:",
4566 tdata->plaintext.data,
4567 (tdata->plaintext.len >> 3) - tdata->digest.len);
4569 if (ut_params->obuf)
4570 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4573 ciphertext = plaintext;
4575 debug_hexdump(stdout, "ciphertext:", ciphertext,
4577 debug_hexdump(stdout, "ciphertext expected:",
4578 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4580 ut_params->digest = rte_pktmbuf_mtod(
4581 ut_params->obuf, uint8_t *) +
4582 (tdata->digest.offset_bytes == 0 ?
4583 plaintext_pad_len : tdata->digest.offset_bytes);
4585 debug_hexdump(stdout, "digest:", ut_params->digest,
4587 debug_hexdump(stdout, "digest expected:",
4588 tdata->digest.data, tdata->digest.len);
4593 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4595 tdata->plaintext.data,
4596 tdata->plaintext.len >> 3,
4597 "KASUMI Plaintext data not as expected");
4599 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4601 tdata->ciphertext.data,
4602 tdata->ciphertext.len >> 3,
4603 "KASUMI Ciphertext data not as expected");
4605 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4608 DIGEST_BYTE_LENGTH_KASUMI_F9,
4609 "KASUMI Generated auth tag not as expected");
4615 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4616 uint8_t op_mode, uint8_t verify)
4618 struct crypto_testsuite_params *ts_params = &testsuite_params;
4619 struct crypto_unittest_params *ut_params = &unittest_params;
4623 const uint8_t *plaintext = NULL;
4624 const uint8_t *ciphertext = NULL;
4625 const uint8_t *digest = NULL;
4626 unsigned int plaintext_pad_len;
4627 unsigned int plaintext_len;
4628 unsigned int ciphertext_pad_len;
4629 unsigned int ciphertext_len;
4630 uint8_t buffer[10000];
4631 uint8_t digest_buffer[10000];
4633 struct rte_cryptodev_info dev_info;
4635 /* Verify the capabilities */
4636 struct rte_cryptodev_sym_capability_idx cap_idx;
4637 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4638 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4639 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4642 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4643 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4644 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4648 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4650 uint64_t feat_flags = dev_info.feature_flags;
4652 if (op_mode == IN_PLACE) {
4653 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4654 printf("Device doesn't support in-place scatter-gather "
4655 "in both input and output mbufs.\n");
4659 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4660 printf("Device doesn't support out-of-place scatter-gather "
4661 "in both input and output mbufs.\n");
4664 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4665 printf("Device doesn't support digest encrypted.\n");
4670 /* Create KASUMI session */
4671 retval = create_wireless_algo_auth_cipher_session(
4672 ts_params->valid_devs[0],
4673 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4674 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4675 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4676 : RTE_CRYPTO_AUTH_OP_GENERATE),
4677 RTE_CRYPTO_AUTH_KASUMI_F9,
4678 RTE_CRYPTO_CIPHER_KASUMI_F8,
4679 tdata->key.data, tdata->key.len,
4680 0, tdata->digest.len,
4681 tdata->cipher_iv.len);
4686 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4687 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4688 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4689 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4691 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4692 plaintext_pad_len, 15, 0);
4693 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4694 "Failed to allocate input buffer in mempool");
4696 if (op_mode == OUT_OF_PLACE) {
4697 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4698 plaintext_pad_len, 15, 0);
4699 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4700 "Failed to allocate output buffer in mempool");
4704 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4705 tdata->ciphertext.data);
4706 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4707 ciphertext_len, buffer);
4708 debug_hexdump(stdout, "ciphertext:", ciphertext,
4711 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4712 tdata->plaintext.data);
4713 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4714 plaintext_len, buffer);
4715 debug_hexdump(stdout, "plaintext:", plaintext,
4718 memset(buffer, 0, sizeof(buffer));
4720 /* Create KASUMI operation */
4721 retval = create_wireless_algo_auth_cipher_operation(
4722 tdata->digest.data, tdata->digest.len,
4723 tdata->cipher_iv.data, tdata->cipher_iv.len,
4725 (tdata->digest.offset_bytes == 0 ?
4726 (verify ? ciphertext_pad_len : plaintext_pad_len)
4727 : tdata->digest.offset_bytes),
4728 tdata->validCipherLenInBits.len,
4729 tdata->validCipherOffsetInBits.len,
4730 tdata->validAuthLenInBits.len,
4732 op_mode, 1, verify);
4737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4740 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4742 ut_params->obuf = (op_mode == IN_PLACE ?
4743 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4746 if (ut_params->obuf)
4747 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4748 plaintext_len, buffer);
4750 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4751 plaintext_len, buffer);
4753 debug_hexdump(stdout, "plaintext:", plaintext,
4754 (tdata->plaintext.len >> 3) - tdata->digest.len);
4755 debug_hexdump(stdout, "plaintext expected:",
4756 tdata->plaintext.data,
4757 (tdata->plaintext.len >> 3) - tdata->digest.len);
4759 if (ut_params->obuf)
4760 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4761 ciphertext_len, buffer);
4763 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4764 ciphertext_len, buffer);
4766 debug_hexdump(stdout, "ciphertext:", ciphertext,
4768 debug_hexdump(stdout, "ciphertext expected:",
4769 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4771 if (ut_params->obuf)
4772 digest = rte_pktmbuf_read(ut_params->obuf,
4773 (tdata->digest.offset_bytes == 0 ?
4774 plaintext_pad_len : tdata->digest.offset_bytes),
4775 tdata->digest.len, digest_buffer);
4777 digest = rte_pktmbuf_read(ut_params->ibuf,
4778 (tdata->digest.offset_bytes == 0 ?
4779 plaintext_pad_len : tdata->digest.offset_bytes),
4780 tdata->digest.len, digest_buffer);
4782 debug_hexdump(stdout, "digest:", digest,
4784 debug_hexdump(stdout, "digest expected:",
4785 tdata->digest.data, tdata->digest.len);
4790 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4792 tdata->plaintext.data,
4793 tdata->plaintext.len >> 3,
4794 "KASUMI Plaintext data not as expected");
4796 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4798 tdata->ciphertext.data,
4799 tdata->validDataLenInBits.len,
4800 "KASUMI Ciphertext data not as expected");
4802 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4805 DIGEST_BYTE_LENGTH_KASUMI_F9,
4806 "KASUMI Generated auth tag not as expected");
4812 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4814 struct crypto_testsuite_params *ts_params = &testsuite_params;
4815 struct crypto_unittest_params *ut_params = &unittest_params;
4819 uint8_t *plaintext, *ciphertext;
4820 unsigned plaintext_pad_len;
4821 unsigned plaintext_len;
4823 /* Verify the capabilities */
4824 struct rte_cryptodev_sym_capability_idx cap_idx;
4825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4826 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4830 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4831 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4832 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4836 /* Create KASUMI session */
4837 retval = create_wireless_algo_cipher_auth_session(
4838 ts_params->valid_devs[0],
4839 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4840 RTE_CRYPTO_AUTH_OP_GENERATE,
4841 RTE_CRYPTO_AUTH_KASUMI_F9,
4842 RTE_CRYPTO_CIPHER_KASUMI_F8,
4843 tdata->key.data, tdata->key.len,
4844 0, tdata->digest.len,
4845 tdata->cipher_iv.len);
4849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4851 /* clear mbuf payload */
4852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4853 rte_pktmbuf_tailroom(ut_params->ibuf));
4855 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4856 /* Append data which is padded to a multiple of */
4857 /* the algorithms block size */
4858 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4859 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4861 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4863 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4865 /* Create KASUMI operation */
4866 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4867 tdata->digest.len, NULL, 0,
4868 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4869 tdata->cipher_iv.data, tdata->cipher_iv.len,
4870 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4871 tdata->validCipherOffsetInBits.len,
4872 tdata->validAuthLenInBits.len,
4878 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4880 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4882 if (ut_params->op->sym->m_dst)
4883 ut_params->obuf = ut_params->op->sym->m_dst;
4885 ut_params->obuf = ut_params->op->sym->m_src;
4887 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4888 tdata->validCipherOffsetInBits.len >> 3);
4890 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4891 + plaintext_pad_len;
4893 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4894 (tdata->validCipherOffsetInBits.len >> 3);
4896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4898 reference_ciphertext,
4899 tdata->validCipherLenInBits.len,
4900 "KASUMI Ciphertext data not as expected");
4903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4906 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4907 "KASUMI Generated auth tag not as expected");
4912 test_zuc_encryption(const struct wireless_test_data *tdata)
4914 struct crypto_testsuite_params *ts_params = &testsuite_params;
4915 struct crypto_unittest_params *ut_params = &unittest_params;
4918 uint8_t *plaintext, *ciphertext;
4919 unsigned plaintext_pad_len;
4920 unsigned plaintext_len;
4922 struct rte_cryptodev_sym_capability_idx cap_idx;
4924 /* Check if device supports ZUC EEA3 */
4925 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4926 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4928 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4932 /* Create ZUC session */
4933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4934 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4935 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4936 tdata->key.data, tdata->key.len,
4937 tdata->cipher_iv.len);
4941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4943 /* Clear mbuf payload */
4944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4945 rte_pktmbuf_tailroom(ut_params->ibuf));
4947 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4948 /* Append data which is padded to a multiple */
4949 /* of the algorithms block size */
4950 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4951 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4953 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4955 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4957 /* Create ZUC operation */
4958 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4959 tdata->cipher_iv.len,
4960 tdata->plaintext.len,
4965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4969 ut_params->obuf = ut_params->op->sym->m_dst;
4970 if (ut_params->obuf)
4971 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4973 ciphertext = plaintext;
4975 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4978 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4980 tdata->ciphertext.data,
4981 tdata->validCipherLenInBits.len,
4982 "ZUC Ciphertext data not as expected");
4987 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4989 struct crypto_testsuite_params *ts_params = &testsuite_params;
4990 struct crypto_unittest_params *ut_params = &unittest_params;
4994 unsigned int plaintext_pad_len;
4995 unsigned int plaintext_len;
4996 const uint8_t *ciphertext;
4997 uint8_t ciphertext_buffer[2048];
4998 struct rte_cryptodev_info dev_info;
5000 struct rte_cryptodev_sym_capability_idx cap_idx;
5002 /* Check if device supports ZUC EEA3 */
5003 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5004 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5006 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5010 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5012 uint64_t feat_flags = dev_info.feature_flags;
5014 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5015 printf("Device doesn't support in-place scatter-gather. "
5020 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5022 /* Append data which is padded to a multiple */
5023 /* of the algorithms block size */
5024 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5026 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5027 plaintext_pad_len, 10, 0);
5029 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5030 tdata->plaintext.data);
5032 /* Create ZUC session */
5033 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5034 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5035 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5036 tdata->key.data, tdata->key.len,
5037 tdata->cipher_iv.len);
5041 /* Clear mbuf payload */
5043 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5045 /* Create ZUC operation */
5046 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5047 tdata->cipher_iv.len, tdata->plaintext.len,
5052 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5054 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5056 ut_params->obuf = ut_params->op->sym->m_dst;
5057 if (ut_params->obuf)
5058 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5059 0, plaintext_len, ciphertext_buffer);
5061 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5062 0, plaintext_len, ciphertext_buffer);
5065 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5068 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5070 tdata->ciphertext.data,
5071 tdata->validCipherLenInBits.len,
5072 "ZUC Ciphertext data not as expected");
5078 test_zuc_authentication(const struct wireless_test_data *tdata)
5080 struct crypto_testsuite_params *ts_params = &testsuite_params;
5081 struct crypto_unittest_params *ut_params = &unittest_params;
5084 unsigned plaintext_pad_len;
5085 unsigned plaintext_len;
5088 struct rte_cryptodev_sym_capability_idx cap_idx;
5090 /* QAT PMD supports byte-aligned data only */
5091 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
5092 (gbl_driver_id == rte_cryptodev_driver_id_get(
5093 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
5096 /* Check if device supports ZUC EIA3 */
5097 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5098 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5100 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5104 /* Create ZUC session */
5105 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5106 tdata->key.data, tdata->key.len,
5107 tdata->auth_iv.len, tdata->digest.len,
5108 RTE_CRYPTO_AUTH_OP_GENERATE,
5109 RTE_CRYPTO_AUTH_ZUC_EIA3);
5113 /* alloc mbuf and set payload */
5114 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5116 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5117 rte_pktmbuf_tailroom(ut_params->ibuf));
5119 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5120 /* Append data which is padded to a multiple of */
5121 /* the algorithms block size */
5122 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5123 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5125 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5127 /* Create ZUC operation */
5128 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5129 tdata->auth_iv.data, tdata->auth_iv.len,
5130 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5131 tdata->validAuthLenInBits.len,
5136 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5138 ut_params->obuf = ut_params->op->sym->m_src;
5139 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5140 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5141 + plaintext_pad_len;
5144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5148 "ZUC Generated auth tag not as expected");
5154 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5155 uint8_t op_mode, uint8_t verify)
5157 struct crypto_testsuite_params *ts_params = &testsuite_params;
5158 struct crypto_unittest_params *ut_params = &unittest_params;
5162 uint8_t *plaintext = NULL, *ciphertext = NULL;
5163 unsigned int plaintext_pad_len;
5164 unsigned int plaintext_len;
5165 unsigned int ciphertext_pad_len;
5166 unsigned int ciphertext_len;
5168 struct rte_cryptodev_info dev_info;
5169 struct rte_cryptodev_sym_capability_idx cap_idx;
5171 /* Check if device supports ZUC EIA3 */
5172 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5173 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5175 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5179 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5181 uint64_t feat_flags = dev_info.feature_flags;
5183 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5184 printf("Device doesn't support digest encrypted.\n");
5188 /* Create ZUC session */
5189 retval = create_wireless_algo_auth_cipher_session(
5190 ts_params->valid_devs[0],
5191 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5192 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5193 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5194 : RTE_CRYPTO_AUTH_OP_GENERATE),
5195 RTE_CRYPTO_AUTH_ZUC_EIA3,
5196 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5197 tdata->key.data, tdata->key.len,
5198 tdata->auth_iv.len, tdata->digest.len,
5199 tdata->cipher_iv.len);
5204 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5205 if (op_mode == OUT_OF_PLACE)
5206 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5208 /* clear mbuf payload */
5209 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5210 rte_pktmbuf_tailroom(ut_params->ibuf));
5211 if (op_mode == OUT_OF_PLACE)
5212 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5213 rte_pktmbuf_tailroom(ut_params->obuf));
5215 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5216 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5217 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5218 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5221 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5222 ciphertext_pad_len);
5223 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5224 if (op_mode == OUT_OF_PLACE)
5225 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5226 debug_hexdump(stdout, "ciphertext:", ciphertext,
5229 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5231 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5232 if (op_mode == OUT_OF_PLACE)
5233 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5234 debug_hexdump(stdout, "plaintext:", plaintext,
5238 /* Create ZUC operation */
5239 retval = create_wireless_algo_auth_cipher_operation(
5240 tdata->digest.data, tdata->digest.len,
5241 tdata->cipher_iv.data, tdata->cipher_iv.len,
5242 tdata->auth_iv.data, tdata->auth_iv.len,
5243 (tdata->digest.offset_bytes == 0 ?
5244 (verify ? ciphertext_pad_len : plaintext_pad_len)
5245 : tdata->digest.offset_bytes),
5246 tdata->validCipherLenInBits.len,
5247 tdata->validCipherOffsetInBits.len,
5248 tdata->validAuthLenInBits.len,
5250 op_mode, 0, verify);
5255 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5258 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5260 ut_params->obuf = (op_mode == IN_PLACE ?
5261 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5265 if (ut_params->obuf)
5266 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5269 plaintext = ciphertext;
5271 debug_hexdump(stdout, "plaintext:", plaintext,
5272 (tdata->plaintext.len >> 3) - tdata->digest.len);
5273 debug_hexdump(stdout, "plaintext expected:",
5274 tdata->plaintext.data,
5275 (tdata->plaintext.len >> 3) - tdata->digest.len);
5277 if (ut_params->obuf)
5278 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5281 ciphertext = plaintext;
5283 debug_hexdump(stdout, "ciphertext:", ciphertext,
5285 debug_hexdump(stdout, "ciphertext expected:",
5286 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5288 ut_params->digest = rte_pktmbuf_mtod(
5289 ut_params->obuf, uint8_t *) +
5290 (tdata->digest.offset_bytes == 0 ?
5291 plaintext_pad_len : tdata->digest.offset_bytes);
5293 debug_hexdump(stdout, "digest:", ut_params->digest,
5295 debug_hexdump(stdout, "digest expected:",
5296 tdata->digest.data, tdata->digest.len);
5301 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5303 tdata->plaintext.data,
5304 tdata->plaintext.len >> 3,
5305 "ZUC Plaintext data not as expected");
5307 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5309 tdata->ciphertext.data,
5310 tdata->ciphertext.len >> 3,
5311 "ZUC Ciphertext data not as expected");
5313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5316 DIGEST_BYTE_LENGTH_KASUMI_F9,
5317 "ZUC Generated auth tag not as expected");
5323 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5324 uint8_t op_mode, uint8_t verify)
5326 struct crypto_testsuite_params *ts_params = &testsuite_params;
5327 struct crypto_unittest_params *ut_params = &unittest_params;
5331 const uint8_t *plaintext = NULL;
5332 const uint8_t *ciphertext = NULL;
5333 const uint8_t *digest = NULL;
5334 unsigned int plaintext_pad_len;
5335 unsigned int plaintext_len;
5336 unsigned int ciphertext_pad_len;
5337 unsigned int ciphertext_len;
5338 uint8_t buffer[10000];
5339 uint8_t digest_buffer[10000];
5341 struct rte_cryptodev_info dev_info;
5342 struct rte_cryptodev_sym_capability_idx cap_idx;
5344 /* Check if device supports ZUC EIA3 */
5345 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5346 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5348 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5352 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5354 uint64_t feat_flags = dev_info.feature_flags;
5356 if (op_mode == IN_PLACE) {
5357 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5358 printf("Device doesn't support in-place scatter-gather "
5359 "in both input and output mbufs.\n");
5363 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5364 printf("Device doesn't support out-of-place scatter-gather "
5365 "in both input and output mbufs.\n");
5368 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5369 printf("Device doesn't support digest encrypted.\n");
5374 /* Create ZUC session */
5375 retval = create_wireless_algo_auth_cipher_session(
5376 ts_params->valid_devs[0],
5377 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5378 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5379 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5380 : RTE_CRYPTO_AUTH_OP_GENERATE),
5381 RTE_CRYPTO_AUTH_ZUC_EIA3,
5382 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5383 tdata->key.data, tdata->key.len,
5384 tdata->auth_iv.len, tdata->digest.len,
5385 tdata->cipher_iv.len);
5390 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5391 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5392 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5393 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5395 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5396 plaintext_pad_len, 15, 0);
5397 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5398 "Failed to allocate input buffer in mempool");
5400 if (op_mode == OUT_OF_PLACE) {
5401 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5402 plaintext_pad_len, 15, 0);
5403 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5404 "Failed to allocate output buffer in mempool");
5408 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5409 tdata->ciphertext.data);
5410 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5411 ciphertext_len, buffer);
5412 debug_hexdump(stdout, "ciphertext:", ciphertext,
5415 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5416 tdata->plaintext.data);
5417 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5418 plaintext_len, buffer);
5419 debug_hexdump(stdout, "plaintext:", plaintext,
5422 memset(buffer, 0, sizeof(buffer));
5424 /* Create ZUC operation */
5425 retval = create_wireless_algo_auth_cipher_operation(
5426 tdata->digest.data, tdata->digest.len,
5427 tdata->cipher_iv.data, tdata->cipher_iv.len,
5429 (tdata->digest.offset_bytes == 0 ?
5430 (verify ? ciphertext_pad_len : plaintext_pad_len)
5431 : tdata->digest.offset_bytes),
5432 tdata->validCipherLenInBits.len,
5433 tdata->validCipherOffsetInBits.len,
5434 tdata->validAuthLenInBits.len,
5436 op_mode, 1, verify);
5441 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5444 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5446 ut_params->obuf = (op_mode == IN_PLACE ?
5447 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5450 if (ut_params->obuf)
5451 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5452 plaintext_len, buffer);
5454 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5455 plaintext_len, buffer);
5457 debug_hexdump(stdout, "plaintext:", plaintext,
5458 (tdata->plaintext.len >> 3) - tdata->digest.len);
5459 debug_hexdump(stdout, "plaintext expected:",
5460 tdata->plaintext.data,
5461 (tdata->plaintext.len >> 3) - tdata->digest.len);
5463 if (ut_params->obuf)
5464 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5465 ciphertext_len, buffer);
5467 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5468 ciphertext_len, buffer);
5470 debug_hexdump(stdout, "ciphertext:", ciphertext,
5472 debug_hexdump(stdout, "ciphertext expected:",
5473 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5475 if (ut_params->obuf)
5476 digest = rte_pktmbuf_read(ut_params->obuf,
5477 (tdata->digest.offset_bytes == 0 ?
5478 plaintext_pad_len : tdata->digest.offset_bytes),
5479 tdata->digest.len, digest_buffer);
5481 digest = rte_pktmbuf_read(ut_params->ibuf,
5482 (tdata->digest.offset_bytes == 0 ?
5483 plaintext_pad_len : tdata->digest.offset_bytes),
5484 tdata->digest.len, digest_buffer);
5486 debug_hexdump(stdout, "digest:", digest,
5488 debug_hexdump(stdout, "digest expected:",
5489 tdata->digest.data, tdata->digest.len);
5494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5496 tdata->plaintext.data,
5497 tdata->plaintext.len >> 3,
5498 "ZUC Plaintext data not as expected");
5500 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5502 tdata->ciphertext.data,
5503 tdata->validDataLenInBits.len,
5504 "ZUC Ciphertext data not as expected");
5506 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5509 DIGEST_BYTE_LENGTH_KASUMI_F9,
5510 "ZUC Generated auth tag not as expected");
5516 test_kasumi_encryption_test_case_1(void)
5518 return test_kasumi_encryption(&kasumi_test_case_1);
5522 test_kasumi_encryption_test_case_1_sgl(void)
5524 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5528 test_kasumi_encryption_test_case_1_oop(void)
5530 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5534 test_kasumi_encryption_test_case_1_oop_sgl(void)
5536 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5540 test_kasumi_encryption_test_case_2(void)
5542 return test_kasumi_encryption(&kasumi_test_case_2);
5546 test_kasumi_encryption_test_case_3(void)
5548 return test_kasumi_encryption(&kasumi_test_case_3);
5552 test_kasumi_encryption_test_case_4(void)
5554 return test_kasumi_encryption(&kasumi_test_case_4);
5558 test_kasumi_encryption_test_case_5(void)
5560 return test_kasumi_encryption(&kasumi_test_case_5);
5564 test_kasumi_decryption_test_case_1(void)
5566 return test_kasumi_decryption(&kasumi_test_case_1);
5570 test_kasumi_decryption_test_case_1_oop(void)
5572 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5576 test_kasumi_decryption_test_case_2(void)
5578 return test_kasumi_decryption(&kasumi_test_case_2);
5582 test_kasumi_decryption_test_case_3(void)
5584 return test_kasumi_decryption(&kasumi_test_case_3);
5588 test_kasumi_decryption_test_case_4(void)
5590 return test_kasumi_decryption(&kasumi_test_case_4);
5594 test_kasumi_decryption_test_case_5(void)
5596 return test_kasumi_decryption(&kasumi_test_case_5);
5599 test_snow3g_encryption_test_case_1(void)
5601 return test_snow3g_encryption(&snow3g_test_case_1);
5605 test_snow3g_encryption_test_case_1_oop(void)
5607 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5611 test_snow3g_encryption_test_case_1_oop_sgl(void)
5613 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5618 test_snow3g_encryption_test_case_1_offset_oop(void)
5620 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5624 test_snow3g_encryption_test_case_2(void)
5626 return test_snow3g_encryption(&snow3g_test_case_2);
5630 test_snow3g_encryption_test_case_3(void)
5632 return test_snow3g_encryption(&snow3g_test_case_3);
5636 test_snow3g_encryption_test_case_4(void)
5638 return test_snow3g_encryption(&snow3g_test_case_4);
5642 test_snow3g_encryption_test_case_5(void)
5644 return test_snow3g_encryption(&snow3g_test_case_5);
5648 test_snow3g_decryption_test_case_1(void)
5650 return test_snow3g_decryption(&snow3g_test_case_1);
5654 test_snow3g_decryption_test_case_1_oop(void)
5656 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5660 test_snow3g_decryption_test_case_2(void)
5662 return test_snow3g_decryption(&snow3g_test_case_2);
5666 test_snow3g_decryption_test_case_3(void)
5668 return test_snow3g_decryption(&snow3g_test_case_3);
5672 test_snow3g_decryption_test_case_4(void)
5674 return test_snow3g_decryption(&snow3g_test_case_4);
5678 test_snow3g_decryption_test_case_5(void)
5680 return test_snow3g_decryption(&snow3g_test_case_5);
5684 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5685 * Pattern digest from snow3g_test_data must be allocated as
5686 * 4 last bytes in plaintext.
5689 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5690 struct snow3g_hash_test_data *output)
5692 if ((pattern != NULL) && (output != NULL)) {
5693 output->key.len = pattern->key.len;
5695 memcpy(output->key.data,
5696 pattern->key.data, pattern->key.len);
5698 output->auth_iv.len = pattern->auth_iv.len;
5700 memcpy(output->auth_iv.data,
5701 pattern->auth_iv.data, pattern->auth_iv.len);
5703 output->plaintext.len = pattern->plaintext.len;
5705 memcpy(output->plaintext.data,
5706 pattern->plaintext.data, pattern->plaintext.len >> 3);
5708 output->digest.len = pattern->digest.len;
5710 memcpy(output->digest.data,
5711 &pattern->plaintext.data[pattern->digest.offset_bytes],
5712 pattern->digest.len);
5714 output->validAuthLenInBits.len =
5715 pattern->validAuthLenInBits.len;
5720 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5723 test_snow3g_decryption_with_digest_test_case_1(void)
5725 struct snow3g_hash_test_data snow3g_hash_data;
5728 * Function prepare data for hash veryfication test case.
5729 * Digest is allocated in 4 last bytes in plaintext, pattern.
5731 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5733 return test_snow3g_decryption(&snow3g_test_case_7) &
5734 test_snow3g_authentication_verify(&snow3g_hash_data);
5738 test_snow3g_cipher_auth_test_case_1(void)
5740 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5744 test_snow3g_auth_cipher_test_case_1(void)
5746 return test_snow3g_auth_cipher(
5747 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5751 test_snow3g_auth_cipher_test_case_2(void)
5753 return test_snow3g_auth_cipher(
5754 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5758 test_snow3g_auth_cipher_test_case_2_oop(void)
5760 return test_snow3g_auth_cipher(
5761 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5765 test_snow3g_auth_cipher_part_digest_enc(void)
5767 return test_snow3g_auth_cipher(
5768 &snow3g_auth_cipher_partial_digest_encryption,
5773 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5775 return test_snow3g_auth_cipher(
5776 &snow3g_auth_cipher_partial_digest_encryption,
5781 test_snow3g_auth_cipher_test_case_3_sgl(void)
5783 return test_snow3g_auth_cipher_sgl(
5784 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5788 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5790 return test_snow3g_auth_cipher_sgl(
5791 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5795 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5797 return test_snow3g_auth_cipher_sgl(
5798 &snow3g_auth_cipher_partial_digest_encryption,
5803 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5805 return test_snow3g_auth_cipher_sgl(
5806 &snow3g_auth_cipher_partial_digest_encryption,
5811 test_snow3g_auth_cipher_verify_test_case_1(void)
5813 return test_snow3g_auth_cipher(
5814 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5818 test_snow3g_auth_cipher_verify_test_case_2(void)
5820 return test_snow3g_auth_cipher(
5821 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5825 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5827 return test_snow3g_auth_cipher(
5828 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5832 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5834 return test_snow3g_auth_cipher(
5835 &snow3g_auth_cipher_partial_digest_encryption,
5840 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5842 return test_snow3g_auth_cipher(
5843 &snow3g_auth_cipher_partial_digest_encryption,
5848 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5850 return test_snow3g_auth_cipher_sgl(
5851 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5855 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5857 return test_snow3g_auth_cipher_sgl(
5858 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5862 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5864 return test_snow3g_auth_cipher_sgl(
5865 &snow3g_auth_cipher_partial_digest_encryption,
5870 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5872 return test_snow3g_auth_cipher_sgl(
5873 &snow3g_auth_cipher_partial_digest_encryption,
5878 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5880 return test_snow3g_auth_cipher(
5881 &snow3g_test_case_7, IN_PLACE, 0);
5885 test_kasumi_auth_cipher_test_case_1(void)
5887 return test_kasumi_auth_cipher(
5888 &kasumi_test_case_3, IN_PLACE, 0);
5892 test_kasumi_auth_cipher_test_case_2(void)
5894 return test_kasumi_auth_cipher(
5895 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5899 test_kasumi_auth_cipher_test_case_2_oop(void)
5901 return test_kasumi_auth_cipher(
5902 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5906 test_kasumi_auth_cipher_test_case_2_sgl(void)
5908 return test_kasumi_auth_cipher_sgl(
5909 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5913 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5915 return test_kasumi_auth_cipher_sgl(
5916 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5920 test_kasumi_auth_cipher_verify_test_case_1(void)
5922 return test_kasumi_auth_cipher(
5923 &kasumi_test_case_3, IN_PLACE, 1);
5927 test_kasumi_auth_cipher_verify_test_case_2(void)
5929 return test_kasumi_auth_cipher(
5930 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5934 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5936 return test_kasumi_auth_cipher(
5937 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5941 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5943 return test_kasumi_auth_cipher_sgl(
5944 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5948 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5950 return test_kasumi_auth_cipher_sgl(
5951 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5955 test_kasumi_cipher_auth_test_case_1(void)
5957 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5961 test_zuc_encryption_test_case_1(void)
5963 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5967 test_zuc_encryption_test_case_2(void)
5969 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5973 test_zuc_encryption_test_case_3(void)
5975 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5979 test_zuc_encryption_test_case_4(void)
5981 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5985 test_zuc_encryption_test_case_5(void)
5987 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5991 test_zuc_encryption_test_case_6_sgl(void)
5993 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5997 test_zuc_hash_generate_test_case_1(void)
5999 return test_zuc_authentication(&zuc_test_case_auth_1b);
6003 test_zuc_hash_generate_test_case_2(void)
6005 return test_zuc_authentication(&zuc_test_case_auth_90b);
6009 test_zuc_hash_generate_test_case_3(void)
6011 return test_zuc_authentication(&zuc_test_case_auth_577b);
6015 test_zuc_hash_generate_test_case_4(void)
6017 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6021 test_zuc_hash_generate_test_case_5(void)
6023 return test_zuc_authentication(&zuc_test_auth_5670b);
6027 test_zuc_hash_generate_test_case_6(void)
6029 return test_zuc_authentication(&zuc_test_case_auth_128b);
6033 test_zuc_hash_generate_test_case_7(void)
6035 /* This test is not for SW ZUC PMD */
6036 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6037 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6040 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6044 test_zuc_hash_generate_test_case_8(void)
6046 return test_zuc_authentication(&zuc_test_case_auth_584b);
6050 test_zuc_cipher_auth_test_case_1(void)
6052 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6056 test_zuc_cipher_auth_test_case_2(void)
6058 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6062 test_zuc_auth_cipher_test_case_1(void)
6064 /* This test is not for SW ZUC PMD */
6065 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6066 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6069 return test_zuc_auth_cipher(
6070 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6074 test_zuc_auth_cipher_test_case_1_oop(void)
6076 return test_zuc_auth_cipher(
6077 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6081 test_zuc_auth_cipher_test_case_1_sgl(void)
6083 return test_zuc_auth_cipher_sgl(
6084 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6088 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6090 return test_zuc_auth_cipher_sgl(
6091 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6095 test_zuc_auth_cipher_verify_test_case_1(void)
6097 return test_zuc_auth_cipher(
6098 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6102 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6104 return test_zuc_auth_cipher(
6105 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6109 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6111 return test_zuc_auth_cipher_sgl(
6112 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6116 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6118 return test_zuc_auth_cipher_sgl(
6119 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6123 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6125 uint8_t dev_id = testsuite_params.valid_devs[0];
6127 struct rte_cryptodev_sym_capability_idx cap_idx;
6129 /* Check if device supports particular cipher algorithm */
6130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6131 cap_idx.algo.cipher = tdata->cipher_algo;
6132 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6135 /* Check if device supports particular hash algorithm */
6136 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6137 cap_idx.algo.auth = tdata->auth_algo;
6138 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6145 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6146 uint8_t op_mode, uint8_t verify)
6148 struct crypto_testsuite_params *ts_params = &testsuite_params;
6149 struct crypto_unittest_params *ut_params = &unittest_params;
6153 uint8_t *plaintext = NULL, *ciphertext = NULL;
6154 unsigned int plaintext_pad_len;
6155 unsigned int plaintext_len;
6156 unsigned int ciphertext_pad_len;
6157 unsigned int ciphertext_len;
6159 struct rte_cryptodev_info dev_info;
6160 struct rte_crypto_op *op;
6162 /* Check if device supports particular algorithms separately */
6163 if (test_mixed_check_if_unsupported(tdata))
6166 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6168 uint64_t feat_flags = dev_info.feature_flags;
6170 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6171 printf("Device doesn't support digest encrypted.\n");
6175 /* Create the session */
6177 retval = create_wireless_algo_cipher_auth_session(
6178 ts_params->valid_devs[0],
6179 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6180 RTE_CRYPTO_AUTH_OP_VERIFY,
6183 tdata->auth_key.data, tdata->auth_key.len,
6184 tdata->auth_iv.len, tdata->digest_enc.len,
6185 tdata->cipher_iv.len);
6187 retval = create_wireless_algo_auth_cipher_session(
6188 ts_params->valid_devs[0],
6189 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6190 RTE_CRYPTO_AUTH_OP_GENERATE,
6193 tdata->auth_key.data, tdata->auth_key.len,
6194 tdata->auth_iv.len, tdata->digest_enc.len,
6195 tdata->cipher_iv.len);
6199 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6200 if (op_mode == OUT_OF_PLACE)
6201 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6203 /* clear mbuf payload */
6204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6205 rte_pktmbuf_tailroom(ut_params->ibuf));
6206 if (op_mode == OUT_OF_PLACE)
6207 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6208 rte_pktmbuf_tailroom(ut_params->obuf));
6210 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6211 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6212 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6213 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6216 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6217 ciphertext_pad_len);
6218 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6219 if (op_mode == OUT_OF_PLACE)
6220 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6221 debug_hexdump(stdout, "ciphertext:", ciphertext,
6224 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6226 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6227 if (op_mode == OUT_OF_PLACE)
6228 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6229 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6232 /* Create the operation */
6233 retval = create_wireless_algo_auth_cipher_operation(
6234 tdata->digest_enc.data, tdata->digest_enc.len,
6235 tdata->cipher_iv.data, tdata->cipher_iv.len,
6236 tdata->auth_iv.data, tdata->auth_iv.len,
6237 (tdata->digest_enc.offset == 0 ?
6239 : tdata->digest_enc.offset),
6240 tdata->validCipherLen.len_bits,
6241 tdata->cipher.offset_bits,
6242 tdata->validAuthLen.len_bits,
6243 tdata->auth.offset_bits,
6244 op_mode, 0, verify);
6249 op = process_crypto_request(ts_params->valid_devs[0],
6252 /* Check if the op failed because the device doesn't */
6253 /* support this particular combination of algorithms */
6254 if (op == NULL && ut_params->op->status ==
6255 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6256 printf("Device doesn't support this mixed combination. "
6262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6264 ut_params->obuf = (op_mode == IN_PLACE ?
6265 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6268 if (ut_params->obuf)
6269 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6272 plaintext = ciphertext +
6273 (tdata->cipher.offset_bits >> 3);
6275 debug_hexdump(stdout, "plaintext:", plaintext,
6276 tdata->plaintext.len_bits >> 3);
6277 debug_hexdump(stdout, "plaintext expected:",
6278 tdata->plaintext.data,
6279 tdata->plaintext.len_bits >> 3);
6281 if (ut_params->obuf)
6282 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6285 ciphertext = plaintext;
6287 debug_hexdump(stdout, "ciphertext:", ciphertext,
6289 debug_hexdump(stdout, "ciphertext expected:",
6290 tdata->ciphertext.data,
6291 tdata->ciphertext.len_bits >> 3);
6293 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6294 + (tdata->digest_enc.offset == 0 ?
6295 plaintext_pad_len : tdata->digest_enc.offset);
6297 debug_hexdump(stdout, "digest:", ut_params->digest,
6298 tdata->digest_enc.len);
6299 debug_hexdump(stdout, "digest expected:",
6300 tdata->digest_enc.data,
6301 tdata->digest_enc.len);
6306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6308 tdata->plaintext.data,
6309 tdata->plaintext.len_bits >> 3,
6310 "Plaintext data not as expected");
6312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6314 tdata->ciphertext.data,
6315 tdata->validDataLen.len_bits,
6316 "Ciphertext data not as expected");
6318 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6320 tdata->digest_enc.data,
6321 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6322 "Generated auth tag not as expected");
6325 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6326 "crypto op processing failed");
6332 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6333 uint8_t op_mode, uint8_t verify)
6335 struct crypto_testsuite_params *ts_params = &testsuite_params;
6336 struct crypto_unittest_params *ut_params = &unittest_params;
6340 const uint8_t *plaintext = NULL;
6341 const uint8_t *ciphertext = NULL;
6342 const uint8_t *digest = NULL;
6343 unsigned int plaintext_pad_len;
6344 unsigned int plaintext_len;
6345 unsigned int ciphertext_pad_len;
6346 unsigned int ciphertext_len;
6347 uint8_t buffer[10000];
6348 uint8_t digest_buffer[10000];
6350 struct rte_cryptodev_info dev_info;
6351 struct rte_crypto_op *op;
6353 /* Check if device supports particular algorithms */
6354 if (test_mixed_check_if_unsupported(tdata))
6357 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6359 uint64_t feat_flags = dev_info.feature_flags;
6361 if (op_mode == IN_PLACE) {
6362 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6363 printf("Device doesn't support in-place scatter-gather "
6364 "in both input and output mbufs.\n");
6368 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6369 printf("Device doesn't support out-of-place scatter-gather "
6370 "in both input and output mbufs.\n");
6373 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6374 printf("Device doesn't support digest encrypted.\n");
6379 /* Create the session */
6381 retval = create_wireless_algo_cipher_auth_session(
6382 ts_params->valid_devs[0],
6383 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6384 RTE_CRYPTO_AUTH_OP_VERIFY,
6387 tdata->auth_key.data, tdata->auth_key.len,
6388 tdata->auth_iv.len, tdata->digest_enc.len,
6389 tdata->cipher_iv.len);
6391 retval = create_wireless_algo_auth_cipher_session(
6392 ts_params->valid_devs[0],
6393 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6394 RTE_CRYPTO_AUTH_OP_GENERATE,
6397 tdata->auth_key.data, tdata->auth_key.len,
6398 tdata->auth_iv.len, tdata->digest_enc.len,
6399 tdata->cipher_iv.len);
6403 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6404 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6405 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6406 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6408 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6409 ciphertext_pad_len, 15, 0);
6410 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6411 "Failed to allocate input buffer in mempool");
6413 if (op_mode == OUT_OF_PLACE) {
6414 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6415 plaintext_pad_len, 15, 0);
6416 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6417 "Failed to allocate output buffer in mempool");
6421 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6422 tdata->ciphertext.data);
6423 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6424 ciphertext_len, buffer);
6425 debug_hexdump(stdout, "ciphertext:", ciphertext,
6428 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6429 tdata->plaintext.data);
6430 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6431 plaintext_len, buffer);
6432 debug_hexdump(stdout, "plaintext:", plaintext,
6435 memset(buffer, 0, sizeof(buffer));
6437 /* Create the operation */
6438 retval = create_wireless_algo_auth_cipher_operation(
6439 tdata->digest_enc.data, tdata->digest_enc.len,
6440 tdata->cipher_iv.data, tdata->cipher_iv.len,
6441 tdata->auth_iv.data, tdata->auth_iv.len,
6442 (tdata->digest_enc.offset == 0 ?
6444 : tdata->digest_enc.offset),
6445 tdata->validCipherLen.len_bits,
6446 tdata->cipher.offset_bits,
6447 tdata->validAuthLen.len_bits,
6448 tdata->auth.offset_bits,
6449 op_mode, 1, verify);
6454 op = process_crypto_request(ts_params->valid_devs[0],
6457 /* Check if the op failed because the device doesn't */
6458 /* support this particular combination of algorithms */
6459 if (op == NULL && ut_params->op->status ==
6460 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6461 printf("Device doesn't support this mixed combination. "
6468 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6470 ut_params->obuf = (op_mode == IN_PLACE ?
6471 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6474 if (ut_params->obuf)
6475 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6476 plaintext_len, buffer);
6478 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6479 plaintext_len, buffer);
6481 debug_hexdump(stdout, "plaintext:", plaintext,
6482 (tdata->plaintext.len_bits >> 3) -
6483 tdata->digest_enc.len);
6484 debug_hexdump(stdout, "plaintext expected:",
6485 tdata->plaintext.data,
6486 (tdata->plaintext.len_bits >> 3) -
6487 tdata->digest_enc.len);
6489 if (ut_params->obuf)
6490 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6491 ciphertext_len, buffer);
6493 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6494 ciphertext_len, buffer);
6496 debug_hexdump(stdout, "ciphertext:", ciphertext,
6498 debug_hexdump(stdout, "ciphertext expected:",
6499 tdata->ciphertext.data,
6500 tdata->ciphertext.len_bits >> 3);
6502 if (ut_params->obuf)
6503 digest = rte_pktmbuf_read(ut_params->obuf,
6504 (tdata->digest_enc.offset == 0 ?
6506 tdata->digest_enc.offset),
6507 tdata->digest_enc.len, digest_buffer);
6509 digest = rte_pktmbuf_read(ut_params->ibuf,
6510 (tdata->digest_enc.offset == 0 ?
6512 tdata->digest_enc.offset),
6513 tdata->digest_enc.len, digest_buffer);
6515 debug_hexdump(stdout, "digest:", digest,
6516 tdata->digest_enc.len);
6517 debug_hexdump(stdout, "digest expected:",
6518 tdata->digest_enc.data, tdata->digest_enc.len);
6523 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6525 tdata->plaintext.data,
6526 tdata->plaintext.len_bits >> 3,
6527 "Plaintext data not as expected");
6529 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6531 tdata->ciphertext.data,
6532 tdata->validDataLen.len_bits,
6533 "Ciphertext data not as expected");
6534 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6536 tdata->digest_enc.data,
6537 tdata->digest_enc.len,
6538 "Generated auth tag not as expected");
6541 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6542 "crypto op processing failed");
6547 /** AUTH AES CMAC + CIPHER AES CTR */
6550 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6552 return test_mixed_auth_cipher(
6553 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6557 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6559 return test_mixed_auth_cipher(
6560 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6564 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6566 return test_mixed_auth_cipher_sgl(
6567 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6571 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6573 return test_mixed_auth_cipher_sgl(
6574 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6578 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6580 return test_mixed_auth_cipher(
6581 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6585 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6587 return test_mixed_auth_cipher(
6588 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6592 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6594 return test_mixed_auth_cipher_sgl(
6595 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6599 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6601 return test_mixed_auth_cipher_sgl(
6602 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6605 /** MIXED AUTH + CIPHER */
6608 test_auth_zuc_cipher_snow_test_case_1(void)
6610 return test_mixed_auth_cipher(
6611 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6615 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6617 return test_mixed_auth_cipher(
6618 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6622 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6624 return test_mixed_auth_cipher(
6625 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6629 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6631 return test_mixed_auth_cipher(
6632 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6636 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6638 return test_mixed_auth_cipher(
6639 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6643 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6645 return test_mixed_auth_cipher(
6646 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6650 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6652 return test_mixed_auth_cipher(
6653 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6657 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6659 return test_mixed_auth_cipher(
6660 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6664 test_auth_snow_cipher_zuc_test_case_1(void)
6666 return test_mixed_auth_cipher(
6667 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6671 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6673 return test_mixed_auth_cipher(
6674 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6678 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6680 return test_mixed_auth_cipher(
6681 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6685 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6687 return test_mixed_auth_cipher(
6688 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6692 test_auth_null_cipher_snow_test_case_1(void)
6694 return test_mixed_auth_cipher(
6695 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6699 test_verify_auth_null_cipher_snow_test_case_1(void)
6701 return test_mixed_auth_cipher(
6702 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6706 test_auth_null_cipher_zuc_test_case_1(void)
6708 return test_mixed_auth_cipher(
6709 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6713 test_verify_auth_null_cipher_zuc_test_case_1(void)
6715 return test_mixed_auth_cipher(
6716 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6720 test_auth_snow_cipher_null_test_case_1(void)
6722 return test_mixed_auth_cipher(
6723 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6727 test_verify_auth_snow_cipher_null_test_case_1(void)
6729 return test_mixed_auth_cipher(
6730 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6734 test_auth_zuc_cipher_null_test_case_1(void)
6736 return test_mixed_auth_cipher(
6737 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6741 test_verify_auth_zuc_cipher_null_test_case_1(void)
6743 return test_mixed_auth_cipher(
6744 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6748 test_auth_null_cipher_aes_ctr_test_case_1(void)
6750 return test_mixed_auth_cipher(
6751 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6755 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6757 return test_mixed_auth_cipher(
6758 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6762 test_auth_aes_cmac_cipher_null_test_case_1(void)
6764 return test_mixed_auth_cipher(
6765 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6769 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6771 return test_mixed_auth_cipher(
6772 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6775 /* ***** AEAD algorithm Tests ***** */
6778 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6779 enum rte_crypto_aead_operation op,
6780 const uint8_t *key, const uint8_t key_len,
6781 const uint16_t aad_len, const uint8_t auth_len,
6784 uint8_t aead_key[key_len];
6786 struct crypto_testsuite_params *ts_params = &testsuite_params;
6787 struct crypto_unittest_params *ut_params = &unittest_params;
6789 memcpy(aead_key, key, key_len);
6791 /* Setup AEAD Parameters */
6792 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6793 ut_params->aead_xform.next = NULL;
6794 ut_params->aead_xform.aead.algo = algo;
6795 ut_params->aead_xform.aead.op = op;
6796 ut_params->aead_xform.aead.key.data = aead_key;
6797 ut_params->aead_xform.aead.key.length = key_len;
6798 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6799 ut_params->aead_xform.aead.iv.length = iv_len;
6800 ut_params->aead_xform.aead.digest_length = auth_len;
6801 ut_params->aead_xform.aead.aad_length = aad_len;
6803 debug_hexdump(stdout, "key:", key, key_len);
6805 /* Create Crypto session*/
6806 ut_params->sess = rte_cryptodev_sym_session_create(
6807 ts_params->session_mpool);
6809 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6810 &ut_params->aead_xform,
6811 ts_params->session_priv_mpool);
6813 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6819 create_aead_xform(struct rte_crypto_op *op,
6820 enum rte_crypto_aead_algorithm algo,
6821 enum rte_crypto_aead_operation aead_op,
6822 uint8_t *key, const uint8_t key_len,
6823 const uint8_t aad_len, const uint8_t auth_len,
6826 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6827 "failed to allocate space for crypto transform");
6829 struct rte_crypto_sym_op *sym_op = op->sym;
6831 /* Setup AEAD Parameters */
6832 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6833 sym_op->xform->next = NULL;
6834 sym_op->xform->aead.algo = algo;
6835 sym_op->xform->aead.op = aead_op;
6836 sym_op->xform->aead.key.data = key;
6837 sym_op->xform->aead.key.length = key_len;
6838 sym_op->xform->aead.iv.offset = IV_OFFSET;
6839 sym_op->xform->aead.iv.length = iv_len;
6840 sym_op->xform->aead.digest_length = auth_len;
6841 sym_op->xform->aead.aad_length = aad_len;
6843 debug_hexdump(stdout, "key:", key, key_len);
6849 create_aead_operation(enum rte_crypto_aead_operation op,
6850 const struct aead_test_data *tdata)
6852 struct crypto_testsuite_params *ts_params = &testsuite_params;
6853 struct crypto_unittest_params *ut_params = &unittest_params;
6855 uint8_t *plaintext, *ciphertext;
6856 unsigned int aad_pad_len, plaintext_pad_len;
6858 /* Generate Crypto op data structure */
6859 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6860 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6861 TEST_ASSERT_NOT_NULL(ut_params->op,
6862 "Failed to allocate symmetric crypto operation struct");
6864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6866 /* Append aad data */
6867 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6868 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6869 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6871 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6872 "no room to append aad");
6874 sym_op->aead.aad.phys_addr =
6875 rte_pktmbuf_iova(ut_params->ibuf);
6876 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6877 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6878 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6881 /* Append IV at the end of the crypto operation*/
6882 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6883 uint8_t *, IV_OFFSET);
6885 /* Copy IV 1 byte after the IV pointer, according to the API */
6886 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6887 debug_hexdump(stdout, "iv:", iv_ptr,
6890 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6891 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6893 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6894 "no room to append aad");
6896 sym_op->aead.aad.phys_addr =
6897 rte_pktmbuf_iova(ut_params->ibuf);
6898 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6899 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6902 /* Append IV at the end of the crypto operation*/
6903 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6904 uint8_t *, IV_OFFSET);
6906 if (tdata->iv.len == 0) {
6907 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6908 debug_hexdump(stdout, "iv:", iv_ptr,
6911 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6912 debug_hexdump(stdout, "iv:", iv_ptr,
6917 /* Append plaintext/ciphertext */
6918 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6919 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6920 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6922 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6924 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6925 debug_hexdump(stdout, "plaintext:", plaintext,
6926 tdata->plaintext.len);
6928 if (ut_params->obuf) {
6929 ciphertext = (uint8_t *)rte_pktmbuf_append(
6931 plaintext_pad_len + aad_pad_len);
6932 TEST_ASSERT_NOT_NULL(ciphertext,
6933 "no room to append ciphertext");
6935 memset(ciphertext + aad_pad_len, 0,
6936 tdata->ciphertext.len);
6939 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6940 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6942 TEST_ASSERT_NOT_NULL(ciphertext,
6943 "no room to append ciphertext");
6945 memcpy(ciphertext, tdata->ciphertext.data,
6946 tdata->ciphertext.len);
6947 debug_hexdump(stdout, "ciphertext:", ciphertext,
6948 tdata->ciphertext.len);
6950 if (ut_params->obuf) {
6951 plaintext = (uint8_t *)rte_pktmbuf_append(
6953 plaintext_pad_len + aad_pad_len);
6954 TEST_ASSERT_NOT_NULL(plaintext,
6955 "no room to append plaintext");
6957 memset(plaintext + aad_pad_len, 0,
6958 tdata->plaintext.len);
6962 /* Append digest data */
6963 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6964 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6965 ut_params->obuf ? ut_params->obuf :
6967 tdata->auth_tag.len);
6968 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6969 "no room to append digest");
6970 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6971 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6972 ut_params->obuf ? ut_params->obuf :
6977 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6978 ut_params->ibuf, tdata->auth_tag.len);
6979 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6980 "no room to append digest");
6981 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6983 plaintext_pad_len + aad_pad_len);
6985 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6986 tdata->auth_tag.len);
6987 debug_hexdump(stdout, "digest:",
6988 sym_op->aead.digest.data,
6989 tdata->auth_tag.len);
6992 sym_op->aead.data.length = tdata->plaintext.len;
6993 sym_op->aead.data.offset = aad_pad_len;
6999 test_authenticated_encryption(const struct aead_test_data *tdata)
7001 struct crypto_testsuite_params *ts_params = &testsuite_params;
7002 struct crypto_unittest_params *ut_params = &unittest_params;
7005 uint8_t *ciphertext, *auth_tag;
7006 uint16_t plaintext_pad_len;
7009 /* Verify the capabilities */
7010 struct rte_cryptodev_sym_capability_idx cap_idx;
7011 const struct rte_cryptodev_symmetric_capability *capability;
7012 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7013 cap_idx.algo.aead = tdata->algo;
7014 capability = rte_cryptodev_sym_capability_get(
7015 ts_params->valid_devs[0], &cap_idx);
7016 if (capability == NULL)
7018 if (rte_cryptodev_sym_capability_check_aead(
7019 capability, tdata->key.len, tdata->auth_tag.len,
7020 tdata->aad.len, tdata->iv.len))
7023 /* Create AEAD session */
7024 retval = create_aead_session(ts_params->valid_devs[0],
7026 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7027 tdata->key.data, tdata->key.len,
7028 tdata->aad.len, tdata->auth_tag.len,
7033 if (tdata->aad.len > MBUF_SIZE) {
7034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7035 /* Populate full size of add data */
7036 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7037 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7039 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7041 /* clear mbuf payload */
7042 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7043 rte_pktmbuf_tailroom(ut_params->ibuf));
7045 /* Create AEAD operation */
7046 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7050 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7052 ut_params->op->sym->m_src = ut_params->ibuf;
7054 /* Process crypto operation */
7055 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7056 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7058 TEST_ASSERT_NOT_NULL(
7059 process_crypto_request(ts_params->valid_devs[0],
7060 ut_params->op), "failed to process sym crypto op");
7062 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7063 "crypto op processing failed");
7065 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7067 if (ut_params->op->sym->m_dst) {
7068 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7070 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7071 uint8_t *, plaintext_pad_len);
7073 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7075 ut_params->op->sym->cipher.data.offset);
7076 auth_tag = ciphertext + plaintext_pad_len;
7079 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7080 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7085 tdata->ciphertext.data,
7086 tdata->ciphertext.len,
7087 "Ciphertext data not as expected");
7089 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7091 tdata->auth_tag.data,
7092 tdata->auth_tag.len,
7093 "Generated auth tag not as expected");
7099 #ifdef RTE_LIBRTE_SECURITY
7100 /* Basic algorithm run function for async inplace mode.
7101 * Creates a session from input parameters and runs one operation
7102 * on input_vec. Checks the output of the crypto operation against
7106 test_pdcp_proto(int i, int oop,
7107 enum rte_crypto_cipher_operation opc,
7108 enum rte_crypto_auth_operation opa,
7110 unsigned int input_vec_len,
7111 uint8_t *output_vec,
7112 unsigned int output_vec_len)
7114 struct crypto_testsuite_params *ts_params = &testsuite_params;
7115 struct crypto_unittest_params *ut_params = &unittest_params;
7117 int ret = TEST_SUCCESS;
7118 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7119 rte_cryptodev_get_sec_ctx(
7120 ts_params->valid_devs[0]);
7122 /* Verify the capabilities */
7123 struct rte_security_capability_idx sec_cap_idx;
7125 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7126 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7127 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7128 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7131 /* Generate test mbuf data */
7132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7134 /* clear mbuf payload */
7135 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7136 rte_pktmbuf_tailroom(ut_params->ibuf));
7138 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7140 memcpy(plaintext, input_vec, input_vec_len);
7142 /* Out of place support */
7145 * For out-op-place we need to alloc another mbuf
7147 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7148 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7151 /* Set crypto type as IPSEC */
7152 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7154 /* Setup Cipher Parameters */
7155 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7156 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7157 ut_params->cipher_xform.cipher.op = opc;
7158 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7159 ut_params->cipher_xform.cipher.key.length =
7160 pdcp_test_params[i].cipher_key_len;
7161 ut_params->cipher_xform.cipher.iv.length = 0;
7163 /* Setup HMAC Parameters if ICV header is required */
7164 if (pdcp_test_params[i].auth_alg != 0) {
7165 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7166 ut_params->auth_xform.next = NULL;
7167 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7168 ut_params->auth_xform.auth.op = opa;
7169 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7170 ut_params->auth_xform.auth.key.length =
7171 pdcp_test_params[i].auth_key_len;
7173 ut_params->cipher_xform.next = &ut_params->auth_xform;
7175 ut_params->cipher_xform.next = NULL;
7178 struct rte_security_session_conf sess_conf = {
7179 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7180 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7182 .bearer = pdcp_test_bearer[i],
7183 .domain = pdcp_test_params[i].domain,
7184 .pkt_dir = pdcp_test_packet_direction[i],
7185 .sn_size = pdcp_test_data_sn_size[i],
7186 .hfn = pdcp_test_hfn[i],
7187 .hfn_threshold = pdcp_test_hfn_threshold[i],
7189 .crypto_xform = &ut_params->cipher_xform
7192 /* Create security session */
7193 ut_params->sec_session = rte_security_session_create(ctx,
7194 &sess_conf, ts_params->session_priv_mpool);
7196 if (!ut_params->sec_session) {
7197 printf("TestCase %s()-%d line %d failed %s: ",
7198 __func__, i, __LINE__, "Failed to allocate session");
7203 /* Generate crypto op data structure */
7204 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7205 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7206 if (!ut_params->op) {
7207 printf("TestCase %s()-%d line %d failed %s: ",
7208 __func__, i, __LINE__,
7209 "Failed to allocate symmetric crypto operation struct");
7214 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7216 /* set crypto operation source mbuf */
7217 ut_params->op->sym->m_src = ut_params->ibuf;
7219 ut_params->op->sym->m_dst = ut_params->obuf;
7221 /* Process crypto operation */
7222 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7224 printf("TestCase %s()-%d line %d failed %s: ",
7225 __func__, i, __LINE__,
7226 "failed to process sym crypto op");
7231 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7232 printf("TestCase %s()-%d line %d failed %s: ",
7233 __func__, i, __LINE__, "crypto op processing failed");
7239 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7242 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7246 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7247 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7248 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7249 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7255 rte_crypto_op_free(ut_params->op);
7256 ut_params->op = NULL;
7258 if (ut_params->sec_session)
7259 rte_security_session_destroy(ctx, ut_params->sec_session);
7260 ut_params->sec_session = NULL;
7262 rte_pktmbuf_free(ut_params->ibuf);
7263 ut_params->ibuf = NULL;
7265 rte_pktmbuf_free(ut_params->obuf);
7266 ut_params->obuf = NULL;
7273 test_pdcp_proto_SGL(int i, int oop,
7274 enum rte_crypto_cipher_operation opc,
7275 enum rte_crypto_auth_operation opa,
7277 unsigned int input_vec_len,
7278 uint8_t *output_vec,
7279 unsigned int output_vec_len,
7281 uint32_t fragsz_oop)
7283 struct crypto_testsuite_params *ts_params = &testsuite_params;
7284 struct crypto_unittest_params *ut_params = &unittest_params;
7286 struct rte_mbuf *buf, *buf_oop = NULL;
7287 int ret = TEST_SUCCESS;
7291 unsigned int trn_data = 0;
7292 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7293 rte_cryptodev_get_sec_ctx(
7294 ts_params->valid_devs[0]);
7296 /* Verify the capabilities */
7297 struct rte_security_capability_idx sec_cap_idx;
7299 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7300 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7301 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7302 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7305 if (fragsz > input_vec_len)
7306 fragsz = input_vec_len;
7308 uint16_t plaintext_len = fragsz;
7309 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7311 if (fragsz_oop > output_vec_len)
7312 frag_size_oop = output_vec_len;
7315 if (input_vec_len % fragsz != 0) {
7316 if (input_vec_len / fragsz + 1 > 16)
7318 } else if (input_vec_len / fragsz > 16)
7321 /* Out of place support */
7324 * For out-op-place we need to alloc another mbuf
7326 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7327 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7328 buf_oop = ut_params->obuf;
7331 /* Generate test mbuf data */
7332 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7334 /* clear mbuf payload */
7335 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7336 rte_pktmbuf_tailroom(ut_params->ibuf));
7338 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7340 memcpy(plaintext, input_vec, plaintext_len);
7341 trn_data += plaintext_len;
7343 buf = ut_params->ibuf;
7346 * Loop until no more fragments
7349 while (trn_data < input_vec_len) {
7351 to_trn = (input_vec_len - trn_data < fragsz) ?
7352 (input_vec_len - trn_data) : fragsz;
7354 to_trn_tbl[ecx++] = to_trn;
7356 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7359 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7360 rte_pktmbuf_tailroom(buf));
7363 if (oop && !fragsz_oop) {
7365 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7366 buf_oop = buf_oop->next;
7367 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7368 0, rte_pktmbuf_tailroom(buf_oop));
7369 rte_pktmbuf_append(buf_oop, to_trn);
7372 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7375 memcpy(plaintext, input_vec + trn_data, to_trn);
7379 ut_params->ibuf->nb_segs = segs;
7382 if (fragsz_oop && oop) {
7386 trn_data = frag_size_oop;
7387 while (trn_data < output_vec_len) {
7390 (output_vec_len - trn_data <
7392 (output_vec_len - trn_data) :
7395 to_trn_tbl[ecx++] = to_trn;
7398 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7399 buf_oop = buf_oop->next;
7400 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7401 0, rte_pktmbuf_tailroom(buf_oop));
7402 rte_pktmbuf_append(buf_oop, to_trn);
7406 ut_params->obuf->nb_segs = segs;
7409 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7411 /* Setup Cipher Parameters */
7412 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7413 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7414 ut_params->cipher_xform.cipher.op = opc;
7415 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7416 ut_params->cipher_xform.cipher.key.length =
7417 pdcp_test_params[i].cipher_key_len;
7418 ut_params->cipher_xform.cipher.iv.length = 0;
7420 /* Setup HMAC Parameters if ICV header is required */
7421 if (pdcp_test_params[i].auth_alg != 0) {
7422 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7423 ut_params->auth_xform.next = NULL;
7424 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7425 ut_params->auth_xform.auth.op = opa;
7426 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7427 ut_params->auth_xform.auth.key.length =
7428 pdcp_test_params[i].auth_key_len;
7430 ut_params->cipher_xform.next = &ut_params->auth_xform;
7432 ut_params->cipher_xform.next = NULL;
7435 struct rte_security_session_conf sess_conf = {
7436 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7437 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7439 .bearer = pdcp_test_bearer[i],
7440 .domain = pdcp_test_params[i].domain,
7441 .pkt_dir = pdcp_test_packet_direction[i],
7442 .sn_size = pdcp_test_data_sn_size[i],
7443 .hfn = pdcp_test_hfn[i],
7444 .hfn_threshold = pdcp_test_hfn_threshold[i],
7446 .crypto_xform = &ut_params->cipher_xform
7449 /* Create security session */
7450 ut_params->sec_session = rte_security_session_create(ctx,
7451 &sess_conf, ts_params->session_priv_mpool);
7453 if (!ut_params->sec_session) {
7454 printf("TestCase %s()-%d line %d failed %s: ",
7455 __func__, i, __LINE__, "Failed to allocate session");
7460 /* Generate crypto op data structure */
7461 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7462 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7463 if (!ut_params->op) {
7464 printf("TestCase %s()-%d line %d failed %s: ",
7465 __func__, i, __LINE__,
7466 "Failed to allocate symmetric crypto operation struct");
7471 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7473 /* set crypto operation source mbuf */
7474 ut_params->op->sym->m_src = ut_params->ibuf;
7476 ut_params->op->sym->m_dst = ut_params->obuf;
7478 /* Process crypto operation */
7479 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7481 printf("TestCase %s()-%d line %d failed %s: ",
7482 __func__, i, __LINE__,
7483 "failed to process sym crypto op");
7488 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7489 printf("TestCase %s()-%d line %d failed %s: ",
7490 __func__, i, __LINE__, "crypto op processing failed");
7496 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7499 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7503 fragsz = frag_size_oop;
7504 if (memcmp(ciphertext, output_vec, fragsz)) {
7505 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7506 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7507 rte_hexdump(stdout, "reference", output_vec, fragsz);
7512 buf = ut_params->op->sym->m_src->next;
7514 buf = ut_params->op->sym->m_dst->next;
7516 unsigned int off = fragsz;
7520 ciphertext = rte_pktmbuf_mtod(buf,
7522 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7523 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7524 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7525 rte_hexdump(stdout, "reference", output_vec + off,
7530 off += to_trn_tbl[ecx++];
7534 rte_crypto_op_free(ut_params->op);
7535 ut_params->op = NULL;
7537 if (ut_params->sec_session)
7538 rte_security_session_destroy(ctx, ut_params->sec_session);
7539 ut_params->sec_session = NULL;
7541 rte_pktmbuf_free(ut_params->ibuf);
7542 ut_params->ibuf = NULL;
7544 rte_pktmbuf_free(ut_params->obuf);
7545 ut_params->obuf = NULL;
7552 test_pdcp_proto_cplane_encap(int i)
7554 return test_pdcp_proto(i, 0,
7555 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7556 RTE_CRYPTO_AUTH_OP_GENERATE,
7557 pdcp_test_data_in[i],
7558 pdcp_test_data_in_len[i],
7559 pdcp_test_data_out[i],
7560 pdcp_test_data_in_len[i]+4);
7564 test_pdcp_proto_uplane_encap(int i)
7566 return test_pdcp_proto(i, 0,
7567 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7568 RTE_CRYPTO_AUTH_OP_GENERATE,
7569 pdcp_test_data_in[i],
7570 pdcp_test_data_in_len[i],
7571 pdcp_test_data_out[i],
7572 pdcp_test_data_in_len[i]);
7577 test_pdcp_proto_uplane_encap_with_int(int i)
7579 return test_pdcp_proto(i, 0,
7580 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7581 RTE_CRYPTO_AUTH_OP_GENERATE,
7582 pdcp_test_data_in[i],
7583 pdcp_test_data_in_len[i],
7584 pdcp_test_data_out[i],
7585 pdcp_test_data_in_len[i] + 4);
7589 test_pdcp_proto_cplane_decap(int i)
7591 return test_pdcp_proto(i, 0,
7592 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7593 RTE_CRYPTO_AUTH_OP_VERIFY,
7594 pdcp_test_data_out[i],
7595 pdcp_test_data_in_len[i] + 4,
7596 pdcp_test_data_in[i],
7597 pdcp_test_data_in_len[i]);
7601 test_pdcp_proto_uplane_decap(int i)
7603 return test_pdcp_proto(i, 0,
7604 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7605 RTE_CRYPTO_AUTH_OP_VERIFY,
7606 pdcp_test_data_out[i],
7607 pdcp_test_data_in_len[i],
7608 pdcp_test_data_in[i],
7609 pdcp_test_data_in_len[i]);
7613 test_pdcp_proto_uplane_decap_with_int(int i)
7615 return test_pdcp_proto(i, 0,
7616 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7617 RTE_CRYPTO_AUTH_OP_VERIFY,
7618 pdcp_test_data_out[i],
7619 pdcp_test_data_in_len[i] + 4,
7620 pdcp_test_data_in[i],
7621 pdcp_test_data_in_len[i]);
7625 test_PDCP_PROTO_SGL_in_place_32B(void)
7627 /* i can be used for running any PDCP case
7628 * In this case it is uplane 12-bit AES-SNOW DL encap
7630 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7631 return test_pdcp_proto_SGL(i, IN_PLACE,
7632 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7633 RTE_CRYPTO_AUTH_OP_GENERATE,
7634 pdcp_test_data_in[i],
7635 pdcp_test_data_in_len[i],
7636 pdcp_test_data_out[i],
7637 pdcp_test_data_in_len[i]+4,
7641 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7643 /* i can be used for running any PDCP case
7644 * In this case it is uplane 18-bit NULL-NULL DL encap
7646 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7647 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7648 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7649 RTE_CRYPTO_AUTH_OP_GENERATE,
7650 pdcp_test_data_in[i],
7651 pdcp_test_data_in_len[i],
7652 pdcp_test_data_out[i],
7653 pdcp_test_data_in_len[i]+4,
7657 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7659 /* i can be used for running any PDCP case
7660 * In this case it is uplane 18-bit AES DL encap
7662 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7664 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7665 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7666 RTE_CRYPTO_AUTH_OP_GENERATE,
7667 pdcp_test_data_in[i],
7668 pdcp_test_data_in_len[i],
7669 pdcp_test_data_out[i],
7670 pdcp_test_data_in_len[i],
7674 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7676 /* i can be used for running any PDCP case
7677 * In this case it is cplane 12-bit AES-ZUC DL encap
7679 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7680 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7681 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7682 RTE_CRYPTO_AUTH_OP_GENERATE,
7683 pdcp_test_data_in[i],
7684 pdcp_test_data_in_len[i],
7685 pdcp_test_data_out[i],
7686 pdcp_test_data_in_len[i]+4,
7692 test_AES_GCM_authenticated_encryption_test_case_1(void)
7694 return test_authenticated_encryption(&gcm_test_case_1);
7698 test_AES_GCM_authenticated_encryption_test_case_2(void)
7700 return test_authenticated_encryption(&gcm_test_case_2);
7704 test_AES_GCM_authenticated_encryption_test_case_3(void)
7706 return test_authenticated_encryption(&gcm_test_case_3);
7710 test_AES_GCM_authenticated_encryption_test_case_4(void)
7712 return test_authenticated_encryption(&gcm_test_case_4);
7716 test_AES_GCM_authenticated_encryption_test_case_5(void)
7718 return test_authenticated_encryption(&gcm_test_case_5);
7722 test_AES_GCM_authenticated_encryption_test_case_6(void)
7724 return test_authenticated_encryption(&gcm_test_case_6);
7728 test_AES_GCM_authenticated_encryption_test_case_7(void)
7730 return test_authenticated_encryption(&gcm_test_case_7);
7734 test_AES_GCM_authenticated_encryption_test_case_8(void)
7736 return test_authenticated_encryption(&gcm_test_case_8);
7740 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7742 return test_authenticated_encryption(&gcm_J0_test_case_1);
7746 test_AES_GCM_auth_encryption_test_case_192_1(void)
7748 return test_authenticated_encryption(&gcm_test_case_192_1);
7752 test_AES_GCM_auth_encryption_test_case_192_2(void)
7754 return test_authenticated_encryption(&gcm_test_case_192_2);
7758 test_AES_GCM_auth_encryption_test_case_192_3(void)
7760 return test_authenticated_encryption(&gcm_test_case_192_3);
7764 test_AES_GCM_auth_encryption_test_case_192_4(void)
7766 return test_authenticated_encryption(&gcm_test_case_192_4);
7770 test_AES_GCM_auth_encryption_test_case_192_5(void)
7772 return test_authenticated_encryption(&gcm_test_case_192_5);
7776 test_AES_GCM_auth_encryption_test_case_192_6(void)
7778 return test_authenticated_encryption(&gcm_test_case_192_6);
7782 test_AES_GCM_auth_encryption_test_case_192_7(void)
7784 return test_authenticated_encryption(&gcm_test_case_192_7);
7788 test_AES_GCM_auth_encryption_test_case_256_1(void)
7790 return test_authenticated_encryption(&gcm_test_case_256_1);
7794 test_AES_GCM_auth_encryption_test_case_256_2(void)
7796 return test_authenticated_encryption(&gcm_test_case_256_2);
7800 test_AES_GCM_auth_encryption_test_case_256_3(void)
7802 return test_authenticated_encryption(&gcm_test_case_256_3);
7806 test_AES_GCM_auth_encryption_test_case_256_4(void)
7808 return test_authenticated_encryption(&gcm_test_case_256_4);
7812 test_AES_GCM_auth_encryption_test_case_256_5(void)
7814 return test_authenticated_encryption(&gcm_test_case_256_5);
7818 test_AES_GCM_auth_encryption_test_case_256_6(void)
7820 return test_authenticated_encryption(&gcm_test_case_256_6);
7824 test_AES_GCM_auth_encryption_test_case_256_7(void)
7826 return test_authenticated_encryption(&gcm_test_case_256_7);
7830 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7832 return test_authenticated_encryption(&gcm_test_case_aad_1);
7836 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7838 return test_authenticated_encryption(&gcm_test_case_aad_2);
7842 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7844 struct aead_test_data tdata;
7847 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7848 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7849 tdata.iv.data[0] += 1;
7850 res = test_authenticated_encryption(&tdata);
7851 if (res == -ENOTSUP)
7853 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7854 return TEST_SUCCESS;
7858 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7860 struct aead_test_data tdata;
7863 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7864 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7865 tdata.plaintext.data[0] += 1;
7866 res = test_authenticated_encryption(&tdata);
7867 if (res == -ENOTSUP)
7869 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7870 return TEST_SUCCESS;
7874 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7876 struct aead_test_data tdata;
7879 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7880 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7881 tdata.ciphertext.data[0] += 1;
7882 res = test_authenticated_encryption(&tdata);
7883 if (res == -ENOTSUP)
7885 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7886 return TEST_SUCCESS;
7890 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7892 struct aead_test_data tdata;
7895 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7896 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7898 res = test_authenticated_encryption(&tdata);
7899 if (res == -ENOTSUP)
7901 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7902 return TEST_SUCCESS;
7906 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7908 struct aead_test_data tdata;
7909 uint8_t aad[gcm_test_case_7.aad.len];
7912 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7913 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7914 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7916 tdata.aad.data = aad;
7917 res = test_authenticated_encryption(&tdata);
7918 if (res == -ENOTSUP)
7920 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7921 return TEST_SUCCESS;
7925 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7927 struct aead_test_data tdata;
7930 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7931 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7932 tdata.auth_tag.data[0] += 1;
7933 res = test_authenticated_encryption(&tdata);
7934 if (res == -ENOTSUP)
7936 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7937 return TEST_SUCCESS;
7941 test_authenticated_decryption(const struct aead_test_data *tdata)
7943 struct crypto_testsuite_params *ts_params = &testsuite_params;
7944 struct crypto_unittest_params *ut_params = &unittest_params;
7950 /* Verify the capabilities */
7951 struct rte_cryptodev_sym_capability_idx cap_idx;
7952 const struct rte_cryptodev_symmetric_capability *capability;
7953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7954 cap_idx.algo.aead = tdata->algo;
7955 capability = rte_cryptodev_sym_capability_get(
7956 ts_params->valid_devs[0], &cap_idx);
7957 if (capability == NULL)
7959 if (rte_cryptodev_sym_capability_check_aead(
7960 capability, tdata->key.len, tdata->auth_tag.len,
7961 tdata->aad.len, tdata->iv.len))
7964 /* Create AEAD session */
7965 retval = create_aead_session(ts_params->valid_devs[0],
7967 RTE_CRYPTO_AEAD_OP_DECRYPT,
7968 tdata->key.data, tdata->key.len,
7969 tdata->aad.len, tdata->auth_tag.len,
7974 /* alloc mbuf and set payload */
7975 if (tdata->aad.len > MBUF_SIZE) {
7976 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7977 /* Populate full size of add data */
7978 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7979 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7981 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7984 rte_pktmbuf_tailroom(ut_params->ibuf));
7986 /* Create AEAD operation */
7987 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7991 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7993 ut_params->op->sym->m_src = ut_params->ibuf;
7995 /* Process crypto operation */
7996 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7997 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7999 TEST_ASSERT_NOT_NULL(
8000 process_crypto_request(ts_params->valid_devs[0],
8001 ut_params->op), "failed to process sym crypto op");
8003 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8004 "crypto op processing failed");
8006 if (ut_params->op->sym->m_dst)
8007 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8010 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8012 ut_params->op->sym->cipher.data.offset);
8014 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8017 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8019 tdata->plaintext.data,
8020 tdata->plaintext.len,
8021 "Plaintext data not as expected");
8023 TEST_ASSERT_EQUAL(ut_params->op->status,
8024 RTE_CRYPTO_OP_STATUS_SUCCESS,
8025 "Authentication failed");
8031 test_AES_GCM_authenticated_decryption_test_case_1(void)
8033 return test_authenticated_decryption(&gcm_test_case_1);
8037 test_AES_GCM_authenticated_decryption_test_case_2(void)
8039 return test_authenticated_decryption(&gcm_test_case_2);
8043 test_AES_GCM_authenticated_decryption_test_case_3(void)
8045 return test_authenticated_decryption(&gcm_test_case_3);
8049 test_AES_GCM_authenticated_decryption_test_case_4(void)
8051 return test_authenticated_decryption(&gcm_test_case_4);
8055 test_AES_GCM_authenticated_decryption_test_case_5(void)
8057 return test_authenticated_decryption(&gcm_test_case_5);
8061 test_AES_GCM_authenticated_decryption_test_case_6(void)
8063 return test_authenticated_decryption(&gcm_test_case_6);
8067 test_AES_GCM_authenticated_decryption_test_case_7(void)
8069 return test_authenticated_decryption(&gcm_test_case_7);
8073 test_AES_GCM_authenticated_decryption_test_case_8(void)
8075 return test_authenticated_decryption(&gcm_test_case_8);
8079 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8081 return test_authenticated_decryption(&gcm_J0_test_case_1);
8085 test_AES_GCM_auth_decryption_test_case_192_1(void)
8087 return test_authenticated_decryption(&gcm_test_case_192_1);
8091 test_AES_GCM_auth_decryption_test_case_192_2(void)
8093 return test_authenticated_decryption(&gcm_test_case_192_2);
8097 test_AES_GCM_auth_decryption_test_case_192_3(void)
8099 return test_authenticated_decryption(&gcm_test_case_192_3);
8103 test_AES_GCM_auth_decryption_test_case_192_4(void)
8105 return test_authenticated_decryption(&gcm_test_case_192_4);
8109 test_AES_GCM_auth_decryption_test_case_192_5(void)
8111 return test_authenticated_decryption(&gcm_test_case_192_5);
8115 test_AES_GCM_auth_decryption_test_case_192_6(void)
8117 return test_authenticated_decryption(&gcm_test_case_192_6);
8121 test_AES_GCM_auth_decryption_test_case_192_7(void)
8123 return test_authenticated_decryption(&gcm_test_case_192_7);
8127 test_AES_GCM_auth_decryption_test_case_256_1(void)
8129 return test_authenticated_decryption(&gcm_test_case_256_1);
8133 test_AES_GCM_auth_decryption_test_case_256_2(void)
8135 return test_authenticated_decryption(&gcm_test_case_256_2);
8139 test_AES_GCM_auth_decryption_test_case_256_3(void)
8141 return test_authenticated_decryption(&gcm_test_case_256_3);
8145 test_AES_GCM_auth_decryption_test_case_256_4(void)
8147 return test_authenticated_decryption(&gcm_test_case_256_4);
8151 test_AES_GCM_auth_decryption_test_case_256_5(void)
8153 return test_authenticated_decryption(&gcm_test_case_256_5);
8157 test_AES_GCM_auth_decryption_test_case_256_6(void)
8159 return test_authenticated_decryption(&gcm_test_case_256_6);
8163 test_AES_GCM_auth_decryption_test_case_256_7(void)
8165 return test_authenticated_decryption(&gcm_test_case_256_7);
8169 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8171 return test_authenticated_decryption(&gcm_test_case_aad_1);
8175 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8177 return test_authenticated_decryption(&gcm_test_case_aad_2);
8181 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8183 struct aead_test_data tdata;
8186 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8187 tdata.iv.data[0] += 1;
8188 res = test_authenticated_decryption(&tdata);
8189 if (res == -ENOTSUP)
8191 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8192 return TEST_SUCCESS;
8196 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8198 struct aead_test_data tdata;
8201 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8202 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8203 tdata.plaintext.data[0] += 1;
8204 res = test_authenticated_decryption(&tdata);
8205 if (res == -ENOTSUP)
8207 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8208 return TEST_SUCCESS;
8212 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8214 struct aead_test_data tdata;
8217 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8218 tdata.ciphertext.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_aad_len_corrupt(void)
8229 struct aead_test_data tdata;
8232 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8234 res = test_authenticated_decryption(&tdata);
8235 if (res == -ENOTSUP)
8237 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8238 return TEST_SUCCESS;
8242 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8244 struct aead_test_data tdata;
8245 uint8_t aad[gcm_test_case_7.aad.len];
8248 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8249 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8251 tdata.aad.data = aad;
8252 res = test_authenticated_decryption(&tdata);
8253 if (res == -ENOTSUP)
8255 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8256 return TEST_SUCCESS;
8260 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8262 struct aead_test_data tdata;
8265 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8266 tdata.auth_tag.data[0] += 1;
8267 res = test_authenticated_decryption(&tdata);
8268 if (res == -ENOTSUP)
8270 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8271 return TEST_SUCCESS;
8275 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8277 struct crypto_testsuite_params *ts_params = &testsuite_params;
8278 struct crypto_unittest_params *ut_params = &unittest_params;
8281 uint8_t *ciphertext, *auth_tag;
8282 uint16_t plaintext_pad_len;
8284 /* Verify the capabilities */
8285 struct rte_cryptodev_sym_capability_idx cap_idx;
8286 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8287 cap_idx.algo.aead = tdata->algo;
8288 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8292 /* not supported with CPU crypto */
8293 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8296 /* Create AEAD session */
8297 retval = create_aead_session(ts_params->valid_devs[0],
8299 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8300 tdata->key.data, tdata->key.len,
8301 tdata->aad.len, tdata->auth_tag.len,
8306 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8307 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8309 /* clear mbuf payload */
8310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8311 rte_pktmbuf_tailroom(ut_params->ibuf));
8312 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8313 rte_pktmbuf_tailroom(ut_params->obuf));
8315 /* Create AEAD operation */
8316 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8320 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8322 ut_params->op->sym->m_src = ut_params->ibuf;
8323 ut_params->op->sym->m_dst = ut_params->obuf;
8325 /* Process crypto operation */
8326 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8327 ut_params->op), "failed to process sym crypto op");
8329 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8330 "crypto op processing failed");
8332 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8334 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8335 ut_params->op->sym->cipher.data.offset);
8336 auth_tag = ciphertext + plaintext_pad_len;
8338 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8339 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8342 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8344 tdata->ciphertext.data,
8345 tdata->ciphertext.len,
8346 "Ciphertext data not as expected");
8348 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8350 tdata->auth_tag.data,
8351 tdata->auth_tag.len,
8352 "Generated auth tag not as expected");
8359 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8361 return test_authenticated_encryption_oop(&gcm_test_case_5);
8365 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8367 struct crypto_testsuite_params *ts_params = &testsuite_params;
8368 struct crypto_unittest_params *ut_params = &unittest_params;
8373 /* Verify the capabilities */
8374 struct rte_cryptodev_sym_capability_idx cap_idx;
8375 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8376 cap_idx.algo.aead = tdata->algo;
8377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8381 /* not supported with CPU crypto */
8382 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8385 /* Create AEAD session */
8386 retval = create_aead_session(ts_params->valid_devs[0],
8388 RTE_CRYPTO_AEAD_OP_DECRYPT,
8389 tdata->key.data, tdata->key.len,
8390 tdata->aad.len, tdata->auth_tag.len,
8395 /* alloc mbuf and set payload */
8396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8397 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8400 rte_pktmbuf_tailroom(ut_params->ibuf));
8401 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8402 rte_pktmbuf_tailroom(ut_params->obuf));
8404 /* Create AEAD operation */
8405 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8409 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8411 ut_params->op->sym->m_src = ut_params->ibuf;
8412 ut_params->op->sym->m_dst = ut_params->obuf;
8414 /* Process crypto operation */
8415 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8416 ut_params->op), "failed to process sym crypto op");
8418 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8419 "crypto op processing failed");
8421 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8422 ut_params->op->sym->cipher.data.offset);
8424 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8429 tdata->plaintext.data,
8430 tdata->plaintext.len,
8431 "Plaintext data not as expected");
8433 TEST_ASSERT_EQUAL(ut_params->op->status,
8434 RTE_CRYPTO_OP_STATUS_SUCCESS,
8435 "Authentication failed");
8440 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8442 return test_authenticated_decryption_oop(&gcm_test_case_5);
8446 test_authenticated_encryption_sessionless(
8447 const struct aead_test_data *tdata)
8449 struct crypto_testsuite_params *ts_params = &testsuite_params;
8450 struct crypto_unittest_params *ut_params = &unittest_params;
8453 uint8_t *ciphertext, *auth_tag;
8454 uint16_t plaintext_pad_len;
8455 uint8_t key[tdata->key.len + 1];
8457 /* This test is for AESNI MB and AESNI GCM PMDs only */
8458 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8459 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8460 (gbl_driver_id != rte_cryptodev_driver_id_get(
8461 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8464 /* not supported with CPU crypto */
8465 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8468 /* Verify the capabilities */
8469 struct rte_cryptodev_sym_capability_idx cap_idx;
8470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8471 cap_idx.algo.aead = tdata->algo;
8472 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8478 /* clear mbuf payload */
8479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8480 rte_pktmbuf_tailroom(ut_params->ibuf));
8482 /* Create AEAD operation */
8483 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8487 /* Create GCM xform */
8488 memcpy(key, tdata->key.data, tdata->key.len);
8489 retval = create_aead_xform(ut_params->op,
8491 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8492 key, tdata->key.len,
8493 tdata->aad.len, tdata->auth_tag.len,
8498 ut_params->op->sym->m_src = ut_params->ibuf;
8500 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8501 RTE_CRYPTO_OP_SESSIONLESS,
8502 "crypto op session type not sessionless");
8504 /* Process crypto operation */
8505 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8506 ut_params->op), "failed to process sym crypto op");
8508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8510 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8511 "crypto op status not success");
8513 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8515 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8516 ut_params->op->sym->cipher.data.offset);
8517 auth_tag = ciphertext + plaintext_pad_len;
8519 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8520 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8525 tdata->ciphertext.data,
8526 tdata->ciphertext.len,
8527 "Ciphertext data not as expected");
8529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8531 tdata->auth_tag.data,
8532 tdata->auth_tag.len,
8533 "Generated auth tag not as expected");
8540 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8542 return test_authenticated_encryption_sessionless(
8547 test_authenticated_decryption_sessionless(
8548 const struct aead_test_data *tdata)
8550 struct crypto_testsuite_params *ts_params = &testsuite_params;
8551 struct crypto_unittest_params *ut_params = &unittest_params;
8555 uint8_t key[tdata->key.len + 1];
8557 /* This test is for AESNI MB and AESNI GCM PMDs only */
8558 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8559 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8560 (gbl_driver_id != rte_cryptodev_driver_id_get(
8561 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8564 /* not supported with CPU crypto */
8565 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8568 /* Verify the capabilities */
8569 struct rte_cryptodev_sym_capability_idx cap_idx;
8570 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8571 cap_idx.algo.aead = tdata->algo;
8572 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8576 /* alloc mbuf and set payload */
8577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8579 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8580 rte_pktmbuf_tailroom(ut_params->ibuf));
8582 /* Create AEAD operation */
8583 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8587 /* Create AEAD xform */
8588 memcpy(key, tdata->key.data, tdata->key.len);
8589 retval = create_aead_xform(ut_params->op,
8591 RTE_CRYPTO_AEAD_OP_DECRYPT,
8592 key, tdata->key.len,
8593 tdata->aad.len, tdata->auth_tag.len,
8598 ut_params->op->sym->m_src = ut_params->ibuf;
8600 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8601 RTE_CRYPTO_OP_SESSIONLESS,
8602 "crypto op session type not sessionless");
8604 /* Process crypto operation */
8605 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8606 ut_params->op), "failed to process sym crypto op");
8608 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8610 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8611 "crypto op status not success");
8613 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8614 ut_params->op->sym->cipher.data.offset);
8616 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8621 tdata->plaintext.data,
8622 tdata->plaintext.len,
8623 "Plaintext data not as expected");
8625 TEST_ASSERT_EQUAL(ut_params->op->status,
8626 RTE_CRYPTO_OP_STATUS_SUCCESS,
8627 "Authentication failed");
8632 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8634 return test_authenticated_decryption_sessionless(
8639 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8641 return test_authenticated_encryption(&ccm_test_case_128_1);
8645 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8647 return test_authenticated_encryption(&ccm_test_case_128_2);
8651 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8653 return test_authenticated_encryption(&ccm_test_case_128_3);
8657 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8659 return test_authenticated_decryption(&ccm_test_case_128_1);
8663 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8665 return test_authenticated_decryption(&ccm_test_case_128_2);
8669 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8671 return test_authenticated_decryption(&ccm_test_case_128_3);
8675 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8677 return test_authenticated_encryption(&ccm_test_case_192_1);
8681 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8683 return test_authenticated_encryption(&ccm_test_case_192_2);
8687 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8689 return test_authenticated_encryption(&ccm_test_case_192_3);
8693 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8695 return test_authenticated_decryption(&ccm_test_case_192_1);
8699 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8701 return test_authenticated_decryption(&ccm_test_case_192_2);
8705 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8707 return test_authenticated_decryption(&ccm_test_case_192_3);
8711 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8713 return test_authenticated_encryption(&ccm_test_case_256_1);
8717 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8719 return test_authenticated_encryption(&ccm_test_case_256_2);
8723 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8725 return test_authenticated_encryption(&ccm_test_case_256_3);
8729 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8731 return test_authenticated_decryption(&ccm_test_case_256_1);
8735 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8737 return test_authenticated_decryption(&ccm_test_case_256_2);
8741 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8743 return test_authenticated_decryption(&ccm_test_case_256_3);
8749 struct crypto_testsuite_params *ts_params = &testsuite_params;
8750 struct rte_cryptodev_stats stats;
8751 struct rte_cryptodev *dev;
8752 cryptodev_stats_get_t temp_pfn;
8754 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8757 /* Verify the capabilities */
8758 struct rte_cryptodev_sym_capability_idx cap_idx;
8759 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8760 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8761 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8764 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8765 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8766 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8770 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8771 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8772 &stats) == -ENODEV),
8773 "rte_cryptodev_stats_get invalid dev failed");
8774 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8775 "rte_cryptodev_stats_get invalid Param failed");
8776 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8777 temp_pfn = dev->dev_ops->stats_get;
8778 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8779 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8781 "rte_cryptodev_stats_get invalid Param failed");
8782 dev->dev_ops->stats_get = temp_pfn;
8784 /* Test expected values */
8786 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8788 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8790 "rte_cryptodev_stats_get failed");
8791 TEST_ASSERT((stats.enqueued_count == 1),
8792 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8793 TEST_ASSERT((stats.dequeued_count == 1),
8794 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8795 TEST_ASSERT((stats.enqueue_err_count == 0),
8796 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8797 TEST_ASSERT((stats.dequeue_err_count == 0),
8798 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8800 /* invalid device but should ignore and not reset device stats*/
8801 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8802 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8804 "rte_cryptodev_stats_get failed");
8805 TEST_ASSERT((stats.enqueued_count == 1),
8806 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8808 /* check that a valid reset clears stats */
8809 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8810 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8812 "rte_cryptodev_stats_get failed");
8813 TEST_ASSERT((stats.enqueued_count == 0),
8814 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8815 TEST_ASSERT((stats.dequeued_count == 0),
8816 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8818 return TEST_SUCCESS;
8821 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8822 struct crypto_unittest_params *ut_params,
8823 enum rte_crypto_auth_operation op,
8824 const struct HMAC_MD5_vector *test_case)
8828 memcpy(key, test_case->key.data, test_case->key.len);
8830 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8831 ut_params->auth_xform.next = NULL;
8832 ut_params->auth_xform.auth.op = op;
8834 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8836 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8837 ut_params->auth_xform.auth.key.length = test_case->key.len;
8838 ut_params->auth_xform.auth.key.data = key;
8840 ut_params->sess = rte_cryptodev_sym_session_create(
8841 ts_params->session_mpool);
8843 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8844 ut_params->sess, &ut_params->auth_xform,
8845 ts_params->session_priv_mpool);
8847 if (ut_params->sess == NULL)
8850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8853 rte_pktmbuf_tailroom(ut_params->ibuf));
8858 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8859 const struct HMAC_MD5_vector *test_case,
8860 uint8_t **plaintext)
8862 uint16_t plaintext_pad_len;
8864 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8866 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8869 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8871 memcpy(*plaintext, test_case->plaintext.data,
8872 test_case->plaintext.len);
8874 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8875 ut_params->ibuf, MD5_DIGEST_LEN);
8876 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8877 "no room to append digest");
8878 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8879 ut_params->ibuf, plaintext_pad_len);
8881 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8882 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8883 test_case->auth_tag.len);
8886 sym_op->auth.data.offset = 0;
8887 sym_op->auth.data.length = test_case->plaintext.len;
8889 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8890 ut_params->op->sym->m_src = ut_params->ibuf;
8896 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8898 uint16_t plaintext_pad_len;
8899 uint8_t *plaintext, *auth_tag;
8901 struct crypto_testsuite_params *ts_params = &testsuite_params;
8902 struct crypto_unittest_params *ut_params = &unittest_params;
8904 /* Verify the capabilities */
8905 struct rte_cryptodev_sym_capability_idx cap_idx;
8906 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8907 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8908 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8912 if (MD5_HMAC_create_session(ts_params, ut_params,
8913 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8916 /* Generate Crypto op data structure */
8917 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8918 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8919 TEST_ASSERT_NOT_NULL(ut_params->op,
8920 "Failed to allocate symmetric crypto operation struct");
8922 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8925 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8928 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8929 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8932 TEST_ASSERT_NOT_NULL(
8933 process_crypto_request(ts_params->valid_devs[0],
8935 "failed to process sym crypto op");
8937 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8938 "crypto op processing failed");
8940 if (ut_params->op->sym->m_dst) {
8941 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8942 uint8_t *, plaintext_pad_len);
8944 auth_tag = plaintext + plaintext_pad_len;
8947 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8949 test_case->auth_tag.data,
8950 test_case->auth_tag.len,
8951 "HMAC_MD5 generated tag not as expected");
8953 return TEST_SUCCESS;
8957 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8961 struct crypto_testsuite_params *ts_params = &testsuite_params;
8962 struct crypto_unittest_params *ut_params = &unittest_params;
8964 /* Verify the capabilities */
8965 struct rte_cryptodev_sym_capability_idx cap_idx;
8966 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8967 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8968 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8972 if (MD5_HMAC_create_session(ts_params, ut_params,
8973 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8977 /* Generate Crypto op data structure */
8978 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8979 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8980 TEST_ASSERT_NOT_NULL(ut_params->op,
8981 "Failed to allocate symmetric crypto operation struct");
8983 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8986 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8987 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8990 TEST_ASSERT_NOT_NULL(
8991 process_crypto_request(ts_params->valid_devs[0],
8993 "failed to process sym crypto op");
8995 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8996 "HMAC_MD5 crypto op processing failed");
8998 return TEST_SUCCESS;
9002 test_MD5_HMAC_generate_case_1(void)
9004 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9008 test_MD5_HMAC_verify_case_1(void)
9010 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9014 test_MD5_HMAC_generate_case_2(void)
9016 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9020 test_MD5_HMAC_verify_case_2(void)
9022 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9026 test_multi_session(void)
9028 struct crypto_testsuite_params *ts_params = &testsuite_params;
9029 struct crypto_unittest_params *ut_params = &unittest_params;
9031 struct rte_cryptodev_info dev_info;
9032 struct rte_cryptodev_sym_session **sessions;
9036 /* Verify the capabilities */
9037 struct rte_cryptodev_sym_capability_idx cap_idx;
9038 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9039 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9040 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9044 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9045 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9049 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9050 aes_cbc_key, hmac_sha512_key);
9053 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9055 sessions = rte_malloc(NULL,
9056 (sizeof(struct rte_cryptodev_sym_session *) *
9057 MAX_NB_SESSIONS) + 1, 0);
9059 /* Create multiple crypto sessions*/
9060 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9062 sessions[i] = rte_cryptodev_sym_session_create(
9063 ts_params->session_mpool);
9065 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9066 sessions[i], &ut_params->auth_xform,
9067 ts_params->session_priv_mpool);
9068 TEST_ASSERT_NOT_NULL(sessions[i],
9069 "Session creation failed at session number %u",
9072 /* Attempt to send a request on each session */
9073 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9077 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9078 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9080 "Failed to perform decrypt on request number %u.", i);
9081 /* free crypto operation structure */
9083 rte_crypto_op_free(ut_params->op);
9086 * free mbuf - both obuf and ibuf are usually the same,
9087 * so check if they point at the same address is necessary,
9088 * to avoid freeing the mbuf twice.
9090 if (ut_params->obuf) {
9091 rte_pktmbuf_free(ut_params->obuf);
9092 if (ut_params->ibuf == ut_params->obuf)
9093 ut_params->ibuf = 0;
9094 ut_params->obuf = 0;
9096 if (ut_params->ibuf) {
9097 rte_pktmbuf_free(ut_params->ibuf);
9098 ut_params->ibuf = 0;
9102 /* Next session create should fail */
9103 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9104 sessions[i], &ut_params->auth_xform,
9105 ts_params->session_priv_mpool);
9106 TEST_ASSERT_NULL(sessions[i],
9107 "Session creation succeeded unexpectedly!");
9109 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9110 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9112 rte_cryptodev_sym_session_free(sessions[i]);
9117 return TEST_SUCCESS;
9120 struct multi_session_params {
9121 struct crypto_unittest_params ut_params;
9122 uint8_t *cipher_key;
9124 const uint8_t *cipher;
9125 const uint8_t *digest;
9129 #define MB_SESSION_NUMBER 3
9132 test_multi_session_random_usage(void)
9134 struct crypto_testsuite_params *ts_params = &testsuite_params;
9135 struct rte_cryptodev_info dev_info;
9136 struct rte_cryptodev_sym_session **sessions;
9138 struct multi_session_params ut_paramz[] = {
9141 .cipher_key = ms_aes_cbc_key0,
9142 .hmac_key = ms_hmac_key0,
9143 .cipher = ms_aes_cbc_cipher0,
9144 .digest = ms_hmac_digest0,
9145 .iv = ms_aes_cbc_iv0
9148 .cipher_key = ms_aes_cbc_key1,
9149 .hmac_key = ms_hmac_key1,
9150 .cipher = ms_aes_cbc_cipher1,
9151 .digest = ms_hmac_digest1,
9152 .iv = ms_aes_cbc_iv1
9155 .cipher_key = ms_aes_cbc_key2,
9156 .hmac_key = ms_hmac_key2,
9157 .cipher = ms_aes_cbc_cipher2,
9158 .digest = ms_hmac_digest2,
9159 .iv = ms_aes_cbc_iv2
9164 /* Verify the capabilities */
9165 struct rte_cryptodev_sym_capability_idx cap_idx;
9166 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9167 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9168 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9171 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9172 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9173 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9177 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9179 sessions = rte_malloc(NULL,
9180 (sizeof(struct rte_cryptodev_sym_session *)
9181 * MAX_NB_SESSIONS) + 1, 0);
9183 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9184 sessions[i] = rte_cryptodev_sym_session_create(
9185 ts_params->session_mpool);
9187 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9188 sizeof(struct crypto_unittest_params));
9190 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9191 &ut_paramz[i].ut_params,
9192 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9194 /* Create multiple crypto sessions*/
9195 rte_cryptodev_sym_session_init(
9196 ts_params->valid_devs[0],
9198 &ut_paramz[i].ut_params.auth_xform,
9199 ts_params->session_priv_mpool);
9201 TEST_ASSERT_NOT_NULL(sessions[i],
9202 "Session creation failed at session number %u",
9208 for (i = 0; i < 40000; i++) {
9210 j = rand() % MB_SESSION_NUMBER;
9212 TEST_ASSERT_SUCCESS(
9213 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9215 &ut_paramz[j].ut_params,
9216 ts_params, ut_paramz[j].cipher,
9217 ut_paramz[j].digest,
9219 "Failed to perform decrypt on request number %u.", i);
9221 if (ut_paramz[j].ut_params.op)
9222 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9225 * free mbuf - both obuf and ibuf are usually the same,
9226 * so check if they point at the same address is necessary,
9227 * to avoid freeing the mbuf twice.
9229 if (ut_paramz[j].ut_params.obuf) {
9230 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9231 if (ut_paramz[j].ut_params.ibuf
9232 == ut_paramz[j].ut_params.obuf)
9233 ut_paramz[j].ut_params.ibuf = 0;
9234 ut_paramz[j].ut_params.obuf = 0;
9236 if (ut_paramz[j].ut_params.ibuf) {
9237 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9238 ut_paramz[j].ut_params.ibuf = 0;
9242 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9243 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9245 rte_cryptodev_sym_session_free(sessions[i]);
9250 return TEST_SUCCESS;
9254 test_null_cipher_only_operation(void)
9256 struct crypto_testsuite_params *ts_params = &testsuite_params;
9257 struct crypto_unittest_params *ut_params = &unittest_params;
9259 /* Verify the capabilities */
9260 struct rte_cryptodev_sym_capability_idx cap_idx;
9261 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9262 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9263 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9267 /* Generate test mbuf data and space for digest */
9268 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9269 catch_22_quote, QUOTE_512_BYTES, 0);
9271 /* Setup Cipher Parameters */
9272 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9273 ut_params->cipher_xform.next = NULL;
9275 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9276 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9278 ut_params->sess = rte_cryptodev_sym_session_create(
9279 ts_params->session_mpool);
9281 /* Create Crypto session*/
9282 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9284 &ut_params->cipher_xform,
9285 ts_params->session_priv_mpool);
9286 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9288 /* Generate Crypto op data structure */
9289 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9290 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9291 TEST_ASSERT_NOT_NULL(ut_params->op,
9292 "Failed to allocate symmetric crypto operation struct");
9294 /* Set crypto operation data parameters */
9295 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9297 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9299 /* set crypto operation source mbuf */
9300 sym_op->m_src = ut_params->ibuf;
9302 sym_op->cipher.data.offset = 0;
9303 sym_op->cipher.data.length = QUOTE_512_BYTES;
9305 /* Process crypto operation */
9306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9308 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9310 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9311 "crypto operation processing failed");
9314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9315 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9318 "Ciphertext data not as expected");
9320 return TEST_SUCCESS;
9322 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9323 0xab, 0xab, 0xab, 0xab,
9324 0xab, 0xab, 0xab, 0xab,
9325 0xab, 0xab, 0xab, 0xab};
9327 test_null_auth_only_operation(void)
9329 struct crypto_testsuite_params *ts_params = &testsuite_params;
9330 struct crypto_unittest_params *ut_params = &unittest_params;
9333 /* Verify the capabilities */
9334 struct rte_cryptodev_sym_capability_idx cap_idx;
9335 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9336 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9337 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9341 /* Generate test mbuf data and space for digest */
9342 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9343 catch_22_quote, QUOTE_512_BYTES, 0);
9345 /* create a pointer for digest, but don't expect anything to be written
9346 * here in a NULL auth algo so no mbuf append done.
9348 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9350 /* prefill the memory pointed to by digest */
9351 memcpy(digest, orig_data, sizeof(orig_data));
9353 /* Setup HMAC Parameters */
9354 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9355 ut_params->auth_xform.next = NULL;
9357 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9358 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9360 ut_params->sess = rte_cryptodev_sym_session_create(
9361 ts_params->session_mpool);
9363 /* Create Crypto session*/
9364 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9365 ut_params->sess, &ut_params->auth_xform,
9366 ts_params->session_priv_mpool);
9367 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9369 /* Generate Crypto op data structure */
9370 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9371 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9372 TEST_ASSERT_NOT_NULL(ut_params->op,
9373 "Failed to allocate symmetric crypto operation struct");
9375 /* Set crypto operation data parameters */
9376 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9378 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9380 sym_op->m_src = ut_params->ibuf;
9382 sym_op->auth.data.offset = 0;
9383 sym_op->auth.data.length = QUOTE_512_BYTES;
9384 sym_op->auth.digest.data = digest;
9385 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9388 /* Process crypto operation */
9389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9391 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9393 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9394 "crypto operation processing failed");
9395 /* Make sure memory pointed to by digest hasn't been overwritten */
9396 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9400 "Memory at digest ptr overwritten unexpectedly");
9402 return TEST_SUCCESS;
9407 test_null_cipher_auth_operation(void)
9409 struct crypto_testsuite_params *ts_params = &testsuite_params;
9410 struct crypto_unittest_params *ut_params = &unittest_params;
9413 /* Verify the capabilities */
9414 struct rte_cryptodev_sym_capability_idx cap_idx;
9415 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9416 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9417 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9420 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9421 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9422 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9426 /* Generate test mbuf data and space for digest */
9427 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9428 catch_22_quote, QUOTE_512_BYTES, 0);
9430 /* create a pointer for digest, but don't expect anything to be written
9431 * here in a NULL auth algo so no mbuf append done.
9433 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9435 /* prefill the memory pointed to by digest */
9436 memcpy(digest, orig_data, sizeof(orig_data));
9438 /* Setup Cipher Parameters */
9439 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9440 ut_params->cipher_xform.next = &ut_params->auth_xform;
9442 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9443 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9445 /* Setup HMAC Parameters */
9446 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9447 ut_params->auth_xform.next = NULL;
9449 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9450 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9452 ut_params->sess = rte_cryptodev_sym_session_create(
9453 ts_params->session_mpool);
9455 /* Create Crypto session*/
9456 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9457 ut_params->sess, &ut_params->cipher_xform,
9458 ts_params->session_priv_mpool);
9459 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9461 /* Generate Crypto op data structure */
9462 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9463 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9464 TEST_ASSERT_NOT_NULL(ut_params->op,
9465 "Failed to allocate symmetric crypto operation struct");
9467 /* Set crypto operation data parameters */
9468 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9470 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9472 sym_op->m_src = ut_params->ibuf;
9474 sym_op->cipher.data.offset = 0;
9475 sym_op->cipher.data.length = QUOTE_512_BYTES;
9477 sym_op->auth.data.offset = 0;
9478 sym_op->auth.data.length = QUOTE_512_BYTES;
9479 sym_op->auth.digest.data = digest;
9480 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9483 /* Process crypto operation */
9484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9486 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9488 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9489 "crypto operation processing failed");
9492 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9493 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9496 "Ciphertext data not as expected");
9497 /* Make sure memory pointed to by digest hasn't been overwritten */
9498 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9502 "Memory at digest ptr overwritten unexpectedly");
9504 return TEST_SUCCESS;
9508 test_null_auth_cipher_operation(void)
9510 struct crypto_testsuite_params *ts_params = &testsuite_params;
9511 struct crypto_unittest_params *ut_params = &unittest_params;
9514 /* Verify the capabilities */
9515 struct rte_cryptodev_sym_capability_idx cap_idx;
9516 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9517 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9518 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9521 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9522 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9523 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9527 /* Generate test mbuf data */
9528 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9529 catch_22_quote, QUOTE_512_BYTES, 0);
9531 /* create a pointer for digest, but don't expect anything to be written
9532 * here in a NULL auth algo so no mbuf append done.
9534 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9536 /* prefill the memory pointed to by digest */
9537 memcpy(digest, orig_data, sizeof(orig_data));
9539 /* Setup Cipher Parameters */
9540 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9541 ut_params->cipher_xform.next = NULL;
9543 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9544 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9546 /* Setup HMAC Parameters */
9547 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9548 ut_params->auth_xform.next = &ut_params->cipher_xform;
9550 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9551 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9553 ut_params->sess = rte_cryptodev_sym_session_create(
9554 ts_params->session_mpool);
9556 /* Create Crypto session*/
9557 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9558 ut_params->sess, &ut_params->cipher_xform,
9559 ts_params->session_priv_mpool);
9560 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9562 /* Generate Crypto op data structure */
9563 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9564 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9565 TEST_ASSERT_NOT_NULL(ut_params->op,
9566 "Failed to allocate symmetric crypto operation struct");
9568 /* Set crypto operation data parameters */
9569 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9571 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9573 sym_op->m_src = ut_params->ibuf;
9575 sym_op->cipher.data.offset = 0;
9576 sym_op->cipher.data.length = QUOTE_512_BYTES;
9578 sym_op->auth.data.offset = 0;
9579 sym_op->auth.data.length = QUOTE_512_BYTES;
9580 sym_op->auth.digest.data = digest;
9581 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9584 /* Process crypto operation */
9585 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9587 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9589 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9590 "crypto operation processing failed");
9593 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9594 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9597 "Ciphertext data not as expected");
9598 /* Make sure memory pointed to by digest hasn't been overwritten */
9599 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9603 "Memory at digest ptr overwritten unexpectedly");
9605 return TEST_SUCCESS;
9610 test_null_invalid_operation(void)
9612 struct crypto_testsuite_params *ts_params = &testsuite_params;
9613 struct crypto_unittest_params *ut_params = &unittest_params;
9616 /* This test is for NULL PMD only */
9617 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9618 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9621 /* Setup Cipher Parameters */
9622 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9623 ut_params->cipher_xform.next = NULL;
9625 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9626 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9628 ut_params->sess = rte_cryptodev_sym_session_create(
9629 ts_params->session_mpool);
9631 /* Create Crypto session*/
9632 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9633 ut_params->sess, &ut_params->cipher_xform,
9634 ts_params->session_priv_mpool);
9635 TEST_ASSERT(ret < 0,
9636 "Session creation succeeded unexpectedly");
9639 /* Setup HMAC Parameters */
9640 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9641 ut_params->auth_xform.next = NULL;
9643 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9644 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9646 ut_params->sess = rte_cryptodev_sym_session_create(
9647 ts_params->session_mpool);
9649 /* Create Crypto session*/
9650 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9651 ut_params->sess, &ut_params->auth_xform,
9652 ts_params->session_priv_mpool);
9653 TEST_ASSERT(ret < 0,
9654 "Session creation succeeded unexpectedly");
9656 return TEST_SUCCESS;
9660 #define NULL_BURST_LENGTH (32)
9663 test_null_burst_operation(void)
9665 struct crypto_testsuite_params *ts_params = &testsuite_params;
9666 struct crypto_unittest_params *ut_params = &unittest_params;
9668 unsigned i, burst_len = NULL_BURST_LENGTH;
9670 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9671 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9673 /* This test is for NULL PMD only */
9674 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9675 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9678 /* Setup Cipher Parameters */
9679 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9680 ut_params->cipher_xform.next = &ut_params->auth_xform;
9682 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9683 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9685 /* Setup HMAC Parameters */
9686 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9687 ut_params->auth_xform.next = NULL;
9689 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9690 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9692 ut_params->sess = rte_cryptodev_sym_session_create(
9693 ts_params->session_mpool);
9695 /* Create Crypto session*/
9696 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9697 ut_params->sess, &ut_params->cipher_xform,
9698 ts_params->session_priv_mpool);
9699 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9701 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9702 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9703 burst_len, "failed to generate burst of crypto ops");
9705 /* Generate an operation for each mbuf in burst */
9706 for (i = 0; i < burst_len; i++) {
9707 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9709 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9711 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9715 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9717 burst[i]->sym->m_src = m;
9720 /* Process crypto operation */
9721 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9722 0, burst, burst_len),
9724 "Error enqueuing burst");
9726 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9727 0, burst_dequeued, burst_len),
9729 "Error dequeuing burst");
9732 for (i = 0; i < burst_len; i++) {
9734 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9735 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9737 "data not as expected");
9739 rte_pktmbuf_free(burst[i]->sym->m_src);
9740 rte_crypto_op_free(burst[i]);
9743 return TEST_SUCCESS;
9747 generate_gmac_large_plaintext(uint8_t *data)
9751 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9752 memcpy(&data[i], &data[0], 32);
9756 create_gmac_operation(enum rte_crypto_auth_operation op,
9757 const struct gmac_test_data *tdata)
9759 struct crypto_testsuite_params *ts_params = &testsuite_params;
9760 struct crypto_unittest_params *ut_params = &unittest_params;
9761 struct rte_crypto_sym_op *sym_op;
9763 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9765 /* Generate Crypto op data structure */
9766 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9767 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9768 TEST_ASSERT_NOT_NULL(ut_params->op,
9769 "Failed to allocate symmetric crypto operation struct");
9771 sym_op = ut_params->op->sym;
9773 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9774 ut_params->ibuf, tdata->gmac_tag.len);
9775 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9776 "no room to append digest");
9778 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9779 ut_params->ibuf, plaintext_pad_len);
9781 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9782 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9783 tdata->gmac_tag.len);
9784 debug_hexdump(stdout, "digest:",
9785 sym_op->auth.digest.data,
9786 tdata->gmac_tag.len);
9789 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9790 uint8_t *, IV_OFFSET);
9792 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9794 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9796 sym_op->cipher.data.length = 0;
9797 sym_op->cipher.data.offset = 0;
9799 sym_op->auth.data.offset = 0;
9800 sym_op->auth.data.length = tdata->plaintext.len;
9805 static int create_gmac_session(uint8_t dev_id,
9806 const struct gmac_test_data *tdata,
9807 enum rte_crypto_auth_operation auth_op)
9809 uint8_t auth_key[tdata->key.len];
9811 struct crypto_testsuite_params *ts_params = &testsuite_params;
9812 struct crypto_unittest_params *ut_params = &unittest_params;
9814 memcpy(auth_key, tdata->key.data, tdata->key.len);
9816 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9817 ut_params->auth_xform.next = NULL;
9819 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9820 ut_params->auth_xform.auth.op = auth_op;
9821 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9822 ut_params->auth_xform.auth.key.length = tdata->key.len;
9823 ut_params->auth_xform.auth.key.data = auth_key;
9824 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9825 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9828 ut_params->sess = rte_cryptodev_sym_session_create(
9829 ts_params->session_mpool);
9831 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9832 &ut_params->auth_xform,
9833 ts_params->session_priv_mpool);
9835 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9841 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9843 struct crypto_testsuite_params *ts_params = &testsuite_params;
9844 struct crypto_unittest_params *ut_params = &unittest_params;
9848 uint8_t *auth_tag, *plaintext;
9849 uint16_t plaintext_pad_len;
9851 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9852 "No GMAC length in the source data");
9854 /* Verify the capabilities */
9855 struct rte_cryptodev_sym_capability_idx cap_idx;
9856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9857 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9862 retval = create_gmac_session(ts_params->valid_devs[0],
9863 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9868 if (tdata->plaintext.len > MBUF_SIZE)
9869 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9872 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9873 "Failed to allocate input buffer in mempool");
9875 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9876 rte_pktmbuf_tailroom(ut_params->ibuf));
9878 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9880 * Runtime generate the large plain text instead of use hard code
9881 * plain text vector. It is done to avoid create huge source file
9882 * with the test vector.
9884 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9885 generate_gmac_large_plaintext(tdata->plaintext.data);
9887 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9889 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9891 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9892 debug_hexdump(stdout, "plaintext:", plaintext,
9893 tdata->plaintext.len);
9895 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9903 ut_params->op->sym->m_src = ut_params->ibuf;
9905 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9906 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9909 TEST_ASSERT_NOT_NULL(
9910 process_crypto_request(ts_params->valid_devs[0],
9911 ut_params->op), "failed to process sym crypto op");
9913 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9914 "crypto op processing failed");
9916 if (ut_params->op->sym->m_dst) {
9917 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9918 uint8_t *, plaintext_pad_len);
9920 auth_tag = plaintext + plaintext_pad_len;
9923 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9925 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9927 tdata->gmac_tag.data,
9928 tdata->gmac_tag.len,
9929 "GMAC Generated auth tag not as expected");
9935 test_AES_GMAC_authentication_test_case_1(void)
9937 return test_AES_GMAC_authentication(&gmac_test_case_1);
9941 test_AES_GMAC_authentication_test_case_2(void)
9943 return test_AES_GMAC_authentication(&gmac_test_case_2);
9947 test_AES_GMAC_authentication_test_case_3(void)
9949 return test_AES_GMAC_authentication(&gmac_test_case_3);
9953 test_AES_GMAC_authentication_test_case_4(void)
9955 return test_AES_GMAC_authentication(&gmac_test_case_4);
9959 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9961 struct crypto_testsuite_params *ts_params = &testsuite_params;
9962 struct crypto_unittest_params *ut_params = &unittest_params;
9964 uint32_t plaintext_pad_len;
9967 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9968 "No GMAC length in the source data");
9970 /* Verify the capabilities */
9971 struct rte_cryptodev_sym_capability_idx cap_idx;
9972 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9973 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9974 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9978 retval = create_gmac_session(ts_params->valid_devs[0],
9979 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9984 if (tdata->plaintext.len > MBUF_SIZE)
9985 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9987 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9988 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9989 "Failed to allocate input buffer in mempool");
9991 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9992 rte_pktmbuf_tailroom(ut_params->ibuf));
9994 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9997 * Runtime generate the large plain text instead of use hard code
9998 * plain text vector. It is done to avoid create huge source file
9999 * with the test vector.
10001 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10002 generate_gmac_large_plaintext(tdata->plaintext.data);
10004 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10005 plaintext_pad_len);
10006 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10008 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10009 debug_hexdump(stdout, "plaintext:", plaintext,
10010 tdata->plaintext.len);
10012 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10018 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10020 ut_params->op->sym->m_src = ut_params->ibuf;
10022 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10023 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10026 TEST_ASSERT_NOT_NULL(
10027 process_crypto_request(ts_params->valid_devs[0],
10028 ut_params->op), "failed to process sym crypto op");
10030 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10031 "crypto op processing failed");
10038 test_AES_GMAC_authentication_verify_test_case_1(void)
10040 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10044 test_AES_GMAC_authentication_verify_test_case_2(void)
10046 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10050 test_AES_GMAC_authentication_verify_test_case_3(void)
10052 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10056 test_AES_GMAC_authentication_verify_test_case_4(void)
10058 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10061 struct test_crypto_vector {
10062 enum rte_crypto_cipher_algorithm crypto_algo;
10063 unsigned int cipher_offset;
10064 unsigned int cipher_len;
10077 const uint8_t *data;
10082 const uint8_t *data;
10086 enum rte_crypto_auth_algorithm auth_algo;
10087 unsigned int auth_offset;
10095 const uint8_t *data;
10105 static const struct test_crypto_vector
10106 hmac_sha1_test_crypto_vector = {
10107 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10109 .data = plaintext_hash,
10114 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10115 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10116 0xDE, 0xF4, 0xDE, 0xAD
10122 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10123 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10124 0x3F, 0x91, 0x64, 0x59
10130 static const struct test_crypto_vector
10131 aes128_gmac_test_vector = {
10132 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10134 .data = plaintext_hash,
10139 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10140 0x08, 0x09, 0x0A, 0x0B
10146 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10147 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10153 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10154 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10160 static const struct test_crypto_vector
10161 aes128cbc_hmac_sha1_test_vector = {
10162 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10163 .cipher_offset = 0,
10167 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10168 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10174 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10175 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10180 .data = plaintext_hash,
10184 .data = ciphertext512_aes128cbc,
10187 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10191 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10192 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10193 0xDE, 0xF4, 0xDE, 0xAD
10199 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10200 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10201 0x18, 0x8C, 0x1D, 0x32
10207 static const struct test_crypto_vector
10208 aes128cbc_hmac_sha1_aad_test_vector = {
10209 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10210 .cipher_offset = 12,
10214 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10215 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10221 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10222 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10227 .data = plaintext_hash,
10231 .data = ciphertext512_aes128cbc_aad,
10234 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10238 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10239 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10240 0xDE, 0xF4, 0xDE, 0xAD
10246 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10247 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10248 0x62, 0x8D, 0x62, 0x65
10255 data_corruption(uint8_t *data)
10261 tag_corruption(uint8_t *data, unsigned int tag_offset)
10263 data[tag_offset] += 1;
10267 create_auth_session(struct crypto_unittest_params *ut_params,
10269 const struct test_crypto_vector *reference,
10270 enum rte_crypto_auth_operation auth_op)
10272 struct crypto_testsuite_params *ts_params = &testsuite_params;
10273 uint8_t auth_key[reference->auth_key.len + 1];
10275 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10277 /* Setup Authentication Parameters */
10278 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10279 ut_params->auth_xform.auth.op = auth_op;
10280 ut_params->auth_xform.next = NULL;
10281 ut_params->auth_xform.auth.algo = reference->auth_algo;
10282 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10283 ut_params->auth_xform.auth.key.data = auth_key;
10284 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10286 /* Create Crypto session*/
10287 ut_params->sess = rte_cryptodev_sym_session_create(
10288 ts_params->session_mpool);
10290 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10291 &ut_params->auth_xform,
10292 ts_params->session_priv_mpool);
10294 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10300 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10302 const struct test_crypto_vector *reference,
10303 enum rte_crypto_auth_operation auth_op,
10304 enum rte_crypto_cipher_operation cipher_op)
10306 struct crypto_testsuite_params *ts_params = &testsuite_params;
10307 uint8_t cipher_key[reference->cipher_key.len + 1];
10308 uint8_t auth_key[reference->auth_key.len + 1];
10310 memcpy(cipher_key, reference->cipher_key.data,
10311 reference->cipher_key.len);
10312 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10314 /* Setup Authentication Parameters */
10315 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10316 ut_params->auth_xform.auth.op = auth_op;
10317 ut_params->auth_xform.auth.algo = reference->auth_algo;
10318 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10319 ut_params->auth_xform.auth.key.data = auth_key;
10320 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10322 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10323 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10324 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10326 ut_params->auth_xform.next = &ut_params->cipher_xform;
10328 /* Setup Cipher Parameters */
10329 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10330 ut_params->cipher_xform.next = NULL;
10331 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10332 ut_params->cipher_xform.cipher.op = cipher_op;
10333 ut_params->cipher_xform.cipher.key.data = cipher_key;
10334 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10335 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10336 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10339 /* Create Crypto session*/
10340 ut_params->sess = rte_cryptodev_sym_session_create(
10341 ts_params->session_mpool);
10343 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10344 &ut_params->auth_xform,
10345 ts_params->session_priv_mpool);
10347 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10353 create_auth_operation(struct crypto_testsuite_params *ts_params,
10354 struct crypto_unittest_params *ut_params,
10355 const struct test_crypto_vector *reference,
10356 unsigned int auth_generate)
10358 /* Generate Crypto op data structure */
10359 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10360 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10361 TEST_ASSERT_NOT_NULL(ut_params->op,
10362 "Failed to allocate pktmbuf offload");
10364 /* Set crypto operation data parameters */
10365 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10367 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10369 /* set crypto operation source mbuf */
10370 sym_op->m_src = ut_params->ibuf;
10373 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10374 ut_params->ibuf, reference->digest.len);
10376 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10377 "no room to append auth tag");
10379 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10380 ut_params->ibuf, reference->plaintext.len);
10383 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10385 memcpy(sym_op->auth.digest.data,
10386 reference->digest.data,
10387 reference->digest.len);
10389 debug_hexdump(stdout, "digest:",
10390 sym_op->auth.digest.data,
10391 reference->digest.len);
10393 sym_op->auth.data.length = reference->plaintext.len;
10394 sym_op->auth.data.offset = 0;
10400 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10401 struct crypto_unittest_params *ut_params,
10402 const struct test_crypto_vector *reference,
10403 unsigned int auth_generate)
10405 /* Generate Crypto op data structure */
10406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10408 TEST_ASSERT_NOT_NULL(ut_params->op,
10409 "Failed to allocate pktmbuf offload");
10411 /* Set crypto operation data parameters */
10412 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10414 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10416 /* set crypto operation source mbuf */
10417 sym_op->m_src = ut_params->ibuf;
10420 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10421 ut_params->ibuf, reference->digest.len);
10423 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10424 "no room to append auth tag");
10426 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10427 ut_params->ibuf, reference->ciphertext.len);
10430 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10432 memcpy(sym_op->auth.digest.data,
10433 reference->digest.data,
10434 reference->digest.len);
10436 debug_hexdump(stdout, "digest:",
10437 sym_op->auth.digest.data,
10438 reference->digest.len);
10440 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10441 reference->iv.data, reference->iv.len);
10443 sym_op->cipher.data.length = 0;
10444 sym_op->cipher.data.offset = 0;
10446 sym_op->auth.data.length = reference->plaintext.len;
10447 sym_op->auth.data.offset = 0;
10453 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10454 struct crypto_unittest_params *ut_params,
10455 const struct test_crypto_vector *reference,
10456 unsigned int auth_generate)
10458 /* Generate Crypto op data structure */
10459 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10460 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10461 TEST_ASSERT_NOT_NULL(ut_params->op,
10462 "Failed to allocate pktmbuf offload");
10464 /* Set crypto operation data parameters */
10465 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10467 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10469 /* set crypto operation source mbuf */
10470 sym_op->m_src = ut_params->ibuf;
10473 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10474 ut_params->ibuf, reference->digest.len);
10476 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10477 "no room to append auth tag");
10479 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10480 ut_params->ibuf, reference->ciphertext.len);
10483 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10485 memcpy(sym_op->auth.digest.data,
10486 reference->digest.data,
10487 reference->digest.len);
10489 debug_hexdump(stdout, "digest:",
10490 sym_op->auth.digest.data,
10491 reference->digest.len);
10493 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10494 reference->iv.data, reference->iv.len);
10496 sym_op->cipher.data.length = reference->cipher_len;
10497 sym_op->cipher.data.offset = reference->cipher_offset;
10499 sym_op->auth.data.length = reference->plaintext.len;
10500 sym_op->auth.data.offset = reference->auth_offset;
10506 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10507 struct crypto_unittest_params *ut_params,
10508 const struct test_crypto_vector *reference)
10510 return create_auth_operation(ts_params, ut_params, reference, 0);
10514 create_auth_verify_GMAC_operation(
10515 struct crypto_testsuite_params *ts_params,
10516 struct crypto_unittest_params *ut_params,
10517 const struct test_crypto_vector *reference)
10519 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10523 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10524 struct crypto_unittest_params *ut_params,
10525 const struct test_crypto_vector *reference)
10527 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10531 test_authentication_verify_fail_when_data_corruption(
10532 struct crypto_testsuite_params *ts_params,
10533 struct crypto_unittest_params *ut_params,
10534 const struct test_crypto_vector *reference,
10535 unsigned int data_corrupted)
10539 uint8_t *plaintext;
10541 /* Verify the capabilities */
10542 struct rte_cryptodev_sym_capability_idx cap_idx;
10543 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10544 cap_idx.algo.auth = reference->auth_algo;
10545 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10549 /* Create session */
10550 retval = create_auth_session(ut_params,
10551 ts_params->valid_devs[0],
10553 RTE_CRYPTO_AUTH_OP_VERIFY);
10557 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10558 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10559 "Failed to allocate input buffer in mempool");
10561 /* clear mbuf payload */
10562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10563 rte_pktmbuf_tailroom(ut_params->ibuf));
10565 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10566 reference->plaintext.len);
10567 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10568 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10570 debug_hexdump(stdout, "plaintext:", plaintext,
10571 reference->plaintext.len);
10573 /* Create operation */
10574 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10579 if (data_corrupted)
10580 data_corruption(plaintext);
10582 tag_corruption(plaintext, reference->plaintext.len);
10584 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10585 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10587 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10588 RTE_CRYPTO_OP_STATUS_SUCCESS,
10589 "authentication not failed");
10591 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10593 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10600 test_authentication_verify_GMAC_fail_when_corruption(
10601 struct crypto_testsuite_params *ts_params,
10602 struct crypto_unittest_params *ut_params,
10603 const struct test_crypto_vector *reference,
10604 unsigned int data_corrupted)
10607 uint8_t *plaintext;
10609 /* Verify the capabilities */
10610 struct rte_cryptodev_sym_capability_idx cap_idx;
10611 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10612 cap_idx.algo.auth = reference->auth_algo;
10613 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10617 /* Create session */
10618 retval = create_auth_cipher_session(ut_params,
10619 ts_params->valid_devs[0],
10621 RTE_CRYPTO_AUTH_OP_VERIFY,
10622 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10626 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10627 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10628 "Failed to allocate input buffer in mempool");
10630 /* clear mbuf payload */
10631 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10632 rte_pktmbuf_tailroom(ut_params->ibuf));
10634 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10635 reference->plaintext.len);
10636 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10637 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10639 debug_hexdump(stdout, "plaintext:", plaintext,
10640 reference->plaintext.len);
10642 /* Create operation */
10643 retval = create_auth_verify_GMAC_operation(ts_params,
10650 if (data_corrupted)
10651 data_corruption(plaintext);
10653 tag_corruption(plaintext, reference->aad.len);
10655 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10656 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10658 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10659 RTE_CRYPTO_OP_STATUS_SUCCESS,
10660 "authentication not failed");
10662 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10664 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10671 test_authenticated_decryption_fail_when_corruption(
10672 struct crypto_testsuite_params *ts_params,
10673 struct crypto_unittest_params *ut_params,
10674 const struct test_crypto_vector *reference,
10675 unsigned int data_corrupted)
10679 uint8_t *ciphertext;
10681 /* Verify the capabilities */
10682 struct rte_cryptodev_sym_capability_idx cap_idx;
10683 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10684 cap_idx.algo.auth = reference->auth_algo;
10685 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10689 cap_idx.algo.cipher = reference->crypto_algo;
10690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10694 /* Create session */
10695 retval = create_auth_cipher_session(ut_params,
10696 ts_params->valid_devs[0],
10698 RTE_CRYPTO_AUTH_OP_VERIFY,
10699 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10704 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10705 "Failed to allocate input buffer in mempool");
10707 /* clear mbuf payload */
10708 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10709 rte_pktmbuf_tailroom(ut_params->ibuf));
10711 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10712 reference->ciphertext.len);
10713 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10714 memcpy(ciphertext, reference->ciphertext.data,
10715 reference->ciphertext.len);
10717 /* Create operation */
10718 retval = create_cipher_auth_verify_operation(ts_params,
10725 if (data_corrupted)
10726 data_corruption(ciphertext);
10728 tag_corruption(ciphertext, reference->ciphertext.len);
10730 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10731 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10733 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10734 RTE_CRYPTO_OP_STATUS_SUCCESS,
10735 "authentication not failed");
10737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10739 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10746 test_authenticated_encryt_with_esn(
10747 struct crypto_testsuite_params *ts_params,
10748 struct crypto_unittest_params *ut_params,
10749 const struct test_crypto_vector *reference)
10753 uint8_t *authciphertext, *plaintext, *auth_tag;
10754 uint16_t plaintext_pad_len;
10755 uint8_t cipher_key[reference->cipher_key.len + 1];
10756 uint8_t auth_key[reference->auth_key.len + 1];
10758 /* Verify the capabilities */
10759 struct rte_cryptodev_sym_capability_idx cap_idx;
10760 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10761 cap_idx.algo.auth = reference->auth_algo;
10762 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10765 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10766 cap_idx.algo.cipher = reference->crypto_algo;
10767 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10771 /* Create session */
10772 memcpy(cipher_key, reference->cipher_key.data,
10773 reference->cipher_key.len);
10774 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10776 /* Setup Cipher Parameters */
10777 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10778 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10779 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10780 ut_params->cipher_xform.cipher.key.data = cipher_key;
10781 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10782 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10783 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10785 ut_params->cipher_xform.next = &ut_params->auth_xform;
10787 /* Setup Authentication Parameters */
10788 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10789 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10790 ut_params->auth_xform.auth.algo = reference->auth_algo;
10791 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10792 ut_params->auth_xform.auth.key.data = auth_key;
10793 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10794 ut_params->auth_xform.next = NULL;
10796 /* Create Crypto session*/
10797 ut_params->sess = rte_cryptodev_sym_session_create(
10798 ts_params->session_mpool);
10800 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10802 &ut_params->cipher_xform,
10803 ts_params->session_priv_mpool);
10805 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10807 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10808 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10809 "Failed to allocate input buffer in mempool");
10811 /* clear mbuf payload */
10812 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10813 rte_pktmbuf_tailroom(ut_params->ibuf));
10815 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10816 reference->plaintext.len);
10817 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10818 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10820 /* Create operation */
10821 retval = create_cipher_auth_operation(ts_params,
10828 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10829 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10832 ut_params->op = process_crypto_request(
10833 ts_params->valid_devs[0], ut_params->op);
10835 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10837 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10838 "crypto op processing failed");
10840 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10842 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10843 ut_params->op->sym->auth.data.offset);
10844 auth_tag = authciphertext + plaintext_pad_len;
10845 debug_hexdump(stdout, "ciphertext:", authciphertext,
10846 reference->ciphertext.len);
10847 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10849 /* Validate obuf */
10850 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10852 reference->ciphertext.data,
10853 reference->ciphertext.len,
10854 "Ciphertext data not as expected");
10856 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10858 reference->digest.data,
10859 reference->digest.len,
10860 "Generated digest not as expected");
10862 return TEST_SUCCESS;
10867 test_authenticated_decrypt_with_esn(
10868 struct crypto_testsuite_params *ts_params,
10869 struct crypto_unittest_params *ut_params,
10870 const struct test_crypto_vector *reference)
10874 uint8_t *ciphertext;
10875 uint8_t cipher_key[reference->cipher_key.len + 1];
10876 uint8_t auth_key[reference->auth_key.len + 1];
10878 /* Verify the capabilities */
10879 struct rte_cryptodev_sym_capability_idx cap_idx;
10880 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10881 cap_idx.algo.auth = reference->auth_algo;
10882 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10886 cap_idx.algo.cipher = reference->crypto_algo;
10887 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10891 /* Create session */
10892 memcpy(cipher_key, reference->cipher_key.data,
10893 reference->cipher_key.len);
10894 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10896 /* Setup Authentication Parameters */
10897 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10898 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10899 ut_params->auth_xform.auth.algo = reference->auth_algo;
10900 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10901 ut_params->auth_xform.auth.key.data = auth_key;
10902 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10903 ut_params->auth_xform.next = &ut_params->cipher_xform;
10905 /* Setup Cipher Parameters */
10906 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10907 ut_params->cipher_xform.next = NULL;
10908 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10909 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10910 ut_params->cipher_xform.cipher.key.data = cipher_key;
10911 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10912 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10913 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10915 /* Create Crypto session*/
10916 ut_params->sess = rte_cryptodev_sym_session_create(
10917 ts_params->session_mpool);
10919 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10921 &ut_params->auth_xform,
10922 ts_params->session_priv_mpool);
10924 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10926 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10927 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10928 "Failed to allocate input buffer in mempool");
10930 /* clear mbuf payload */
10931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10932 rte_pktmbuf_tailroom(ut_params->ibuf));
10934 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10935 reference->ciphertext.len);
10936 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10937 memcpy(ciphertext, reference->ciphertext.data,
10938 reference->ciphertext.len);
10940 /* Create operation */
10941 retval = create_cipher_auth_verify_operation(ts_params,
10948 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10949 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10956 TEST_ASSERT_EQUAL(ut_params->op->status,
10957 RTE_CRYPTO_OP_STATUS_SUCCESS,
10958 "crypto op processing passed");
10960 ut_params->obuf = ut_params->op->sym->m_src;
10961 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10967 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10968 const struct aead_test_data *tdata,
10969 void *digest_mem, uint64_t digest_phys)
10971 struct crypto_testsuite_params *ts_params = &testsuite_params;
10972 struct crypto_unittest_params *ut_params = &unittest_params;
10974 const unsigned int auth_tag_len = tdata->auth_tag.len;
10975 const unsigned int iv_len = tdata->iv.len;
10976 unsigned int aad_len = tdata->aad.len;
10977 unsigned int aad_len_pad = 0;
10979 /* Generate Crypto op data structure */
10980 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10981 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10982 TEST_ASSERT_NOT_NULL(ut_params->op,
10983 "Failed to allocate symmetric crypto operation struct");
10985 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10987 sym_op->aead.digest.data = digest_mem;
10989 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10990 "no room to append digest");
10992 sym_op->aead.digest.phys_addr = digest_phys;
10994 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10995 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10997 debug_hexdump(stdout, "digest:",
10998 sym_op->aead.digest.data,
11002 /* Append aad data */
11003 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11004 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11005 uint8_t *, IV_OFFSET);
11007 /* Copy IV 1 byte after the IV pointer, according to the API */
11008 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11010 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11012 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11013 ut_params->ibuf, aad_len);
11014 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11015 "no room to prepend aad");
11016 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11019 memset(sym_op->aead.aad.data, 0, aad_len);
11020 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11021 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11023 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11024 debug_hexdump(stdout, "aad:",
11025 sym_op->aead.aad.data, aad_len);
11027 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11028 uint8_t *, IV_OFFSET);
11030 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11032 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11034 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11035 ut_params->ibuf, aad_len_pad);
11036 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11037 "no room to prepend aad");
11038 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11041 memset(sym_op->aead.aad.data, 0, aad_len);
11042 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11044 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11045 debug_hexdump(stdout, "aad:",
11046 sym_op->aead.aad.data, aad_len);
11049 sym_op->aead.data.length = tdata->plaintext.len;
11050 sym_op->aead.data.offset = aad_len_pad;
11055 #define SGL_MAX_NO 16
11058 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11059 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11061 struct crypto_testsuite_params *ts_params = &testsuite_params;
11062 struct crypto_unittest_params *ut_params = &unittest_params;
11063 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11066 int to_trn_tbl[SGL_MAX_NO];
11068 unsigned int trn_data = 0;
11069 uint8_t *plaintext, *ciphertext, *auth_tag;
11070 struct rte_cryptodev_info dev_info;
11072 /* Verify the capabilities */
11073 struct rte_cryptodev_sym_capability_idx cap_idx;
11074 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11075 cap_idx.algo.aead = tdata->algo;
11076 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11080 /* OOP not supported with CPU crypto */
11081 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11084 /* Detailed check for the particular SGL support flag */
11085 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11087 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11088 if (sgl_in && (!(dev_info.feature_flags &
11089 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11092 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11093 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11094 tdata->plaintext.len;
11095 if (sgl_in && !sgl_out) {
11096 if (!(dev_info.feature_flags &
11097 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11099 } else if (!sgl_in && sgl_out) {
11100 if (!(dev_info.feature_flags &
11101 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11103 } else if (sgl_in && sgl_out) {
11104 if (!(dev_info.feature_flags &
11105 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11110 if (fragsz > tdata->plaintext.len)
11111 fragsz = tdata->plaintext.len;
11113 uint16_t plaintext_len = fragsz;
11114 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11116 if (fragsz_oop > tdata->plaintext.len)
11117 frag_size_oop = tdata->plaintext.len;
11120 void *digest_mem = NULL;
11122 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11124 if (tdata->plaintext.len % fragsz != 0) {
11125 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11128 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11133 * For out-op-place we need to alloc another mbuf
11136 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11137 rte_pktmbuf_append(ut_params->obuf,
11138 frag_size_oop + prepend_len);
11139 buf_oop = ut_params->obuf;
11142 /* Create AEAD session */
11143 retval = create_aead_session(ts_params->valid_devs[0],
11145 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11146 tdata->key.data, tdata->key.len,
11147 tdata->aad.len, tdata->auth_tag.len,
11152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11154 /* clear mbuf payload */
11155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11156 rte_pktmbuf_tailroom(ut_params->ibuf));
11158 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11161 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11163 trn_data += plaintext_len;
11165 buf = ut_params->ibuf;
11168 * Loop until no more fragments
11171 while (trn_data < tdata->plaintext.len) {
11173 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11174 (tdata->plaintext.len - trn_data) : fragsz;
11176 to_trn_tbl[ecx++] = to_trn;
11178 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11181 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11182 rte_pktmbuf_tailroom(buf));
11185 if (oop && !fragsz_oop) {
11186 buf_last_oop = buf_oop->next =
11187 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11188 buf_oop = buf_oop->next;
11189 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11190 0, rte_pktmbuf_tailroom(buf_oop));
11191 rte_pktmbuf_append(buf_oop, to_trn);
11194 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11197 memcpy(plaintext, tdata->plaintext.data + trn_data,
11199 trn_data += to_trn;
11200 if (trn_data == tdata->plaintext.len) {
11203 digest_mem = rte_pktmbuf_append(buf_oop,
11204 tdata->auth_tag.len);
11206 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11207 tdata->auth_tag.len);
11211 uint64_t digest_phys = 0;
11213 ut_params->ibuf->nb_segs = segs;
11216 if (fragsz_oop && oop) {
11220 if (frag_size_oop == tdata->plaintext.len) {
11221 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11222 tdata->auth_tag.len);
11224 digest_phys = rte_pktmbuf_iova_offset(
11226 tdata->plaintext.len + prepend_len);
11229 trn_data = frag_size_oop;
11230 while (trn_data < tdata->plaintext.len) {
11233 (tdata->plaintext.len - trn_data <
11235 (tdata->plaintext.len - trn_data) :
11238 to_trn_tbl[ecx++] = to_trn;
11240 buf_last_oop = buf_oop->next =
11241 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11242 buf_oop = buf_oop->next;
11243 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11244 0, rte_pktmbuf_tailroom(buf_oop));
11245 rte_pktmbuf_append(buf_oop, to_trn);
11247 trn_data += to_trn;
11249 if (trn_data == tdata->plaintext.len) {
11250 digest_mem = rte_pktmbuf_append(buf_oop,
11251 tdata->auth_tag.len);
11255 ut_params->obuf->nb_segs = segs;
11259 * Place digest at the end of the last buffer
11262 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11263 if (oop && buf_last_oop)
11264 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11266 if (!digest_mem && !oop) {
11267 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11268 + tdata->auth_tag.len);
11269 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11270 tdata->plaintext.len);
11273 /* Create AEAD operation */
11274 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11275 tdata, digest_mem, digest_phys);
11280 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11282 ut_params->op->sym->m_src = ut_params->ibuf;
11284 ut_params->op->sym->m_dst = ut_params->obuf;
11286 /* Process crypto operation */
11287 if (oop == IN_PLACE &&
11288 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11289 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11291 TEST_ASSERT_NOT_NULL(
11292 process_crypto_request(ts_params->valid_devs[0],
11293 ut_params->op), "failed to process sym crypto op");
11295 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11296 "crypto op processing failed");
11299 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11300 uint8_t *, prepend_len);
11302 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11303 uint8_t *, prepend_len);
11307 fragsz = fragsz_oop;
11309 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11311 tdata->ciphertext.data,
11313 "Ciphertext data not as expected");
11315 buf = ut_params->op->sym->m_src->next;
11317 buf = ut_params->op->sym->m_dst->next;
11319 unsigned int off = fragsz;
11323 ciphertext = rte_pktmbuf_mtod(buf,
11326 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11328 tdata->ciphertext.data + off,
11330 "Ciphertext data not as expected");
11332 off += to_trn_tbl[ecx++];
11336 auth_tag = digest_mem;
11337 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11339 tdata->auth_tag.data,
11340 tdata->auth_tag.len,
11341 "Generated auth tag not as expected");
11347 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11349 return test_authenticated_encryption_SGL(
11350 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11354 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11356 return test_authenticated_encryption_SGL(
11357 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11361 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11363 return test_authenticated_encryption_SGL(
11364 &gcm_test_case_8, OUT_OF_PLACE, 400,
11365 gcm_test_case_8.plaintext.len);
11369 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11371 /* This test is not for OPENSSL PMD */
11372 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11373 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11376 return test_authenticated_encryption_SGL(
11377 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11381 test_authentication_verify_fail_when_data_corrupted(
11382 struct crypto_testsuite_params *ts_params,
11383 struct crypto_unittest_params *ut_params,
11384 const struct test_crypto_vector *reference)
11386 return test_authentication_verify_fail_when_data_corruption(
11387 ts_params, ut_params, reference, 1);
11391 test_authentication_verify_fail_when_tag_corrupted(
11392 struct crypto_testsuite_params *ts_params,
11393 struct crypto_unittest_params *ut_params,
11394 const struct test_crypto_vector *reference)
11396 return test_authentication_verify_fail_when_data_corruption(
11397 ts_params, ut_params, reference, 0);
11401 test_authentication_verify_GMAC_fail_when_data_corrupted(
11402 struct crypto_testsuite_params *ts_params,
11403 struct crypto_unittest_params *ut_params,
11404 const struct test_crypto_vector *reference)
11406 return test_authentication_verify_GMAC_fail_when_corruption(
11407 ts_params, ut_params, reference, 1);
11411 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11412 struct crypto_testsuite_params *ts_params,
11413 struct crypto_unittest_params *ut_params,
11414 const struct test_crypto_vector *reference)
11416 return test_authentication_verify_GMAC_fail_when_corruption(
11417 ts_params, ut_params, reference, 0);
11421 test_authenticated_decryption_fail_when_data_corrupted(
11422 struct crypto_testsuite_params *ts_params,
11423 struct crypto_unittest_params *ut_params,
11424 const struct test_crypto_vector *reference)
11426 return test_authenticated_decryption_fail_when_corruption(
11427 ts_params, ut_params, reference, 1);
11431 test_authenticated_decryption_fail_when_tag_corrupted(
11432 struct crypto_testsuite_params *ts_params,
11433 struct crypto_unittest_params *ut_params,
11434 const struct test_crypto_vector *reference)
11436 return test_authenticated_decryption_fail_when_corruption(
11437 ts_params, ut_params, reference, 0);
11441 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11443 return test_authentication_verify_fail_when_data_corrupted(
11444 &testsuite_params, &unittest_params,
11445 &hmac_sha1_test_crypto_vector);
11449 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11451 return test_authentication_verify_fail_when_tag_corrupted(
11452 &testsuite_params, &unittest_params,
11453 &hmac_sha1_test_crypto_vector);
11457 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11459 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11460 &testsuite_params, &unittest_params,
11461 &aes128_gmac_test_vector);
11465 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11467 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11468 &testsuite_params, &unittest_params,
11469 &aes128_gmac_test_vector);
11473 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11475 return test_authenticated_decryption_fail_when_data_corrupted(
11478 &aes128cbc_hmac_sha1_test_vector);
11482 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11484 return test_authenticated_decryption_fail_when_tag_corrupted(
11487 &aes128cbc_hmac_sha1_test_vector);
11491 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11493 return test_authenticated_encryt_with_esn(
11496 &aes128cbc_hmac_sha1_aad_test_vector);
11500 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11502 return test_authenticated_decrypt_with_esn(
11505 &aes128cbc_hmac_sha1_aad_test_vector);
11508 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11510 /* global AESNI slave IDs for the scheduler test */
11511 uint8_t aesni_ids[2];
11514 test_scheduler_attach_slave_op(void)
11516 struct crypto_testsuite_params *ts_params = &testsuite_params;
11517 uint8_t sched_id = ts_params->valid_devs[0];
11518 uint32_t nb_devs, i, nb_devs_attached = 0;
11520 char vdev_name[32];
11522 /* create 2 AESNI_MB if necessary */
11523 nb_devs = rte_cryptodev_device_count_by_driver(
11524 rte_cryptodev_driver_id_get(
11525 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11527 for (i = nb_devs; i < 2; i++) {
11528 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11529 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11531 ret = rte_vdev_init(vdev_name, NULL);
11533 TEST_ASSERT(ret == 0,
11534 "Failed to create instance %u of"
11536 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11540 /* attach 2 AESNI_MB cdevs */
11541 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11543 struct rte_cryptodev_info info;
11544 unsigned int session_size;
11546 rte_cryptodev_info_get(i, &info);
11547 if (info.driver_id != rte_cryptodev_driver_id_get(
11548 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11551 session_size = rte_cryptodev_sym_get_private_session_size(i);
11553 * Create the session mempool again, since now there are new devices
11554 * to use the mempool.
11556 if (ts_params->session_mpool) {
11557 rte_mempool_free(ts_params->session_mpool);
11558 ts_params->session_mpool = NULL;
11560 if (ts_params->session_priv_mpool) {
11561 rte_mempool_free(ts_params->session_priv_mpool);
11562 ts_params->session_priv_mpool = NULL;
11565 if (info.sym.max_nb_sessions != 0 &&
11566 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11567 RTE_LOG(ERR, USER1,
11568 "Device does not support "
11569 "at least %u sessions\n",
11571 return TEST_FAILED;
11574 * Create mempool with maximum number of sessions,
11575 * to include the session headers
11577 if (ts_params->session_mpool == NULL) {
11578 ts_params->session_mpool =
11579 rte_cryptodev_sym_session_pool_create(
11581 MAX_NB_SESSIONS, 0, 0, 0,
11583 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11584 "session mempool allocation failed");
11588 * Create mempool with maximum number of sessions,
11589 * to include device specific session private data
11591 if (ts_params->session_priv_mpool == NULL) {
11592 ts_params->session_priv_mpool = rte_mempool_create(
11593 "test_sess_mp_priv",
11596 0, 0, NULL, NULL, NULL,
11597 NULL, SOCKET_ID_ANY,
11600 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11601 "session mempool allocation failed");
11604 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11605 ts_params->qp_conf.mp_session_private =
11606 ts_params->session_priv_mpool;
11608 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11611 TEST_ASSERT(ret == 0,
11612 "Failed to attach device %u of pmd : %s", i,
11613 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11615 aesni_ids[nb_devs_attached] = (uint8_t)i;
11617 nb_devs_attached++;
11624 test_scheduler_detach_slave_op(void)
11626 struct crypto_testsuite_params *ts_params = &testsuite_params;
11627 uint8_t sched_id = ts_params->valid_devs[0];
11631 for (i = 0; i < 2; i++) {
11632 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11634 TEST_ASSERT(ret == 0,
11635 "Failed to detach device %u", aesni_ids[i]);
11642 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11644 struct crypto_testsuite_params *ts_params = &testsuite_params;
11645 uint8_t sched_id = ts_params->valid_devs[0];
11647 return rte_cryptodev_scheduler_mode_set(sched_id,
11652 test_scheduler_mode_roundrobin_op(void)
11654 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11655 0, "Failed to set roundrobin mode");
11661 test_scheduler_mode_multicore_op(void)
11663 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11664 0, "Failed to set multicore mode");
11670 test_scheduler_mode_failover_op(void)
11672 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11673 0, "Failed to set failover mode");
11679 test_scheduler_mode_pkt_size_distr_op(void)
11681 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11682 0, "Failed to set pktsize mode");
11687 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11688 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11689 .setup = testsuite_setup,
11690 .teardown = testsuite_teardown,
11691 .unit_test_cases = {
11693 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11694 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11695 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11696 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11697 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11698 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11701 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11702 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11703 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11704 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11705 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11706 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11709 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11710 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11711 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11712 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11713 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11714 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11717 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11718 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11719 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11720 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11721 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11722 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11724 TEST_CASES_END() /**< NULL terminate unit test array */
11728 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11730 static struct unit_test_suite cryptodev_testsuite = {
11731 .suite_name = "Crypto Unit Test Suite",
11732 .setup = testsuite_setup,
11733 .teardown = testsuite_teardown,
11734 .unit_test_cases = {
11735 TEST_CASE_ST(ut_setup, ut_teardown,
11736 test_device_configure_invalid_dev_id),
11737 TEST_CASE_ST(ut_setup, ut_teardown,
11738 test_device_configure_invalid_queue_pair_ids),
11739 TEST_CASE_ST(ut_setup, ut_teardown,
11740 test_queue_pair_descriptor_setup),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 test_multi_session),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_multi_session_random_usage),
11747 TEST_CASE_ST(ut_setup, ut_teardown,
11748 test_null_invalid_operation),
11749 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11751 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11752 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11753 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11754 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11755 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11757 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11758 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11759 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11761 /** AES CCM Authenticated Encryption 128 bits key */
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_AES_CCM_authenticated_encryption_test_case_128_1),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_CCM_authenticated_encryption_test_case_128_2),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_CCM_authenticated_encryption_test_case_128_3),
11769 /** AES CCM Authenticated Decryption 128 bits key*/
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_CCM_authenticated_decryption_test_case_128_1),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_CCM_authenticated_decryption_test_case_128_2),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_CCM_authenticated_decryption_test_case_128_3),
11777 /** AES CCM Authenticated Encryption 192 bits key */
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_AES_CCM_authenticated_encryption_test_case_192_1),
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_CCM_authenticated_encryption_test_case_192_2),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_CCM_authenticated_encryption_test_case_192_3),
11785 /** AES CCM Authenticated Decryption 192 bits key*/
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_CCM_authenticated_decryption_test_case_192_1),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_CCM_authenticated_decryption_test_case_192_2),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_CCM_authenticated_decryption_test_case_192_3),
11793 /** AES CCM Authenticated Encryption 256 bits key */
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_AES_CCM_authenticated_encryption_test_case_256_1),
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_CCM_authenticated_encryption_test_case_256_2),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_CCM_authenticated_encryption_test_case_256_3),
11801 /** AES CCM Authenticated Decryption 256 bits key*/
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_AES_CCM_authenticated_decryption_test_case_256_1),
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_CCM_authenticated_decryption_test_case_256_2),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_CCM_authenticated_decryption_test_case_256_3),
11809 /** AES GCM Authenticated Encryption */
11810 TEST_CASE_ST(ut_setup, ut_teardown,
11811 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GCM_authenticated_encryption_test_case_1),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_GCM_authenticated_encryption_test_case_2),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_GCM_authenticated_encryption_test_case_3),
11824 TEST_CASE_ST(ut_setup, ut_teardown,
11825 test_AES_GCM_authenticated_encryption_test_case_4),
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_AES_GCM_authenticated_encryption_test_case_5),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_authenticated_encryption_test_case_6),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_GCM_authenticated_encryption_test_case_7),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_GCM_authenticated_encryption_test_case_8),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11837 /** AES GCM Authenticated Decryption */
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_AES_GCM_authenticated_decryption_test_case_1),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_AES_GCM_authenticated_decryption_test_case_2),
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_authenticated_decryption_test_case_3),
11844 TEST_CASE_ST(ut_setup, ut_teardown,
11845 test_AES_GCM_authenticated_decryption_test_case_4),
11846 TEST_CASE_ST(ut_setup, ut_teardown,
11847 test_AES_GCM_authenticated_decryption_test_case_5),
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GCM_authenticated_decryption_test_case_6),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GCM_authenticated_decryption_test_case_7),
11852 TEST_CASE_ST(ut_setup, ut_teardown,
11853 test_AES_GCM_authenticated_decryption_test_case_8),
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11857 /** AES GCM Authenticated Encryption 192 bits key */
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_AES_GCM_auth_encryption_test_case_192_1),
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_GCM_auth_encryption_test_case_192_2),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_AES_GCM_auth_encryption_test_case_192_3),
11864 TEST_CASE_ST(ut_setup, ut_teardown,
11865 test_AES_GCM_auth_encryption_test_case_192_4),
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_AES_GCM_auth_encryption_test_case_192_5),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_AES_GCM_auth_encryption_test_case_192_6),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_GCM_auth_encryption_test_case_192_7),
11873 /** AES GCM Authenticated Decryption 192 bits key */
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_AES_GCM_auth_decryption_test_case_192_1),
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_GCM_auth_decryption_test_case_192_2),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_GCM_auth_decryption_test_case_192_3),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_AES_GCM_auth_decryption_test_case_192_4),
11882 TEST_CASE_ST(ut_setup, ut_teardown,
11883 test_AES_GCM_auth_decryption_test_case_192_5),
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_AES_GCM_auth_decryption_test_case_192_6),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_AES_GCM_auth_decryption_test_case_192_7),
11889 /** AES GCM Authenticated Encryption 256 bits key */
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_AES_GCM_auth_encryption_test_case_256_1),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_AES_GCM_auth_encryption_test_case_256_2),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_GCM_auth_encryption_test_case_256_3),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_AES_GCM_auth_encryption_test_case_256_4),
11898 TEST_CASE_ST(ut_setup, ut_teardown,
11899 test_AES_GCM_auth_encryption_test_case_256_5),
11900 TEST_CASE_ST(ut_setup, ut_teardown,
11901 test_AES_GCM_auth_encryption_test_case_256_6),
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_GCM_auth_encryption_test_case_256_7),
11905 /** AES GCM Authenticated Decryption 256 bits key */
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_AES_GCM_auth_decryption_test_case_256_1),
11908 TEST_CASE_ST(ut_setup, ut_teardown,
11909 test_AES_GCM_auth_decryption_test_case_256_2),
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_AES_GCM_auth_decryption_test_case_256_3),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_GCM_auth_decryption_test_case_256_4),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_AES_GCM_auth_decryption_test_case_256_5),
11916 TEST_CASE_ST(ut_setup, ut_teardown,
11917 test_AES_GCM_auth_decryption_test_case_256_6),
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_AES_GCM_auth_decryption_test_case_256_7),
11921 /** AES GCM Authenticated Encryption big aad size */
11922 TEST_CASE_ST(ut_setup, ut_teardown,
11923 test_AES_GCM_auth_encryption_test_case_aad_1),
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_AES_GCM_auth_encryption_test_case_aad_2),
11927 /** AES GCM Authenticated Decryption big aad size */
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_AES_GCM_auth_decryption_test_case_aad_1),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_AES_GCM_auth_decryption_test_case_aad_2),
11933 /** Out of place tests */
11934 TEST_CASE_ST(ut_setup, ut_teardown,
11935 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11939 /** Session-less tests */
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11945 /** AES GMAC Authentication */
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_AES_GMAC_authentication_test_case_1),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GMAC_authentication_verify_test_case_1),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_GMAC_authentication_test_case_2),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_GMAC_authentication_verify_test_case_2),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GMAC_authentication_test_case_3),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_GMAC_authentication_verify_test_case_3),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_GMAC_authentication_test_case_4),
11960 TEST_CASE_ST(ut_setup, ut_teardown,
11961 test_AES_GMAC_authentication_verify_test_case_4),
11963 /** SNOW 3G encrypt only (UEA2) */
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_snow3g_encryption_test_case_1),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_snow3g_encryption_test_case_2),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_snow3g_encryption_test_case_3),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_snow3g_encryption_test_case_4),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_snow3g_encryption_test_case_5),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_snow3g_encryption_test_case_1_oop),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_snow3g_encryption_test_case_1_oop_sgl),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_snow3g_encryption_test_case_1_offset_oop),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_snow3g_decryption_test_case_1_oop),
11984 /** SNOW 3G generate auth, then encrypt (UEA2) */
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_snow3g_auth_cipher_test_case_1),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_snow3g_auth_cipher_test_case_2),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_snow3g_auth_cipher_test_case_2_oop),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_snow3g_auth_cipher_part_digest_enc),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_snow3g_auth_cipher_part_digest_enc_oop),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_snow3g_auth_cipher_test_case_3_sgl),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_snow3g_auth_cipher_part_digest_enc_sgl),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12004 /** SNOW 3G decrypt (UEA2), then verify auth */
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_snow3g_auth_cipher_verify_test_case_1),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_snow3g_auth_cipher_verify_test_case_2),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_snow3g_auth_cipher_verify_test_case_2_oop),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_snow3g_auth_cipher_verify_part_digest_enc),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12024 /** SNOW 3G decrypt only (UEA2) */
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_snow3g_decryption_test_case_1),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_snow3g_decryption_test_case_2),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_snow3g_decryption_test_case_3),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_snow3g_decryption_test_case_4),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_snow3g_decryption_test_case_5),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_snow3g_decryption_with_digest_test_case_1),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_snow3g_hash_generate_test_case_1),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_snow3g_hash_generate_test_case_2),
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_snow3g_hash_generate_test_case_3),
12043 /* Tests with buffers which length is not byte-aligned */
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_hash_generate_test_case_4),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_hash_generate_test_case_5),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_hash_generate_test_case_6),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_hash_verify_test_case_1),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_hash_verify_test_case_2),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_hash_verify_test_case_3),
12056 /* Tests with buffers which length is not byte-aligned */
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_snow3g_hash_verify_test_case_4),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_snow3g_hash_verify_test_case_5),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_snow3g_hash_verify_test_case_6),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_snow3g_cipher_auth_test_case_1),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_snow3g_auth_cipher_with_digest_test_case_1),
12068 /** ZUC encrypt only (EEA3) */
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_zuc_encryption_test_case_1),
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_zuc_encryption_test_case_2),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_zuc_encryption_test_case_3),
12075 TEST_CASE_ST(ut_setup, ut_teardown,
12076 test_zuc_encryption_test_case_4),
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_zuc_encryption_test_case_5),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_zuc_encryption_test_case_6_sgl),
12082 /** ZUC authenticate (EIA3) */
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_zuc_hash_generate_test_case_1),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_zuc_hash_generate_test_case_2),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_zuc_hash_generate_test_case_3),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_zuc_hash_generate_test_case_4),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_zuc_hash_generate_test_case_5),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_zuc_hash_generate_test_case_6),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_zuc_hash_generate_test_case_7),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_zuc_hash_generate_test_case_8),
12100 /** ZUC alg-chain (EEA3/EIA3) */
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_zuc_cipher_auth_test_case_1),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_zuc_cipher_auth_test_case_2),
12106 /** ZUC generate auth, then encrypt (EEA3) */
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_zuc_auth_cipher_test_case_1),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_zuc_auth_cipher_test_case_1_oop),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_zuc_auth_cipher_test_case_1_sgl),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_zuc_auth_cipher_test_case_1_oop_sgl),
12116 /** ZUC decrypt (EEA3), then verify auth */
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_zuc_auth_cipher_verify_test_case_1),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_zuc_auth_cipher_verify_test_case_1_oop),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_zuc_auth_cipher_verify_test_case_1_sgl),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12126 /** HMAC_MD5 Authentication */
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_MD5_HMAC_generate_case_1),
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_MD5_HMAC_verify_case_1),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_MD5_HMAC_generate_case_2),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_MD5_HMAC_verify_case_2),
12136 /** KASUMI hash only (UIA1) */
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_kasumi_hash_generate_test_case_1),
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_kasumi_hash_generate_test_case_2),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_kasumi_hash_generate_test_case_3),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_kasumi_hash_generate_test_case_4),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_kasumi_hash_generate_test_case_5),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_kasumi_hash_generate_test_case_6),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_kasumi_hash_verify_test_case_1),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_kasumi_hash_verify_test_case_2),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_kasumi_hash_verify_test_case_3),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_kasumi_hash_verify_test_case_4),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_kasumi_hash_verify_test_case_5),
12161 /** KASUMI encrypt only (UEA1) */
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_kasumi_encryption_test_case_1),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_kasumi_encryption_test_case_1_sgl),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_kasumi_encryption_test_case_1_oop),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_kasumi_encryption_test_case_1_oop_sgl),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_kasumi_encryption_test_case_2),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_kasumi_encryption_test_case_3),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_kasumi_encryption_test_case_4),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_kasumi_encryption_test_case_5),
12179 /** KASUMI decrypt only (UEA1) */
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_kasumi_decryption_test_case_1),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_kasumi_decryption_test_case_2),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_kasumi_decryption_test_case_3),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_kasumi_decryption_test_case_4),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_kasumi_decryption_test_case_5),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_kasumi_decryption_test_case_1_oop),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_cipher_auth_test_case_1),
12196 /** KASUMI generate auth, then encrypt (F8) */
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_kasumi_auth_cipher_test_case_1),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_auth_cipher_test_case_2),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_auth_cipher_test_case_2_oop),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_auth_cipher_test_case_2_sgl),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12208 /** KASUMI decrypt (F8), then verify auth */
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_kasumi_auth_cipher_verify_test_case_1),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_auth_cipher_verify_test_case_2),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_auth_cipher_verify_test_case_2_oop),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12220 /** ESN Testcase */
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12226 /** Negative tests */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 authentication_verify_AES128_GMAC_fail_data_corrupt),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12264 /** Mixed CIPHER + HASH algorithms */
12265 /** AUTH AES CMAC + CIPHER AES CTR */
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12283 /** AUTH ZUC + CIPHER SNOW3G */
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_auth_zuc_cipher_snow_test_case_1),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_verify_auth_zuc_cipher_snow_test_case_1),
12288 /** AUTH AES CMAC + CIPHER SNOW3G */
12289 TEST_CASE_ST(ut_setup, ut_teardown,
12290 test_auth_aes_cmac_cipher_snow_test_case_1),
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12293 /** AUTH ZUC + CIPHER AES CTR */
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_auth_zuc_cipher_aes_ctr_test_case_1),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12298 /** AUTH SNOW3G + CIPHER AES CTR */
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_auth_snow_cipher_aes_ctr_test_case_1),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12303 /** AUTH SNOW3G + CIPHER ZUC */
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 test_auth_snow_cipher_zuc_test_case_1),
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 test_verify_auth_snow_cipher_zuc_test_case_1),
12308 /** AUTH AES CMAC + CIPHER ZUC */
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_auth_aes_cmac_cipher_zuc_test_case_1),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12314 /** AUTH NULL + CIPHER SNOW3G */
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_auth_null_cipher_snow_test_case_1),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_verify_auth_null_cipher_snow_test_case_1),
12319 /** AUTH NULL + CIPHER ZUC */
12320 TEST_CASE_ST(ut_setup, ut_teardown,
12321 test_auth_null_cipher_zuc_test_case_1),
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 test_verify_auth_null_cipher_zuc_test_case_1),
12324 /** AUTH SNOW3G + CIPHER NULL */
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_auth_snow_cipher_null_test_case_1),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_verify_auth_snow_cipher_null_test_case_1),
12329 /** AUTH ZUC + CIPHER NULL */
12330 TEST_CASE_ST(ut_setup, ut_teardown,
12331 test_auth_zuc_cipher_null_test_case_1),
12332 TEST_CASE_ST(ut_setup, ut_teardown,
12333 test_verify_auth_zuc_cipher_null_test_case_1),
12334 /** AUTH NULL + CIPHER AES CTR */
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_auth_null_cipher_aes_ctr_test_case_1),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12339 /** AUTH AES CMAC + CIPHER NULL */
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_auth_aes_cmac_cipher_null_test_case_1),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12345 TEST_CASES_END() /**< NULL terminate unit test array */
12349 static struct unit_test_suite cryptodev_virtio_testsuite = {
12350 .suite_name = "Crypto VIRTIO Unit Test Suite",
12351 .setup = testsuite_setup,
12352 .teardown = testsuite_teardown,
12353 .unit_test_cases = {
12354 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12356 TEST_CASES_END() /**< NULL terminate unit test array */
12360 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12361 .suite_name = "Crypto CAAM JR Unit Test Suite",
12362 .setup = testsuite_setup,
12363 .teardown = testsuite_teardown,
12364 .unit_test_cases = {
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_device_configure_invalid_dev_id),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_multi_session),
12370 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12371 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12372 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12373 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12374 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12376 TEST_CASES_END() /**< NULL terminate unit test array */
12380 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12381 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12382 .setup = testsuite_setup,
12383 .teardown = testsuite_teardown,
12384 .unit_test_cases = {
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_device_configure_invalid_dev_id),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_multi_session),
12390 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12391 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12392 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12393 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12394 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12396 #ifdef RTE_LIBRTE_SECURITY
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_PDCP_PROTO_cplane_encap_all),
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_PDCP_PROTO_cplane_decap_all),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_PDCP_PROTO_uplane_encap_all),
12406 TEST_CASE_ST(ut_setup, ut_teardown,
12407 test_PDCP_PROTO_uplane_decap_all),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_PDCP_PROTO_SGL_in_place_32B),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_PDCP_PROTO_SGL_oop_32B_128B),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_PDCP_PROTO_SGL_oop_32B_40B),
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_PDCP_PROTO_SGL_oop_128B_32B),
12418 /** AES GCM Authenticated Encryption */
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GCM_authenticated_encryption_test_case_1),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GCM_authenticated_encryption_test_case_2),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_authenticated_encryption_test_case_3),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GCM_authenticated_encryption_test_case_4),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GCM_authenticated_encryption_test_case_5),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GCM_authenticated_encryption_test_case_6),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_authenticated_encryption_test_case_7),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_authenticated_encryption_test_case_8),
12444 /** AES GCM Authenticated Decryption */
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_AES_GCM_authenticated_decryption_test_case_1),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_AES_GCM_authenticated_decryption_test_case_2),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_AES_GCM_authenticated_decryption_test_case_3),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_AES_GCM_authenticated_decryption_test_case_4),
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_AES_GCM_authenticated_decryption_test_case_5),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_AES_GCM_authenticated_decryption_test_case_6),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_AES_GCM_authenticated_decryption_test_case_7),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_GCM_authenticated_decryption_test_case_8),
12462 /** AES GCM Authenticated Encryption 192 bits key */
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_AES_GCM_auth_encryption_test_case_192_1),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_AES_GCM_auth_encryption_test_case_192_2),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_AES_GCM_auth_encryption_test_case_192_3),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_AES_GCM_auth_encryption_test_case_192_4),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 test_AES_GCM_auth_encryption_test_case_192_5),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_AES_GCM_auth_encryption_test_case_192_6),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_AES_GCM_auth_encryption_test_case_192_7),
12478 /** AES GCM Authenticated Decryption 192 bits key */
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_AES_GCM_auth_decryption_test_case_192_1),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_AES_GCM_auth_decryption_test_case_192_2),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_AES_GCM_auth_decryption_test_case_192_3),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_AES_GCM_auth_decryption_test_case_192_4),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_AES_GCM_auth_decryption_test_case_192_5),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_AES_GCM_auth_decryption_test_case_192_6),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_AES_GCM_auth_decryption_test_case_192_7),
12494 /** AES GCM Authenticated Encryption 256 bits key */
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 test_AES_GCM_auth_encryption_test_case_256_1),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_AES_GCM_auth_encryption_test_case_256_2),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_AES_GCM_auth_encryption_test_case_256_3),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_AES_GCM_auth_encryption_test_case_256_4),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_GCM_auth_encryption_test_case_256_5),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_AES_GCM_auth_encryption_test_case_256_6),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_GCM_auth_encryption_test_case_256_7),
12510 /** AES GCM Authenticated Decryption 256 bits key */
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_AES_GCM_auth_decryption_test_case_256_1),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_AES_GCM_auth_decryption_test_case_256_2),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_AES_GCM_auth_decryption_test_case_256_3),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_AES_GCM_auth_decryption_test_case_256_4),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_AES_GCM_auth_decryption_test_case_256_5),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_AES_GCM_auth_decryption_test_case_256_6),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_AES_GCM_auth_decryption_test_case_256_7),
12526 /** Out of place tests */
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12532 /** SNOW 3G encrypt only (UEA2) */
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_snow3g_encryption_test_case_1),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_snow3g_encryption_test_case_2),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_snow3g_encryption_test_case_3),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_snow3g_encryption_test_case_4),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_snow3g_encryption_test_case_5),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_snow3g_encryption_test_case_1_oop),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_snow3g_encryption_test_case_1_oop_sgl),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_snow3g_decryption_test_case_1_oop),
12551 /** SNOW 3G decrypt only (UEA2) */
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_snow3g_decryption_test_case_1),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_snow3g_decryption_test_case_2),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_snow3g_decryption_test_case_3),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_snow3g_decryption_test_case_4),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_snow3g_decryption_test_case_5),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 test_snow3g_hash_generate_test_case_1),
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_snow3g_hash_generate_test_case_2),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_snow3g_hash_generate_test_case_3),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_snow3g_hash_verify_test_case_1),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_snow3g_hash_verify_test_case_2),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_snow3g_hash_verify_test_case_3),
12576 /** ZUC encrypt only (EEA3) */
12577 TEST_CASE_ST(ut_setup, ut_teardown,
12578 test_zuc_encryption_test_case_1),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_zuc_encryption_test_case_2),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_zuc_encryption_test_case_3),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_zuc_encryption_test_case_4),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_zuc_encryption_test_case_5),
12588 /** ZUC authenticate (EIA3) */
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_zuc_hash_generate_test_case_6),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_zuc_hash_generate_test_case_7),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_zuc_hash_generate_test_case_8),
12596 /** Negative tests */
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12613 TEST_CASE_ST(ut_setup, ut_teardown,
12614 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12621 TEST_CASE_ST(ut_setup, ut_teardown,
12622 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12636 TEST_CASES_END() /**< NULL terminate unit test array */
12640 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12641 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12642 .setup = testsuite_setup,
12643 .teardown = testsuite_teardown,
12644 .unit_test_cases = {
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_device_configure_invalid_dev_id),
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_multi_session),
12649 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12650 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12651 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12652 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12653 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12655 #ifdef RTE_LIBRTE_SECURITY
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_PDCP_PROTO_cplane_encap_all),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_PDCP_PROTO_cplane_decap_all),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 test_PDCP_PROTO_uplane_encap_all),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_PDCP_PROTO_uplane_decap_all),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 test_PDCP_PROTO_SGL_in_place_32B),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_PDCP_PROTO_SGL_oop_32B_128B),
12672 TEST_CASE_ST(ut_setup, ut_teardown,
12673 test_PDCP_PROTO_SGL_oop_32B_40B),
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 test_PDCP_PROTO_SGL_oop_128B_32B),
12677 /** AES GCM Authenticated Encryption */
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_AES_GCM_authenticated_encryption_test_case_1),
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_AES_GCM_authenticated_encryption_test_case_2),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_AES_GCM_authenticated_encryption_test_case_3),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_AES_GCM_authenticated_encryption_test_case_4),
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_AES_GCM_authenticated_encryption_test_case_5),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_authenticated_encryption_test_case_6),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_authenticated_encryption_test_case_7),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_authenticated_encryption_test_case_8),
12703 /** AES GCM Authenticated Decryption */
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_authenticated_decryption_test_case_1),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_authenticated_decryption_test_case_2),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_authenticated_decryption_test_case_3),
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_AES_GCM_authenticated_decryption_test_case_4),
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_AES_GCM_authenticated_decryption_test_case_5),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_authenticated_decryption_test_case_6),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_authenticated_decryption_test_case_7),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_AES_GCM_authenticated_decryption_test_case_8),
12721 /** AES GCM Authenticated Encryption 192 bits key */
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_auth_encryption_test_case_192_1),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_AES_GCM_auth_encryption_test_case_192_2),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 test_AES_GCM_auth_encryption_test_case_192_3),
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 test_AES_GCM_auth_encryption_test_case_192_4),
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 test_AES_GCM_auth_encryption_test_case_192_5),
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_AES_GCM_auth_encryption_test_case_192_6),
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_AES_GCM_auth_encryption_test_case_192_7),
12737 /** AES GCM Authenticated Decryption 192 bits key */
12738 TEST_CASE_ST(ut_setup, ut_teardown,
12739 test_AES_GCM_auth_decryption_test_case_192_1),
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_AES_GCM_auth_decryption_test_case_192_2),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_AES_GCM_auth_decryption_test_case_192_3),
12744 TEST_CASE_ST(ut_setup, ut_teardown,
12745 test_AES_GCM_auth_decryption_test_case_192_4),
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_AES_GCM_auth_decryption_test_case_192_5),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_AES_GCM_auth_decryption_test_case_192_6),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_AES_GCM_auth_decryption_test_case_192_7),
12753 /** AES GCM Authenticated Encryption 256 bits key */
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_AES_GCM_auth_encryption_test_case_256_1),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_AES_GCM_auth_encryption_test_case_256_2),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_AES_GCM_auth_encryption_test_case_256_3),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_AES_GCM_auth_encryption_test_case_256_4),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_AES_GCM_auth_encryption_test_case_256_5),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_AES_GCM_auth_encryption_test_case_256_6),
12766 TEST_CASE_ST(ut_setup, ut_teardown,
12767 test_AES_GCM_auth_encryption_test_case_256_7),
12769 /** AES GCM Authenticated Decryption 256 bits key */
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_AES_GCM_auth_decryption_test_case_256_1),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_AES_GCM_auth_decryption_test_case_256_2),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GCM_auth_decryption_test_case_256_3),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_AES_GCM_auth_decryption_test_case_256_4),
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_AES_GCM_auth_decryption_test_case_256_5),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GCM_auth_decryption_test_case_256_6),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_AES_GCM_auth_decryption_test_case_256_7),
12785 /** Out of place tests */
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12791 /** SNOW 3G encrypt only (UEA2) */
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_snow3g_encryption_test_case_1),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_snow3g_encryption_test_case_2),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_snow3g_encryption_test_case_3),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_snow3g_encryption_test_case_4),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_snow3g_encryption_test_case_5),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_snow3g_encryption_test_case_1_oop),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_snow3g_encryption_test_case_1_oop_sgl),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_snow3g_decryption_test_case_1_oop),
12810 /** SNOW 3G decrypt only (UEA2) */
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_snow3g_decryption_test_case_1),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_snow3g_decryption_test_case_2),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_snow3g_decryption_test_case_3),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_snow3g_decryption_test_case_4),
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 test_snow3g_decryption_test_case_5),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_snow3g_hash_generate_test_case_1),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_snow3g_hash_generate_test_case_2),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_snow3g_hash_generate_test_case_3),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_snow3g_hash_verify_test_case_1),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_snow3g_hash_verify_test_case_2),
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_snow3g_hash_verify_test_case_3),
12835 /** ZUC encrypt only (EEA3) */
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_zuc_encryption_test_case_1),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_zuc_encryption_test_case_2),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_zuc_encryption_test_case_3),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_zuc_encryption_test_case_4),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_zuc_encryption_test_case_5),
12847 /** ZUC authenticate (EIA3) */
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_zuc_hash_generate_test_case_6),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_zuc_hash_generate_test_case_7),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_zuc_hash_generate_test_case_8),
12855 /** HMAC_MD5 Authentication */
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_MD5_HMAC_generate_case_1),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_MD5_HMAC_verify_case_1),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_MD5_HMAC_generate_case_2),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_MD5_HMAC_verify_case_2),
12865 /** Negative tests */
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12870 TEST_CASE_ST(ut_setup, ut_teardown,
12871 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12906 TEST_CASES_END() /**< NULL terminate unit test array */
12910 static struct unit_test_suite cryptodev_armv8_testsuite = {
12911 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12912 .setup = testsuite_setup,
12913 .teardown = testsuite_teardown,
12914 .unit_test_cases = {
12915 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12917 /** Negative tests */
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12923 TEST_CASES_END() /**< NULL terminate unit test array */
12927 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12928 .suite_name = "Crypto Device Marvell Component Test Suite",
12929 .setup = testsuite_setup,
12930 .teardown = testsuite_teardown,
12931 .unit_test_cases = {
12932 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_multi_session_random_usage),
12935 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12936 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12937 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12938 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12939 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12941 /** Negative tests */
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12944 TEST_CASE_ST(ut_setup, ut_teardown,
12945 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12951 TEST_CASES_END() /**< NULL terminate unit test array */
12955 static struct unit_test_suite cryptodev_ccp_testsuite = {
12956 .suite_name = "Crypto Device CCP Unit Test Suite",
12957 .setup = testsuite_setup,
12958 .teardown = testsuite_teardown,
12959 .unit_test_cases = {
12960 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_multi_session_random_usage),
12963 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12964 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12965 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12966 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12967 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12969 /** Negative tests */
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12972 TEST_CASE_ST(ut_setup, ut_teardown,
12973 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12979 TEST_CASES_END() /**< NULL terminate unit test array */
12983 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12984 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12985 .setup = testsuite_setup,
12986 .teardown = testsuite_teardown,
12987 .unit_test_cases = {
12988 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12989 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12990 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12991 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12992 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12994 /** AES GCM Authenticated Encryption */
12995 TEST_CASE_ST(ut_setup, ut_teardown,
12996 test_AES_GCM_authenticated_encryption_test_case_1),
12997 TEST_CASE_ST(ut_setup, ut_teardown,
12998 test_AES_GCM_authenticated_encryption_test_case_2),
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_AES_GCM_authenticated_encryption_test_case_3),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_AES_GCM_authenticated_encryption_test_case_4),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_AES_GCM_authenticated_encryption_test_case_5),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_AES_GCM_authenticated_encryption_test_case_6),
13007 TEST_CASE_ST(ut_setup, ut_teardown,
13008 test_AES_GCM_authenticated_encryption_test_case_7),
13010 /** AES GCM Authenticated Decryption */
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 test_AES_GCM_authenticated_decryption_test_case_1),
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_AES_GCM_authenticated_decryption_test_case_2),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_authenticated_decryption_test_case_3),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_authenticated_decryption_test_case_4),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_authenticated_decryption_test_case_5),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_authenticated_decryption_test_case_6),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_authenticated_decryption_test_case_7),
13025 /** AES GMAC Authentication */
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_GMAC_authentication_test_case_1),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_AES_GMAC_authentication_verify_test_case_1),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GMAC_authentication_test_case_2),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GMAC_authentication_verify_test_case_2),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GMAC_authentication_test_case_3),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GMAC_authentication_verify_test_case_3),
13039 /** SNOW 3G encrypt only (UEA2) */
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_snow3g_encryption_test_case_1),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_snow3g_encryption_test_case_2),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_snow3g_encryption_test_case_3),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_snow3g_encryption_test_case_4),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_snow3g_encryption_test_case_5),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 test_snow3g_encryption_test_case_1_oop),
13053 TEST_CASE_ST(ut_setup, ut_teardown,
13054 test_snow3g_decryption_test_case_1_oop),
13055 TEST_CASE_ST(ut_setup, ut_teardown,
13056 test_snow3g_encryption_test_case_1_oop_sgl),
13058 /** SNOW 3G decrypt only (UEA2) */
13059 TEST_CASE_ST(ut_setup, ut_teardown,
13060 test_snow3g_decryption_test_case_1),
13061 TEST_CASE_ST(ut_setup, ut_teardown,
13062 test_snow3g_decryption_test_case_2),
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_snow3g_decryption_test_case_3),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_snow3g_decryption_test_case_4),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_snow3g_decryption_test_case_5),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_snow3g_hash_generate_test_case_1),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_snow3g_hash_generate_test_case_2),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_snow3g_hash_generate_test_case_3),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_snow3g_hash_verify_test_case_1),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_snow3g_hash_verify_test_case_2),
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_snow3g_hash_verify_test_case_3),
13083 /** ZUC encrypt only (EEA3) */
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_zuc_encryption_test_case_1),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_zuc_encryption_test_case_2),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_zuc_encryption_test_case_3),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_zuc_encryption_test_case_4),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_zuc_encryption_test_case_5),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_zuc_hash_generate_test_case_1),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_zuc_hash_generate_test_case_2),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_zuc_hash_generate_test_case_3),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_zuc_hash_generate_test_case_4),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_zuc_hash_generate_test_case_5),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_zuc_encryption_test_case_6_sgl),
13107 /** KASUMI encrypt only (UEA1) */
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_kasumi_encryption_test_case_1),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_kasumi_encryption_test_case_2),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_kasumi_encryption_test_case_3),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_kasumi_encryption_test_case_4),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_kasumi_encryption_test_case_5),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_kasumi_encryption_test_case_1_sgl),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_kasumi_encryption_test_case_1_oop_sgl),
13122 /** KASUMI decrypt only (UEA1) */
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_kasumi_decryption_test_case_1),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_kasumi_decryption_test_case_2),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_kasumi_decryption_test_case_3),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_kasumi_decryption_test_case_4),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_kasumi_decryption_test_case_5),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_kasumi_encryption_test_case_1_oop),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_kasumi_decryption_test_case_1_oop),
13139 /** KASUMI hash only (UIA1) */
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_kasumi_hash_generate_test_case_1),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_kasumi_hash_generate_test_case_2),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_kasumi_hash_generate_test_case_3),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_kasumi_hash_generate_test_case_4),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_kasumi_hash_generate_test_case_5),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_kasumi_hash_generate_test_case_6),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_kasumi_hash_verify_test_case_1),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_kasumi_hash_verify_test_case_2),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_kasumi_hash_verify_test_case_3),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_kasumi_hash_verify_test_case_4),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_kasumi_hash_verify_test_case_5),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_null_cipher_only_operation),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_null_auth_only_operation),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_null_cipher_auth_operation),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_null_auth_cipher_operation),
13173 /** Negative tests */
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 authentication_verify_AES128_GMAC_fail_data_corrupt),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13186 TEST_CASES_END() /**< NULL terminate unit test array */
13190 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13191 .suite_name = "Crypto NITROX Unit Test Suite",
13192 .setup = testsuite_setup,
13193 .teardown = testsuite_teardown,
13194 .unit_test_cases = {
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_device_configure_invalid_dev_id),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_device_configure_invalid_queue_pair_ids),
13199 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13200 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13202 TEST_CASES_END() /**< NULL terminate unit test array */
13206 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13207 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13208 .setup = testsuite_setup,
13209 .teardown = testsuite_teardown,
13210 .unit_test_cases = {
13211 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13212 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13213 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13214 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13215 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13217 /** AES GCM Authenticated Encryption */
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_AES_GCM_authenticated_encryption_test_case_1),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_AES_GCM_authenticated_encryption_test_case_2),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_AES_GCM_authenticated_encryption_test_case_3),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_AES_GCM_authenticated_encryption_test_case_4),
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_AES_GCM_authenticated_encryption_test_case_5),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_AES_GCM_authenticated_encryption_test_case_6),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_AES_GCM_authenticated_encryption_test_case_7),
13233 /** AES GCM Authenticated Decryption */
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_AES_GCM_authenticated_decryption_test_case_1),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_AES_GCM_authenticated_decryption_test_case_2),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_AES_GCM_authenticated_decryption_test_case_3),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_AES_GCM_authenticated_decryption_test_case_4),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_AES_GCM_authenticated_decryption_test_case_5),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_AES_GCM_authenticated_decryption_test_case_6),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_AES_GCM_authenticated_decryption_test_case_7),
13248 /** AES GMAC Authentication */
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 test_AES_GMAC_authentication_test_case_1),
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_AES_GMAC_authentication_verify_test_case_1),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_AES_GMAC_authentication_test_case_2),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_AES_GMAC_authentication_verify_test_case_2),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_AES_GMAC_authentication_test_case_3),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_AES_GMAC_authentication_verify_test_case_3),
13262 /** SNOW 3G encrypt only (UEA2) */
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_snow3g_encryption_test_case_1),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_snow3g_encryption_test_case_2),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_snow3g_encryption_test_case_3),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_snow3g_encryption_test_case_4),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_snow3g_encryption_test_case_5),
13274 TEST_CASE_ST(ut_setup, ut_teardown,
13275 test_snow3g_encryption_test_case_1_oop),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_snow3g_decryption_test_case_1_oop),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_snow3g_encryption_test_case_1_oop_sgl),
13281 /** SNOW 3G decrypt only (UEA2) */
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_snow3g_decryption_test_case_1),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_snow3g_decryption_test_case_2),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_snow3g_decryption_test_case_3),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_snow3g_decryption_test_case_4),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_snow3g_decryption_test_case_5),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_snow3g_hash_generate_test_case_1),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_snow3g_hash_generate_test_case_2),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_snow3g_hash_generate_test_case_3),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_snow3g_hash_verify_test_case_1),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_snow3g_hash_verify_test_case_2),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_snow3g_hash_verify_test_case_3),
13306 /** ZUC encrypt only (EEA3) */
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_zuc_encryption_test_case_1),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_zuc_encryption_test_case_2),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_zuc_encryption_test_case_3),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_zuc_encryption_test_case_4),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_zuc_encryption_test_case_5),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_zuc_hash_generate_test_case_1),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_zuc_hash_generate_test_case_2),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_zuc_hash_generate_test_case_3),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_zuc_hash_generate_test_case_4),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_zuc_hash_generate_test_case_5),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_zuc_encryption_test_case_6_sgl),
13330 /** KASUMI encrypt only (UEA1) */
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_kasumi_encryption_test_case_1),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_kasumi_encryption_test_case_2),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_kasumi_encryption_test_case_3),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_kasumi_encryption_test_case_4),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_kasumi_encryption_test_case_5),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_kasumi_encryption_test_case_1_sgl),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_kasumi_encryption_test_case_1_oop_sgl),
13345 /** KASUMI decrypt only (UEA1) */
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_kasumi_decryption_test_case_1),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_kasumi_decryption_test_case_2),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_kasumi_decryption_test_case_3),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_kasumi_decryption_test_case_4),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_kasumi_decryption_test_case_5),
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 test_kasumi_encryption_test_case_1_oop),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 test_kasumi_decryption_test_case_1_oop),
13362 /** KASUMI hash only (UIA1) */
13363 TEST_CASE_ST(ut_setup, ut_teardown,
13364 test_kasumi_hash_generate_test_case_1),
13365 TEST_CASE_ST(ut_setup, ut_teardown,
13366 test_kasumi_hash_generate_test_case_2),
13367 TEST_CASE_ST(ut_setup, ut_teardown,
13368 test_kasumi_hash_generate_test_case_3),
13369 TEST_CASE_ST(ut_setup, ut_teardown,
13370 test_kasumi_hash_generate_test_case_4),
13371 TEST_CASE_ST(ut_setup, ut_teardown,
13372 test_kasumi_hash_generate_test_case_5),
13373 TEST_CASE_ST(ut_setup, ut_teardown,
13374 test_kasumi_hash_generate_test_case_6),
13375 TEST_CASE_ST(ut_setup, ut_teardown,
13376 test_kasumi_hash_verify_test_case_1),
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_kasumi_hash_verify_test_case_2),
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 test_kasumi_hash_verify_test_case_3),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_kasumi_hash_verify_test_case_4),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_kasumi_hash_verify_test_case_5),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_null_cipher_only_operation),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_null_auth_only_operation),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_null_cipher_auth_operation),
13393 TEST_CASE_ST(ut_setup, ut_teardown,
13394 test_null_auth_cipher_operation),
13396 /** Negative tests */
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 authentication_verify_AES128_GMAC_fail_data_corrupt),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13409 TEST_CASES_END() /**< NULL terminate unit test array */
13414 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13416 gbl_driver_id = rte_cryptodev_driver_id_get(
13417 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13419 if (gbl_driver_id == -1) {
13420 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13421 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13422 "are enabled in config file to run this testsuite.\n");
13423 return TEST_SKIPPED;
13426 return unit_test_suite_runner(&cryptodev_testsuite);
13430 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13432 gbl_driver_id = rte_cryptodev_driver_id_get(
13433 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13435 if (gbl_driver_id == -1) {
13436 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13437 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13438 "in config file to run this testsuite.\n");
13439 return TEST_FAILED;
13442 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13446 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13448 gbl_driver_id = rte_cryptodev_driver_id_get(
13449 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13451 if (gbl_driver_id == -1) {
13452 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13453 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13454 "in config file to run this testsuite.\n");
13455 return TEST_SKIPPED;
13458 return unit_test_suite_runner(&cryptodev_testsuite);
13462 test_cryptodev_cpu_aesni_mb(void)
13465 enum rte_security_session_action_type at;
13467 gbl_driver_id = rte_cryptodev_driver_id_get(
13468 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13470 if (gbl_driver_id == -1) {
13471 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13472 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13473 "in config file to run this testsuite.\n");
13474 return TEST_SKIPPED;
13477 at = gbl_action_type;
13478 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13479 rc = unit_test_suite_runner(&cryptodev_testsuite);
13480 gbl_action_type = at;
13485 test_cryptodev_openssl(void)
13487 gbl_driver_id = rte_cryptodev_driver_id_get(
13488 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13490 if (gbl_driver_id == -1) {
13491 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13492 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13493 "in config file to run this testsuite.\n");
13494 return TEST_SKIPPED;
13497 return unit_test_suite_runner(&cryptodev_testsuite);
13501 test_cryptodev_aesni_gcm(void)
13503 gbl_driver_id = rte_cryptodev_driver_id_get(
13504 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13506 if (gbl_driver_id == -1) {
13507 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13508 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13509 "in config file to run this testsuite.\n");
13510 return TEST_SKIPPED;
13513 return unit_test_suite_runner(&cryptodev_testsuite);
13517 test_cryptodev_cpu_aesni_gcm(void)
13520 enum rte_security_session_action_type at;
13522 gbl_driver_id = rte_cryptodev_driver_id_get(
13523 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13525 if (gbl_driver_id == -1) {
13526 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13527 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13528 "in config file to run this testsuite.\n");
13529 return TEST_SKIPPED;
13532 at = gbl_action_type;
13533 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13534 rc = unit_test_suite_runner(&cryptodev_testsuite);
13535 gbl_action_type = at;
13540 test_cryptodev_null(void)
13542 gbl_driver_id = rte_cryptodev_driver_id_get(
13543 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13545 if (gbl_driver_id == -1) {
13546 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13547 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13548 "in config file to run this testsuite.\n");
13549 return TEST_SKIPPED;
13552 return unit_test_suite_runner(&cryptodev_testsuite);
13556 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13558 gbl_driver_id = rte_cryptodev_driver_id_get(
13559 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13561 if (gbl_driver_id == -1) {
13562 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13563 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13564 "in config file to run this testsuite.\n");
13565 return TEST_SKIPPED;
13568 return unit_test_suite_runner(&cryptodev_testsuite);
13572 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13574 gbl_driver_id = rte_cryptodev_driver_id_get(
13575 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13577 if (gbl_driver_id == -1) {
13578 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13579 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13580 "in config file to run this testsuite.\n");
13581 return TEST_SKIPPED;
13584 return unit_test_suite_runner(&cryptodev_testsuite);
13588 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13590 gbl_driver_id = rte_cryptodev_driver_id_get(
13591 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13593 if (gbl_driver_id == -1) {
13594 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13595 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13596 "in config file to run this testsuite.\n");
13597 return TEST_SKIPPED;
13600 return unit_test_suite_runner(&cryptodev_testsuite);
13604 test_cryptodev_armv8(void)
13606 gbl_driver_id = rte_cryptodev_driver_id_get(
13607 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13609 if (gbl_driver_id == -1) {
13610 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13611 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13612 "in config file to run this testsuite.\n");
13613 return TEST_SKIPPED;
13616 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13620 test_cryptodev_mrvl(void)
13622 gbl_driver_id = rte_cryptodev_driver_id_get(
13623 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13625 if (gbl_driver_id == -1) {
13626 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13627 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13628 "in config file to run this testsuite.\n");
13629 return TEST_SKIPPED;
13632 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13635 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13638 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13640 gbl_driver_id = rte_cryptodev_driver_id_get(
13641 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13643 if (gbl_driver_id == -1) {
13644 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13645 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13646 "in config file to run this testsuite.\n");
13647 return TEST_SKIPPED;
13650 if (rte_cryptodev_driver_id_get(
13651 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13652 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13653 " enabled in config file to run this testsuite.\n");
13654 return TEST_SKIPPED;
13656 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13659 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13664 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13666 gbl_driver_id = rte_cryptodev_driver_id_get(
13667 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13669 if (gbl_driver_id == -1) {
13670 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13671 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13672 "in config file to run this testsuite.\n");
13673 return TEST_SKIPPED;
13676 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13680 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13682 gbl_driver_id = rte_cryptodev_driver_id_get(
13683 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13685 if (gbl_driver_id == -1) {
13686 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13687 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13688 "in config file to run this testsuite.\n");
13689 return TEST_SKIPPED;
13692 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13696 test_cryptodev_ccp(void)
13698 gbl_driver_id = rte_cryptodev_driver_id_get(
13699 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13701 if (gbl_driver_id == -1) {
13702 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13703 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13704 "in config file to run this testsuite.\n");
13705 return TEST_FAILED;
13708 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13712 test_cryptodev_octeontx(void)
13714 gbl_driver_id = rte_cryptodev_driver_id_get(
13715 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13716 if (gbl_driver_id == -1) {
13717 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13718 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13719 "enabled in config file to run this "
13721 return TEST_FAILED;
13723 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13727 test_cryptodev_octeontx2(void)
13729 gbl_driver_id = rte_cryptodev_driver_id_get(
13730 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13731 if (gbl_driver_id == -1) {
13732 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13733 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13734 "enabled in config file to run this "
13736 return TEST_FAILED;
13738 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13742 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13744 gbl_driver_id = rte_cryptodev_driver_id_get(
13745 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13747 if (gbl_driver_id == -1) {
13748 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13749 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13750 "in config file to run this testsuite.\n");
13751 return TEST_FAILED;
13754 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13758 test_cryptodev_nitrox(void)
13760 gbl_driver_id = rte_cryptodev_driver_id_get(
13761 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13763 if (gbl_driver_id == -1) {
13764 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13765 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13766 "in config file to run this testsuite.\n");
13767 return TEST_FAILED;
13770 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13773 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13774 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13775 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13776 test_cryptodev_cpu_aesni_mb);
13777 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13778 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13779 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13780 test_cryptodev_cpu_aesni_gcm);
13781 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13782 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13783 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13784 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13785 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13786 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13787 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13788 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13789 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13790 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13791 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13792 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13793 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13794 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);