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],
1741 if (status == -ENOTSUP)
1744 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1746 return TEST_SUCCESS;
1750 test_AES_cipheronly_all(void)
1752 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1756 test_AES_docsis_all(void)
1758 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1762 test_DES_docsis_all(void)
1764 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1768 test_DES_cipheronly_all(void)
1770 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1774 test_authonly_all(void)
1776 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1780 test_AES_chain_all(void)
1782 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1786 test_3DES_chain_all(void)
1788 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1792 test_3DES_cipheronly_all(void)
1794 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1797 /* ***** SNOW 3G Tests ***** */
1799 create_wireless_algo_hash_session(uint8_t dev_id,
1800 const uint8_t *key, const uint8_t key_len,
1801 const uint8_t iv_len, const uint8_t auth_len,
1802 enum rte_crypto_auth_operation op,
1803 enum rte_crypto_auth_algorithm algo)
1805 uint8_t hash_key[key_len];
1808 struct crypto_testsuite_params *ts_params = &testsuite_params;
1809 struct crypto_unittest_params *ut_params = &unittest_params;
1811 memcpy(hash_key, key, key_len);
1813 debug_hexdump(stdout, "key:", key, key_len);
1815 /* Setup Authentication Parameters */
1816 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1817 ut_params->auth_xform.next = NULL;
1819 ut_params->auth_xform.auth.op = op;
1820 ut_params->auth_xform.auth.algo = algo;
1821 ut_params->auth_xform.auth.key.length = key_len;
1822 ut_params->auth_xform.auth.key.data = hash_key;
1823 ut_params->auth_xform.auth.digest_length = auth_len;
1824 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1825 ut_params->auth_xform.auth.iv.length = iv_len;
1826 ut_params->sess = rte_cryptodev_sym_session_create(
1827 ts_params->session_mpool);
1829 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1830 &ut_params->auth_xform,
1831 ts_params->session_priv_mpool);
1832 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1833 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1838 create_wireless_algo_cipher_session(uint8_t dev_id,
1839 enum rte_crypto_cipher_operation op,
1840 enum rte_crypto_cipher_algorithm algo,
1841 const uint8_t *key, const uint8_t key_len,
1844 uint8_t cipher_key[key_len];
1846 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 struct crypto_unittest_params *ut_params = &unittest_params;
1849 memcpy(cipher_key, key, key_len);
1851 /* Setup Cipher Parameters */
1852 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1853 ut_params->cipher_xform.next = NULL;
1855 ut_params->cipher_xform.cipher.algo = algo;
1856 ut_params->cipher_xform.cipher.op = op;
1857 ut_params->cipher_xform.cipher.key.data = cipher_key;
1858 ut_params->cipher_xform.cipher.key.length = key_len;
1859 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1860 ut_params->cipher_xform.cipher.iv.length = iv_len;
1862 debug_hexdump(stdout, "key:", key, key_len);
1864 /* Create Crypto session */
1865 ut_params->sess = rte_cryptodev_sym_session_create(
1866 ts_params->session_mpool);
1868 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1869 &ut_params->cipher_xform,
1870 ts_params->session_priv_mpool);
1871 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1872 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1877 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1878 unsigned int cipher_len,
1879 unsigned int cipher_offset)
1881 struct crypto_testsuite_params *ts_params = &testsuite_params;
1882 struct crypto_unittest_params *ut_params = &unittest_params;
1884 /* Generate Crypto op data structure */
1885 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1886 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1887 TEST_ASSERT_NOT_NULL(ut_params->op,
1888 "Failed to allocate pktmbuf offload");
1890 /* Set crypto operation data parameters */
1891 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1893 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1895 /* set crypto operation source mbuf */
1896 sym_op->m_src = ut_params->ibuf;
1899 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1901 sym_op->cipher.data.length = cipher_len;
1902 sym_op->cipher.data.offset = cipher_offset;
1907 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1908 unsigned int cipher_len,
1909 unsigned int cipher_offset)
1911 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 struct crypto_unittest_params *ut_params = &unittest_params;
1914 /* Generate Crypto op data structure */
1915 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1916 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1917 TEST_ASSERT_NOT_NULL(ut_params->op,
1918 "Failed to allocate pktmbuf offload");
1920 /* Set crypto operation data parameters */
1921 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1923 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1925 /* set crypto operation source mbuf */
1926 sym_op->m_src = ut_params->ibuf;
1927 sym_op->m_dst = ut_params->obuf;
1930 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1932 sym_op->cipher.data.length = cipher_len;
1933 sym_op->cipher.data.offset = cipher_offset;
1938 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1939 enum rte_crypto_cipher_operation cipher_op,
1940 enum rte_crypto_auth_operation auth_op,
1941 enum rte_crypto_auth_algorithm auth_algo,
1942 enum rte_crypto_cipher_algorithm cipher_algo,
1943 const uint8_t *key, uint8_t key_len,
1944 uint8_t auth_iv_len, uint8_t auth_len,
1945 uint8_t cipher_iv_len)
1948 uint8_t cipher_auth_key[key_len];
1951 struct crypto_testsuite_params *ts_params = &testsuite_params;
1952 struct crypto_unittest_params *ut_params = &unittest_params;
1954 memcpy(cipher_auth_key, key, key_len);
1956 /* Setup Authentication Parameters */
1957 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1958 ut_params->auth_xform.next = NULL;
1960 ut_params->auth_xform.auth.op = auth_op;
1961 ut_params->auth_xform.auth.algo = auth_algo;
1962 ut_params->auth_xform.auth.key.length = key_len;
1963 /* Hash key = cipher key */
1964 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1965 ut_params->auth_xform.auth.digest_length = auth_len;
1966 /* Auth IV will be after cipher IV */
1967 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1968 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1970 /* Setup Cipher Parameters */
1971 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1972 ut_params->cipher_xform.next = &ut_params->auth_xform;
1974 ut_params->cipher_xform.cipher.algo = cipher_algo;
1975 ut_params->cipher_xform.cipher.op = cipher_op;
1976 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1977 ut_params->cipher_xform.cipher.key.length = key_len;
1978 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1979 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1981 debug_hexdump(stdout, "key:", key, key_len);
1983 /* Create Crypto session*/
1984 ut_params->sess = rte_cryptodev_sym_session_create(
1985 ts_params->session_mpool);
1986 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1988 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1989 &ut_params->cipher_xform,
1990 ts_params->session_priv_mpool);
1991 if (status == -ENOTSUP)
1994 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1999 create_wireless_cipher_auth_session(uint8_t dev_id,
2000 enum rte_crypto_cipher_operation cipher_op,
2001 enum rte_crypto_auth_operation auth_op,
2002 enum rte_crypto_auth_algorithm auth_algo,
2003 enum rte_crypto_cipher_algorithm cipher_algo,
2004 const struct wireless_test_data *tdata)
2006 const uint8_t key_len = tdata->key.len;
2007 uint8_t cipher_auth_key[key_len];
2010 struct crypto_testsuite_params *ts_params = &testsuite_params;
2011 struct crypto_unittest_params *ut_params = &unittest_params;
2012 const uint8_t *key = tdata->key.data;
2013 const uint8_t auth_len = tdata->digest.len;
2014 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2015 uint8_t auth_iv_len = tdata->auth_iv.len;
2017 memcpy(cipher_auth_key, key, key_len);
2019 /* Setup Authentication Parameters */
2020 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2021 ut_params->auth_xform.next = NULL;
2023 ut_params->auth_xform.auth.op = auth_op;
2024 ut_params->auth_xform.auth.algo = auth_algo;
2025 ut_params->auth_xform.auth.key.length = key_len;
2026 /* Hash key = cipher key */
2027 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2028 ut_params->auth_xform.auth.digest_length = auth_len;
2029 /* Auth IV will be after cipher IV */
2030 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2031 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2033 /* Setup Cipher Parameters */
2034 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2035 ut_params->cipher_xform.next = &ut_params->auth_xform;
2037 ut_params->cipher_xform.cipher.algo = cipher_algo;
2038 ut_params->cipher_xform.cipher.op = cipher_op;
2039 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2040 ut_params->cipher_xform.cipher.key.length = key_len;
2041 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2042 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2045 debug_hexdump(stdout, "key:", key, key_len);
2047 /* Create Crypto session*/
2048 ut_params->sess = rte_cryptodev_sym_session_create(
2049 ts_params->session_mpool);
2051 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2052 &ut_params->cipher_xform,
2053 ts_params->session_priv_mpool);
2055 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2056 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2061 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2062 const struct wireless_test_data *tdata)
2064 return create_wireless_cipher_auth_session(dev_id,
2065 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2066 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2067 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2071 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2072 enum rte_crypto_cipher_operation cipher_op,
2073 enum rte_crypto_auth_operation auth_op,
2074 enum rte_crypto_auth_algorithm auth_algo,
2075 enum rte_crypto_cipher_algorithm cipher_algo,
2076 const uint8_t *key, const uint8_t key_len,
2077 uint8_t auth_iv_len, uint8_t auth_len,
2078 uint8_t cipher_iv_len)
2080 uint8_t auth_cipher_key[key_len];
2082 struct crypto_testsuite_params *ts_params = &testsuite_params;
2083 struct crypto_unittest_params *ut_params = &unittest_params;
2085 memcpy(auth_cipher_key, key, key_len);
2087 /* Setup Authentication Parameters */
2088 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2089 ut_params->auth_xform.auth.op = auth_op;
2090 ut_params->auth_xform.next = &ut_params->cipher_xform;
2091 ut_params->auth_xform.auth.algo = auth_algo;
2092 ut_params->auth_xform.auth.key.length = key_len;
2093 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2094 ut_params->auth_xform.auth.digest_length = auth_len;
2095 /* Auth IV will be after cipher IV */
2096 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2097 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2099 /* Setup Cipher Parameters */
2100 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2101 ut_params->cipher_xform.next = NULL;
2102 ut_params->cipher_xform.cipher.algo = cipher_algo;
2103 ut_params->cipher_xform.cipher.op = cipher_op;
2104 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2105 ut_params->cipher_xform.cipher.key.length = key_len;
2106 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2107 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2109 debug_hexdump(stdout, "key:", key, key_len);
2111 /* Create Crypto session*/
2112 ut_params->sess = rte_cryptodev_sym_session_create(
2113 ts_params->session_mpool);
2114 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2116 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2117 ut_params->auth_xform.next = NULL;
2118 ut_params->cipher_xform.next = &ut_params->auth_xform;
2119 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2120 &ut_params->cipher_xform,
2121 ts_params->session_priv_mpool);
2124 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2125 &ut_params->auth_xform,
2126 ts_params->session_priv_mpool);
2128 if (status == -ENOTSUP)
2131 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2137 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2138 unsigned int auth_tag_len,
2139 const uint8_t *iv, unsigned int iv_len,
2140 unsigned int data_pad_len,
2141 enum rte_crypto_auth_operation op,
2142 unsigned int auth_len, unsigned int auth_offset)
2144 struct crypto_testsuite_params *ts_params = &testsuite_params;
2146 struct crypto_unittest_params *ut_params = &unittest_params;
2148 /* Generate Crypto op data structure */
2149 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2150 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2151 TEST_ASSERT_NOT_NULL(ut_params->op,
2152 "Failed to allocate pktmbuf offload");
2154 /* Set crypto operation data parameters */
2155 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2157 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2159 /* set crypto operation source mbuf */
2160 sym_op->m_src = ut_params->ibuf;
2163 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2166 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2167 ut_params->ibuf, auth_tag_len);
2169 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2170 "no room to append auth tag");
2171 ut_params->digest = sym_op->auth.digest.data;
2172 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2173 ut_params->ibuf, data_pad_len);
2174 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2175 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2177 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2179 debug_hexdump(stdout, "digest:",
2180 sym_op->auth.digest.data,
2183 sym_op->auth.data.length = auth_len;
2184 sym_op->auth.data.offset = auth_offset;
2190 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2191 enum rte_crypto_auth_operation op)
2193 struct crypto_testsuite_params *ts_params = &testsuite_params;
2194 struct crypto_unittest_params *ut_params = &unittest_params;
2196 const uint8_t *auth_tag = tdata->digest.data;
2197 const unsigned int auth_tag_len = tdata->digest.len;
2198 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2199 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2201 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2202 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2203 const uint8_t *auth_iv = tdata->auth_iv.data;
2204 const uint8_t auth_iv_len = tdata->auth_iv.len;
2205 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2206 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2208 /* Generate Crypto op data structure */
2209 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2210 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2211 TEST_ASSERT_NOT_NULL(ut_params->op,
2212 "Failed to allocate pktmbuf offload");
2213 /* Set crypto operation data parameters */
2214 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2216 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2218 /* set crypto operation source mbuf */
2219 sym_op->m_src = ut_params->ibuf;
2222 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2223 ut_params->ibuf, auth_tag_len);
2225 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2226 "no room to append auth tag");
2227 ut_params->digest = sym_op->auth.digest.data;
2228 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2229 ut_params->ibuf, data_pad_len);
2230 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2231 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2233 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2235 debug_hexdump(stdout, "digest:",
2236 sym_op->auth.digest.data,
2239 /* Copy cipher and auth IVs at the end of the crypto operation */
2240 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2242 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2243 iv_ptr += cipher_iv_len;
2244 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2246 sym_op->cipher.data.length = cipher_len;
2247 sym_op->cipher.data.offset = 0;
2248 sym_op->auth.data.length = auth_len;
2249 sym_op->auth.data.offset = 0;
2255 create_zuc_cipher_hash_generate_operation(
2256 const struct wireless_test_data *tdata)
2258 return create_wireless_cipher_hash_operation(tdata,
2259 RTE_CRYPTO_AUTH_OP_GENERATE);
2263 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2264 const unsigned auth_tag_len,
2265 const uint8_t *auth_iv, uint8_t auth_iv_len,
2266 unsigned data_pad_len,
2267 enum rte_crypto_auth_operation op,
2268 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2269 const unsigned cipher_len, const unsigned cipher_offset,
2270 const unsigned auth_len, const unsigned auth_offset)
2272 struct crypto_testsuite_params *ts_params = &testsuite_params;
2273 struct crypto_unittest_params *ut_params = &unittest_params;
2275 enum rte_crypto_cipher_algorithm cipher_algo =
2276 ut_params->cipher_xform.cipher.algo;
2277 enum rte_crypto_auth_algorithm auth_algo =
2278 ut_params->auth_xform.auth.algo;
2280 /* Generate Crypto op data structure */
2281 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2282 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2283 TEST_ASSERT_NOT_NULL(ut_params->op,
2284 "Failed to allocate pktmbuf offload");
2285 /* Set crypto operation data parameters */
2286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2290 /* set crypto operation source mbuf */
2291 sym_op->m_src = ut_params->ibuf;
2294 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2295 ut_params->ibuf, auth_tag_len);
2297 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2298 "no room to append auth tag");
2299 ut_params->digest = sym_op->auth.digest.data;
2301 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2302 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2303 ut_params->ibuf, data_pad_len);
2305 struct rte_mbuf *m = ut_params->ibuf;
2306 unsigned int offset = data_pad_len;
2308 while (offset > m->data_len && m->next != NULL) {
2309 offset -= m->data_len;
2312 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2316 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2317 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2319 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2321 debug_hexdump(stdout, "digest:",
2322 sym_op->auth.digest.data,
2325 /* Copy cipher and auth IVs at the end of the crypto operation */
2326 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2328 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2329 iv_ptr += cipher_iv_len;
2330 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2332 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2333 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2334 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2335 sym_op->cipher.data.length = cipher_len;
2336 sym_op->cipher.data.offset = cipher_offset;
2338 sym_op->cipher.data.length = cipher_len >> 3;
2339 sym_op->cipher.data.offset = cipher_offset >> 3;
2342 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2343 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2344 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2345 sym_op->auth.data.length = auth_len;
2346 sym_op->auth.data.offset = auth_offset;
2348 sym_op->auth.data.length = auth_len >> 3;
2349 sym_op->auth.data.offset = auth_offset >> 3;
2356 create_wireless_algo_auth_cipher_operation(
2357 const uint8_t *auth_tag, unsigned int auth_tag_len,
2358 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2359 const uint8_t *auth_iv, uint8_t auth_iv_len,
2360 unsigned int data_pad_len,
2361 unsigned int cipher_len, unsigned int cipher_offset,
2362 unsigned int auth_len, unsigned int auth_offset,
2363 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2365 struct crypto_testsuite_params *ts_params = &testsuite_params;
2366 struct crypto_unittest_params *ut_params = &unittest_params;
2368 enum rte_crypto_cipher_algorithm cipher_algo =
2369 ut_params->cipher_xform.cipher.algo;
2370 enum rte_crypto_auth_algorithm auth_algo =
2371 ut_params->auth_xform.auth.algo;
2373 /* Generate Crypto op data structure */
2374 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2375 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2376 TEST_ASSERT_NOT_NULL(ut_params->op,
2377 "Failed to allocate pktmbuf offload");
2379 /* Set crypto operation data parameters */
2380 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2382 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2384 /* set crypto operation mbufs */
2385 sym_op->m_src = ut_params->ibuf;
2386 if (op_mode == OUT_OF_PLACE)
2387 sym_op->m_dst = ut_params->obuf;
2391 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2392 (op_mode == IN_PLACE ?
2393 ut_params->ibuf : ut_params->obuf),
2394 uint8_t *, data_pad_len);
2395 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2396 (op_mode == IN_PLACE ?
2397 ut_params->ibuf : ut_params->obuf),
2399 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2401 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2402 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2403 sym_op->m_src : sym_op->m_dst);
2404 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2405 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2406 sgl_buf = sgl_buf->next;
2408 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2409 uint8_t *, remaining_off);
2410 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2412 memset(sym_op->auth.digest.data, 0, remaining_off);
2413 while (sgl_buf->next != NULL) {
2414 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2415 0, rte_pktmbuf_data_len(sgl_buf));
2416 sgl_buf = sgl_buf->next;
2420 /* Copy digest for the verification */
2422 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2424 /* Copy cipher and auth IVs at the end of the crypto operation */
2425 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2426 ut_params->op, uint8_t *, IV_OFFSET);
2428 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2429 iv_ptr += cipher_iv_len;
2430 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2432 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2433 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2434 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2435 sym_op->cipher.data.length = cipher_len;
2436 sym_op->cipher.data.offset = cipher_offset;
2438 sym_op->cipher.data.length = cipher_len >> 3;
2439 sym_op->cipher.data.offset = cipher_offset >> 3;
2442 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2443 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2444 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2445 sym_op->auth.data.length = auth_len;
2446 sym_op->auth.data.offset = auth_offset;
2448 sym_op->auth.data.length = auth_len >> 3;
2449 sym_op->auth.data.offset = auth_offset >> 3;
2456 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2458 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2462 unsigned plaintext_pad_len;
2463 unsigned plaintext_len;
2466 /* QAT PMD supports byte-aligned data only */
2467 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2468 (gbl_driver_id == rte_cryptodev_driver_id_get(
2469 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2472 /* Verify the capabilities */
2473 struct rte_cryptodev_sym_capability_idx cap_idx;
2474 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2475 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2476 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2480 /* Create SNOW 3G session */
2481 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2482 tdata->key.data, tdata->key.len,
2483 tdata->auth_iv.len, tdata->digest.len,
2484 RTE_CRYPTO_AUTH_OP_GENERATE,
2485 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2489 /* alloc mbuf and set payload */
2490 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2492 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2493 rte_pktmbuf_tailroom(ut_params->ibuf));
2495 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2496 /* Append data which is padded to a multiple of */
2497 /* the algorithms block size */
2498 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2499 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2501 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2503 /* Create SNOW 3G operation */
2504 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2505 tdata->auth_iv.data, tdata->auth_iv.len,
2506 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2507 tdata->validAuthLenInBits.len,
2512 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2514 ut_params->obuf = ut_params->op->sym->m_src;
2515 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2516 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2517 + plaintext_pad_len;
2520 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2523 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2524 "SNOW 3G Generated auth tag not as expected");
2530 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2532 struct crypto_testsuite_params *ts_params = &testsuite_params;
2533 struct crypto_unittest_params *ut_params = &unittest_params;
2536 unsigned plaintext_pad_len;
2537 unsigned plaintext_len;
2540 /* QAT PMD supports byte-aligned data only */
2541 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2542 (gbl_driver_id == rte_cryptodev_driver_id_get(
2543 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2546 /* Verify the capabilities */
2547 struct rte_cryptodev_sym_capability_idx cap_idx;
2548 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2549 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2550 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2554 /* Create SNOW 3G session */
2555 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2556 tdata->key.data, tdata->key.len,
2557 tdata->auth_iv.len, tdata->digest.len,
2558 RTE_CRYPTO_AUTH_OP_VERIFY,
2559 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2562 /* alloc mbuf and set payload */
2563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2565 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2566 rte_pktmbuf_tailroom(ut_params->ibuf));
2568 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2569 /* Append data which is padded to a multiple of */
2570 /* the algorithms block size */
2571 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2572 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2574 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2576 /* Create SNOW 3G operation */
2577 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2579 tdata->auth_iv.data, tdata->auth_iv.len,
2581 RTE_CRYPTO_AUTH_OP_VERIFY,
2582 tdata->validAuthLenInBits.len,
2587 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2589 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2590 ut_params->obuf = ut_params->op->sym->m_src;
2591 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2592 + plaintext_pad_len;
2595 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2604 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2606 struct crypto_testsuite_params *ts_params = &testsuite_params;
2607 struct crypto_unittest_params *ut_params = &unittest_params;
2610 unsigned plaintext_pad_len;
2611 unsigned plaintext_len;
2614 /* Verify the capabilities */
2615 struct rte_cryptodev_sym_capability_idx cap_idx;
2616 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2617 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2618 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2622 /* Create KASUMI session */
2623 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2624 tdata->key.data, tdata->key.len,
2625 0, tdata->digest.len,
2626 RTE_CRYPTO_AUTH_OP_GENERATE,
2627 RTE_CRYPTO_AUTH_KASUMI_F9);
2631 /* alloc mbuf and set payload */
2632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2634 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2635 rte_pktmbuf_tailroom(ut_params->ibuf));
2637 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2638 /* Append data which is padded to a multiple of */
2639 /* the algorithms block size */
2640 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2641 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2643 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2645 /* Create KASUMI operation */
2646 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2648 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2649 tdata->plaintext.len,
2654 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2655 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2658 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2661 ut_params->obuf = ut_params->op->sym->m_src;
2662 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2663 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2664 + plaintext_pad_len;
2667 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2670 DIGEST_BYTE_LENGTH_KASUMI_F9,
2671 "KASUMI Generated auth tag not as expected");
2677 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2679 struct crypto_testsuite_params *ts_params = &testsuite_params;
2680 struct crypto_unittest_params *ut_params = &unittest_params;
2683 unsigned plaintext_pad_len;
2684 unsigned plaintext_len;
2687 /* Verify the capabilities */
2688 struct rte_cryptodev_sym_capability_idx cap_idx;
2689 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2690 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2691 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2695 /* Create KASUMI session */
2696 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2697 tdata->key.data, tdata->key.len,
2698 0, tdata->digest.len,
2699 RTE_CRYPTO_AUTH_OP_VERIFY,
2700 RTE_CRYPTO_AUTH_KASUMI_F9);
2703 /* alloc mbuf and set payload */
2704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2707 rte_pktmbuf_tailroom(ut_params->ibuf));
2709 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2710 /* Append data which is padded to a multiple */
2711 /* of the algorithms block size */
2712 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2713 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2715 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2717 /* Create KASUMI operation */
2718 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2722 RTE_CRYPTO_AUTH_OP_VERIFY,
2723 tdata->plaintext.len,
2728 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2730 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2731 ut_params->obuf = ut_params->op->sym->m_src;
2732 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2733 + plaintext_pad_len;
2736 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2745 test_snow3g_hash_generate_test_case_1(void)
2747 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2751 test_snow3g_hash_generate_test_case_2(void)
2753 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2757 test_snow3g_hash_generate_test_case_3(void)
2759 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2763 test_snow3g_hash_generate_test_case_4(void)
2765 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2769 test_snow3g_hash_generate_test_case_5(void)
2771 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2775 test_snow3g_hash_generate_test_case_6(void)
2777 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2781 test_snow3g_hash_verify_test_case_1(void)
2783 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2788 test_snow3g_hash_verify_test_case_2(void)
2790 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2794 test_snow3g_hash_verify_test_case_3(void)
2796 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2800 test_snow3g_hash_verify_test_case_4(void)
2802 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2806 test_snow3g_hash_verify_test_case_5(void)
2808 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2812 test_snow3g_hash_verify_test_case_6(void)
2814 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2818 test_kasumi_hash_generate_test_case_1(void)
2820 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2824 test_kasumi_hash_generate_test_case_2(void)
2826 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2830 test_kasumi_hash_generate_test_case_3(void)
2832 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2836 test_kasumi_hash_generate_test_case_4(void)
2838 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2842 test_kasumi_hash_generate_test_case_5(void)
2844 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2848 test_kasumi_hash_generate_test_case_6(void)
2850 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2854 test_kasumi_hash_verify_test_case_1(void)
2856 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2860 test_kasumi_hash_verify_test_case_2(void)
2862 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2866 test_kasumi_hash_verify_test_case_3(void)
2868 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2872 test_kasumi_hash_verify_test_case_4(void)
2874 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2878 test_kasumi_hash_verify_test_case_5(void)
2880 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2884 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2886 struct crypto_testsuite_params *ts_params = &testsuite_params;
2887 struct crypto_unittest_params *ut_params = &unittest_params;
2890 uint8_t *plaintext, *ciphertext;
2891 unsigned plaintext_pad_len;
2892 unsigned plaintext_len;
2894 /* Verify the capabilities */
2895 struct rte_cryptodev_sym_capability_idx cap_idx;
2896 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2897 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2898 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2902 /* Create KASUMI session */
2903 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2904 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2905 RTE_CRYPTO_CIPHER_KASUMI_F8,
2906 tdata->key.data, tdata->key.len,
2907 tdata->cipher_iv.len);
2911 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2913 /* Clear mbuf payload */
2914 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2915 rte_pktmbuf_tailroom(ut_params->ibuf));
2917 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2918 /* Append data which is padded to a multiple */
2919 /* of the algorithms block size */
2920 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2921 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2923 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2925 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2927 /* Create KASUMI operation */
2928 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2929 tdata->cipher_iv.len,
2930 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2931 tdata->validCipherOffsetInBits.len);
2935 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2937 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2939 ut_params->obuf = ut_params->op->sym->m_dst;
2940 if (ut_params->obuf)
2941 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2943 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2945 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2947 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2948 (tdata->validCipherOffsetInBits.len >> 3);
2950 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2952 reference_ciphertext,
2953 tdata->validCipherLenInBits.len,
2954 "KASUMI Ciphertext data not as expected");
2959 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2961 struct crypto_testsuite_params *ts_params = &testsuite_params;
2962 struct crypto_unittest_params *ut_params = &unittest_params;
2966 unsigned int plaintext_pad_len;
2967 unsigned int plaintext_len;
2969 uint8_t buffer[10000];
2970 const uint8_t *ciphertext;
2972 struct rte_cryptodev_info dev_info;
2974 /* Verify the capabilities */
2975 struct rte_cryptodev_sym_capability_idx cap_idx;
2976 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2977 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2978 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2984 uint64_t feat_flags = dev_info.feature_flags;
2986 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2987 printf("Device doesn't support in-place scatter-gather. "
2992 /* Create KASUMI session */
2993 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2994 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2995 RTE_CRYPTO_CIPHER_KASUMI_F8,
2996 tdata->key.data, tdata->key.len,
2997 tdata->cipher_iv.len);
3001 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3004 /* Append data which is padded to a multiple */
3005 /* of the algorithms block size */
3006 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3008 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3009 plaintext_pad_len, 10, 0);
3011 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3013 /* Create KASUMI operation */
3014 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3015 tdata->cipher_iv.len,
3016 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3017 tdata->validCipherOffsetInBits.len);
3021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3025 ut_params->obuf = ut_params->op->sym->m_dst;
3027 if (ut_params->obuf)
3028 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3029 plaintext_len, buffer);
3031 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3032 tdata->validCipherOffsetInBits.len >> 3,
3033 plaintext_len, buffer);
3036 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3038 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3039 (tdata->validCipherOffsetInBits.len >> 3);
3041 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3043 reference_ciphertext,
3044 tdata->validCipherLenInBits.len,
3045 "KASUMI Ciphertext data not as expected");
3050 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3052 struct crypto_testsuite_params *ts_params = &testsuite_params;
3053 struct crypto_unittest_params *ut_params = &unittest_params;
3056 uint8_t *plaintext, *ciphertext;
3057 unsigned plaintext_pad_len;
3058 unsigned plaintext_len;
3060 /* Verify the capabilities */
3061 struct rte_cryptodev_sym_capability_idx cap_idx;
3062 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3063 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3064 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3068 /* Create KASUMI session */
3069 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3070 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3071 RTE_CRYPTO_CIPHER_KASUMI_F8,
3072 tdata->key.data, tdata->key.len,
3073 tdata->cipher_iv.len);
3077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3078 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3080 /* Clear mbuf payload */
3081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3082 rte_pktmbuf_tailroom(ut_params->ibuf));
3084 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3085 /* Append data which is padded to a multiple */
3086 /* of the algorithms block size */
3087 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3088 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3090 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3091 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3093 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3095 /* Create KASUMI operation */
3096 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3097 tdata->cipher_iv.len,
3098 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3099 tdata->validCipherOffsetInBits.len);
3103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3107 ut_params->obuf = ut_params->op->sym->m_dst;
3108 if (ut_params->obuf)
3109 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3111 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3113 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3115 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3116 (tdata->validCipherOffsetInBits.len >> 3);
3118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3120 reference_ciphertext,
3121 tdata->validCipherLenInBits.len,
3122 "KASUMI Ciphertext data not as expected");
3127 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3129 struct crypto_testsuite_params *ts_params = &testsuite_params;
3130 struct crypto_unittest_params *ut_params = &unittest_params;
3133 unsigned int plaintext_pad_len;
3134 unsigned int plaintext_len;
3136 const uint8_t *ciphertext;
3137 uint8_t buffer[2048];
3139 struct rte_cryptodev_info dev_info;
3141 /* Verify the capabilities */
3142 struct rte_cryptodev_sym_capability_idx cap_idx;
3143 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3144 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3145 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3149 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3151 uint64_t feat_flags = dev_info.feature_flags;
3152 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3153 printf("Device doesn't support out-of-place scatter-gather "
3154 "in both input and output mbufs. "
3159 /* Create KASUMI session */
3160 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3161 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3162 RTE_CRYPTO_CIPHER_KASUMI_F8,
3163 tdata->key.data, tdata->key.len,
3164 tdata->cipher_iv.len);
3168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3169 /* Append data which is padded to a multiple */
3170 /* of the algorithms block size */
3171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3173 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3174 plaintext_pad_len, 10, 0);
3175 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3176 plaintext_pad_len, 3, 0);
3178 /* Append data which is padded to a multiple */
3179 /* of the algorithms block size */
3180 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3182 /* Create KASUMI operation */
3183 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3184 tdata->cipher_iv.len,
3185 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3186 tdata->validCipherOffsetInBits.len);
3190 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3192 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3194 ut_params->obuf = ut_params->op->sym->m_dst;
3195 if (ut_params->obuf)
3196 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3197 plaintext_pad_len, buffer);
3199 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3200 tdata->validCipherOffsetInBits.len >> 3,
3201 plaintext_pad_len, buffer);
3203 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3204 (tdata->validCipherOffsetInBits.len >> 3);
3206 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3208 reference_ciphertext,
3209 tdata->validCipherLenInBits.len,
3210 "KASUMI Ciphertext data not as expected");
3216 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3218 struct crypto_testsuite_params *ts_params = &testsuite_params;
3219 struct crypto_unittest_params *ut_params = &unittest_params;
3222 uint8_t *ciphertext, *plaintext;
3223 unsigned ciphertext_pad_len;
3224 unsigned ciphertext_len;
3226 /* Verify the capabilities */
3227 struct rte_cryptodev_sym_capability_idx cap_idx;
3228 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3229 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3230 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3234 /* Create KASUMI session */
3235 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3236 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3237 RTE_CRYPTO_CIPHER_KASUMI_F8,
3238 tdata->key.data, tdata->key.len,
3239 tdata->cipher_iv.len);
3243 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3244 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3246 /* Clear mbuf payload */
3247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3248 rte_pktmbuf_tailroom(ut_params->ibuf));
3250 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3251 /* Append data which is padded to a multiple */
3252 /* of the algorithms block size */
3253 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3254 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3255 ciphertext_pad_len);
3256 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3257 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3259 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3261 /* Create KASUMI operation */
3262 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3263 tdata->cipher_iv.len,
3264 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3265 tdata->validCipherOffsetInBits.len);
3269 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3271 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3273 ut_params->obuf = ut_params->op->sym->m_dst;
3274 if (ut_params->obuf)
3275 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3277 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3279 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3281 const uint8_t *reference_plaintext = tdata->plaintext.data +
3282 (tdata->validCipherOffsetInBits.len >> 3);
3284 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3286 reference_plaintext,
3287 tdata->validCipherLenInBits.len,
3288 "KASUMI Plaintext data not as expected");
3293 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3295 struct crypto_testsuite_params *ts_params = &testsuite_params;
3296 struct crypto_unittest_params *ut_params = &unittest_params;
3299 uint8_t *ciphertext, *plaintext;
3300 unsigned ciphertext_pad_len;
3301 unsigned ciphertext_len;
3303 /* Verify the capabilities */
3304 struct rte_cryptodev_sym_capability_idx cap_idx;
3305 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3306 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3307 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3311 /* Create KASUMI session */
3312 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3313 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3314 RTE_CRYPTO_CIPHER_KASUMI_F8,
3315 tdata->key.data, tdata->key.len,
3316 tdata->cipher_iv.len);
3320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3322 /* Clear mbuf payload */
3323 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3324 rte_pktmbuf_tailroom(ut_params->ibuf));
3326 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3327 /* Append data which is padded to a multiple */
3328 /* of the algorithms block size */
3329 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3330 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3331 ciphertext_pad_len);
3332 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3334 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3336 /* Create KASUMI operation */
3337 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3338 tdata->cipher_iv.len,
3339 tdata->ciphertext.len,
3340 tdata->validCipherOffsetInBits.len);
3344 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3346 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3348 ut_params->obuf = ut_params->op->sym->m_dst;
3349 if (ut_params->obuf)
3350 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3352 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3354 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3356 const uint8_t *reference_plaintext = tdata->plaintext.data +
3357 (tdata->validCipherOffsetInBits.len >> 3);
3359 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3361 reference_plaintext,
3362 tdata->validCipherLenInBits.len,
3363 "KASUMI Plaintext data not as expected");
3368 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3370 struct crypto_testsuite_params *ts_params = &testsuite_params;
3371 struct crypto_unittest_params *ut_params = &unittest_params;
3374 uint8_t *plaintext, *ciphertext;
3375 unsigned plaintext_pad_len;
3376 unsigned plaintext_len;
3378 /* Verify the capabilities */
3379 struct rte_cryptodev_sym_capability_idx cap_idx;
3380 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3381 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3382 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3386 /* Create SNOW 3G session */
3387 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3388 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3389 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3390 tdata->key.data, tdata->key.len,
3391 tdata->cipher_iv.len);
3395 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3397 /* Clear mbuf payload */
3398 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3399 rte_pktmbuf_tailroom(ut_params->ibuf));
3401 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3402 /* Append data which is padded to a multiple of */
3403 /* the algorithms block size */
3404 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3405 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3407 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3409 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3411 /* Create SNOW 3G operation */
3412 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3413 tdata->cipher_iv.len,
3414 tdata->validCipherLenInBits.len,
3419 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3421 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3423 ut_params->obuf = ut_params->op->sym->m_dst;
3424 if (ut_params->obuf)
3425 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3427 ciphertext = plaintext;
3429 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3432 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3434 tdata->ciphertext.data,
3435 tdata->validDataLenInBits.len,
3436 "SNOW 3G Ciphertext data not as expected");
3442 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3444 struct crypto_testsuite_params *ts_params = &testsuite_params;
3445 struct crypto_unittest_params *ut_params = &unittest_params;
3446 uint8_t *plaintext, *ciphertext;
3449 unsigned plaintext_pad_len;
3450 unsigned plaintext_len;
3452 /* Verify the capabilities */
3453 struct rte_cryptodev_sym_capability_idx cap_idx;
3454 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3455 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3456 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3460 /* Create SNOW 3G session */
3461 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3462 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3463 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3464 tdata->key.data, tdata->key.len,
3465 tdata->cipher_iv.len);
3469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3470 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3472 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3473 "Failed to allocate input buffer in mempool");
3474 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3475 "Failed to allocate output buffer in mempool");
3477 /* Clear mbuf payload */
3478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3479 rte_pktmbuf_tailroom(ut_params->ibuf));
3481 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3482 /* Append data which is padded to a multiple of */
3483 /* the algorithms block size */
3484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3487 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3488 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3490 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3492 /* Create SNOW 3G operation */
3493 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3494 tdata->cipher_iv.len,
3495 tdata->validCipherLenInBits.len,
3500 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3502 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3504 ut_params->obuf = ut_params->op->sym->m_dst;
3505 if (ut_params->obuf)
3506 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3508 ciphertext = plaintext;
3510 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3513 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3515 tdata->ciphertext.data,
3516 tdata->validDataLenInBits.len,
3517 "SNOW 3G Ciphertext data not as expected");
3522 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3524 struct crypto_testsuite_params *ts_params = &testsuite_params;
3525 struct crypto_unittest_params *ut_params = &unittest_params;
3528 unsigned int plaintext_pad_len;
3529 unsigned int plaintext_len;
3530 uint8_t buffer[10000];
3531 const uint8_t *ciphertext;
3533 struct rte_cryptodev_info dev_info;
3535 /* Verify the capabilities */
3536 struct rte_cryptodev_sym_capability_idx cap_idx;
3537 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3538 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3539 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3543 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3545 uint64_t feat_flags = dev_info.feature_flags;
3547 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3548 printf("Device doesn't support out-of-place scatter-gather "
3549 "in both input and output mbufs. "
3554 /* Create SNOW 3G session */
3555 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3556 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3557 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3558 tdata->key.data, tdata->key.len,
3559 tdata->cipher_iv.len);
3563 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3564 /* Append data which is padded to a multiple of */
3565 /* the algorithms block size */
3566 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3568 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3569 plaintext_pad_len, 10, 0);
3570 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3571 plaintext_pad_len, 3, 0);
3573 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3574 "Failed to allocate input buffer in mempool");
3575 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3576 "Failed to allocate output buffer in mempool");
3578 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3580 /* Create SNOW 3G operation */
3581 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3582 tdata->cipher_iv.len,
3583 tdata->validCipherLenInBits.len,
3588 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3590 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3592 ut_params->obuf = ut_params->op->sym->m_dst;
3593 if (ut_params->obuf)
3594 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3595 plaintext_len, buffer);
3597 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3598 plaintext_len, buffer);
3600 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3603 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3605 tdata->ciphertext.data,
3606 tdata->validDataLenInBits.len,
3607 "SNOW 3G Ciphertext data not as expected");
3612 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3614 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3616 uint8_t curr_byte, prev_byte;
3617 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3618 uint8_t lower_byte_mask = (1 << offset) - 1;
3621 prev_byte = buffer[0];
3622 buffer[0] >>= offset;
3624 for (i = 1; i < length_in_bytes; i++) {
3625 curr_byte = buffer[i];
3626 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3627 (curr_byte >> offset);
3628 prev_byte = curr_byte;
3633 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3635 struct crypto_testsuite_params *ts_params = &testsuite_params;
3636 struct crypto_unittest_params *ut_params = &unittest_params;
3637 uint8_t *plaintext, *ciphertext;
3639 uint32_t plaintext_len;
3640 uint32_t plaintext_pad_len;
3641 uint8_t extra_offset = 4;
3642 uint8_t *expected_ciphertext_shifted;
3644 /* QAT PMD supports byte-aligned data only */
3645 if (gbl_driver_id == rte_cryptodev_driver_id_get(
3646 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
3649 /* Verify the capabilities */
3650 struct rte_cryptodev_sym_capability_idx cap_idx;
3651 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3652 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3653 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3657 /* Create SNOW 3G session */
3658 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3659 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3660 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3661 tdata->key.data, tdata->key.len,
3662 tdata->cipher_iv.len);
3666 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3667 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3669 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3670 "Failed to allocate input buffer in mempool");
3671 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3672 "Failed to allocate output buffer in mempool");
3674 /* Clear mbuf payload */
3675 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3676 rte_pktmbuf_tailroom(ut_params->ibuf));
3678 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3680 * Append data which is padded to a
3681 * multiple of the algorithms block size
3683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3685 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3688 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3690 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3691 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3693 #ifdef RTE_APP_TEST_DEBUG
3694 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3696 /* Create SNOW 3G operation */
3697 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3698 tdata->cipher_iv.len,
3699 tdata->validCipherLenInBits.len,
3704 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3706 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3708 ut_params->obuf = ut_params->op->sym->m_dst;
3709 if (ut_params->obuf)
3710 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3712 ciphertext = plaintext;
3714 #ifdef RTE_APP_TEST_DEBUG
3715 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3718 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3720 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3721 "failed to reserve memory for ciphertext shifted\n");
3723 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3724 ceil_byte_length(tdata->ciphertext.len));
3725 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3728 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3730 expected_ciphertext_shifted,
3731 tdata->validDataLenInBits.len,
3733 "SNOW 3G Ciphertext data not as expected");
3737 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3739 struct crypto_testsuite_params *ts_params = &testsuite_params;
3740 struct crypto_unittest_params *ut_params = &unittest_params;
3744 uint8_t *plaintext, *ciphertext;
3745 unsigned ciphertext_pad_len;
3746 unsigned ciphertext_len;
3748 /* Verify the capabilities */
3749 struct rte_cryptodev_sym_capability_idx cap_idx;
3750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3751 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3752 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3756 /* Create SNOW 3G session */
3757 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3758 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3759 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3760 tdata->key.data, tdata->key.len,
3761 tdata->cipher_iv.len);
3765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3767 /* Clear mbuf payload */
3768 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3769 rte_pktmbuf_tailroom(ut_params->ibuf));
3771 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3772 /* Append data which is padded to a multiple of */
3773 /* the algorithms block size */
3774 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3775 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3776 ciphertext_pad_len);
3777 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3779 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3781 /* Create SNOW 3G operation */
3782 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3783 tdata->cipher_iv.len,
3784 tdata->validCipherLenInBits.len,
3785 tdata->cipher.offset_bits);
3789 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3791 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3792 ut_params->obuf = ut_params->op->sym->m_dst;
3793 if (ut_params->obuf)
3794 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3796 plaintext = ciphertext;
3798 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3801 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3802 tdata->plaintext.data,
3803 tdata->validDataLenInBits.len,
3804 "SNOW 3G Plaintext data not as expected");
3808 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3810 struct crypto_testsuite_params *ts_params = &testsuite_params;
3811 struct crypto_unittest_params *ut_params = &unittest_params;
3815 uint8_t *plaintext, *ciphertext;
3816 unsigned ciphertext_pad_len;
3817 unsigned ciphertext_len;
3819 /* Verify the capabilities */
3820 struct rte_cryptodev_sym_capability_idx cap_idx;
3821 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3822 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3823 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3827 /* Create SNOW 3G session */
3828 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3830 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831 tdata->key.data, tdata->key.len,
3832 tdata->cipher_iv.len);
3836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3840 "Failed to allocate input buffer");
3841 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3842 "Failed to allocate output buffer");
3844 /* Clear mbuf payload */
3845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846 rte_pktmbuf_tailroom(ut_params->ibuf));
3848 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3849 rte_pktmbuf_tailroom(ut_params->obuf));
3851 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3852 /* Append data which is padded to a multiple of */
3853 /* the algorithms block size */
3854 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3855 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3856 ciphertext_pad_len);
3857 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3858 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3860 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3862 /* Create SNOW 3G operation */
3863 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3864 tdata->cipher_iv.len,
3865 tdata->validCipherLenInBits.len,
3870 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3872 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3873 ut_params->obuf = ut_params->op->sym->m_dst;
3874 if (ut_params->obuf)
3875 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3877 plaintext = ciphertext;
3879 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3882 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3883 tdata->plaintext.data,
3884 tdata->validDataLenInBits.len,
3885 "SNOW 3G Plaintext data not as expected");
3890 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3892 struct crypto_testsuite_params *ts_params = &testsuite_params;
3893 struct crypto_unittest_params *ut_params = &unittest_params;
3897 uint8_t *plaintext, *ciphertext;
3898 unsigned int plaintext_pad_len;
3899 unsigned int plaintext_len;
3901 struct rte_cryptodev_sym_capability_idx cap_idx;
3903 /* Check if device supports ZUC EEA3 */
3904 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3905 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3907 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3911 /* Check if device supports ZUC EIA3 */
3912 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3913 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3915 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3919 /* Create ZUC session */
3920 retval = create_zuc_cipher_auth_encrypt_generate_session(
3921 ts_params->valid_devs[0],
3925 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3927 /* clear mbuf payload */
3928 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3929 rte_pktmbuf_tailroom(ut_params->ibuf));
3931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3932 /* Append data which is padded to a multiple of */
3933 /* the algorithms block size */
3934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3935 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3937 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3939 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3941 /* Create ZUC operation */
3942 retval = create_zuc_cipher_hash_generate_operation(tdata);
3946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3948 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3949 ut_params->obuf = ut_params->op->sym->m_src;
3950 if (ut_params->obuf)
3951 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3953 ciphertext = plaintext;
3955 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3959 tdata->ciphertext.data,
3960 tdata->validDataLenInBits.len,
3961 "ZUC Ciphertext data not as expected");
3963 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3964 + plaintext_pad_len;
3967 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3971 "ZUC Generated auth tag not as expected");
3976 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3978 struct crypto_testsuite_params *ts_params = &testsuite_params;
3979 struct crypto_unittest_params *ut_params = &unittest_params;
3983 uint8_t *plaintext, *ciphertext;
3984 unsigned plaintext_pad_len;
3985 unsigned plaintext_len;
3987 /* Verify the capabilities */
3988 struct rte_cryptodev_sym_capability_idx cap_idx;
3989 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3990 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3991 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3994 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3995 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3996 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4000 /* Create SNOW 3G session */
4001 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4002 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4003 RTE_CRYPTO_AUTH_OP_GENERATE,
4004 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4005 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4006 tdata->key.data, tdata->key.len,
4007 tdata->auth_iv.len, tdata->digest.len,
4008 tdata->cipher_iv.len);
4011 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013 /* clear mbuf payload */
4014 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4015 rte_pktmbuf_tailroom(ut_params->ibuf));
4017 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4018 /* Append data which is padded to a multiple of */
4019 /* the algorithms block size */
4020 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4021 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4023 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4025 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4027 /* Create SNOW 3G operation */
4028 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4029 tdata->digest.len, tdata->auth_iv.data,
4031 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4032 tdata->cipher_iv.data, tdata->cipher_iv.len,
4033 tdata->validCipherLenInBits.len,
4035 tdata->validAuthLenInBits.len,
4041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_src;
4045 if (ut_params->obuf)
4046 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 ciphertext = plaintext;
4050 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4054 tdata->ciphertext.data,
4055 tdata->validDataLenInBits.len,
4056 "SNOW 3G Ciphertext data not as expected");
4058 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4059 + plaintext_pad_len;
4062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4065 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4066 "SNOW 3G Generated auth tag not as expected");
4071 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4072 uint8_t op_mode, uint8_t verify)
4074 struct crypto_testsuite_params *ts_params = &testsuite_params;
4075 struct crypto_unittest_params *ut_params = &unittest_params;
4079 uint8_t *plaintext = NULL, *ciphertext = NULL;
4080 unsigned int plaintext_pad_len;
4081 unsigned int plaintext_len;
4082 unsigned int ciphertext_pad_len;
4083 unsigned int ciphertext_len;
4085 struct rte_cryptodev_info dev_info;
4087 /* Verify the capabilities */
4088 struct rte_cryptodev_sym_capability_idx cap_idx;
4089 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4090 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4091 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4094 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4095 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4096 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4100 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4102 uint64_t feat_flags = dev_info.feature_flags;
4104 if (op_mode == OUT_OF_PLACE) {
4105 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4106 printf("Device doesn't support digest encrypted.\n");
4111 /* Create SNOW 3G session */
4112 retval = create_wireless_algo_auth_cipher_session(
4113 ts_params->valid_devs[0],
4114 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4115 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4116 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4117 : RTE_CRYPTO_AUTH_OP_GENERATE),
4118 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4119 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4120 tdata->key.data, tdata->key.len,
4121 tdata->auth_iv.len, tdata->digest.len,
4122 tdata->cipher_iv.len);
4127 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4128 if (op_mode == OUT_OF_PLACE)
4129 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4131 /* clear mbuf payload */
4132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4133 rte_pktmbuf_tailroom(ut_params->ibuf));
4134 if (op_mode == OUT_OF_PLACE)
4135 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4136 rte_pktmbuf_tailroom(ut_params->obuf));
4138 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4139 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4140 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4141 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4144 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4145 ciphertext_pad_len);
4146 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4147 if (op_mode == OUT_OF_PLACE)
4148 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4149 debug_hexdump(stdout, "ciphertext:", ciphertext,
4152 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4154 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4155 if (op_mode == OUT_OF_PLACE)
4156 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4157 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4160 /* Create SNOW 3G operation */
4161 retval = create_wireless_algo_auth_cipher_operation(
4162 tdata->digest.data, tdata->digest.len,
4163 tdata->cipher_iv.data, tdata->cipher_iv.len,
4164 tdata->auth_iv.data, tdata->auth_iv.len,
4165 (tdata->digest.offset_bytes == 0 ?
4166 (verify ? ciphertext_pad_len : plaintext_pad_len)
4167 : tdata->digest.offset_bytes),
4168 tdata->validCipherLenInBits.len,
4169 tdata->cipher.offset_bits,
4170 tdata->validAuthLenInBits.len,
4171 tdata->auth.offset_bits,
4172 op_mode, 0, verify);
4177 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4182 ut_params->obuf = (op_mode == IN_PLACE ?
4183 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4186 if (ut_params->obuf)
4187 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4190 plaintext = ciphertext +
4191 (tdata->cipher.offset_bits >> 3);
4193 debug_hexdump(stdout, "plaintext:", plaintext,
4194 (tdata->plaintext.len >> 3) - tdata->digest.len);
4195 debug_hexdump(stdout, "plaintext expected:",
4196 tdata->plaintext.data,
4197 (tdata->plaintext.len >> 3) - tdata->digest.len);
4199 if (ut_params->obuf)
4200 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4203 ciphertext = plaintext;
4205 debug_hexdump(stdout, "ciphertext:", ciphertext,
4207 debug_hexdump(stdout, "ciphertext expected:",
4208 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4210 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4211 + (tdata->digest.offset_bytes == 0 ?
4212 plaintext_pad_len : tdata->digest.offset_bytes);
4214 debug_hexdump(stdout, "digest:", ut_params->digest,
4216 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4222 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4224 tdata->plaintext.data,
4225 tdata->plaintext.len >> 3,
4226 "SNOW 3G Plaintext data not as expected");
4228 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4230 tdata->ciphertext.data,
4231 tdata->validDataLenInBits.len,
4232 "SNOW 3G Ciphertext data not as expected");
4234 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4237 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4238 "SNOW 3G Generated auth tag not as expected");
4244 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4245 uint8_t op_mode, uint8_t verify)
4247 struct crypto_testsuite_params *ts_params = &testsuite_params;
4248 struct crypto_unittest_params *ut_params = &unittest_params;
4252 const uint8_t *plaintext = NULL;
4253 const uint8_t *ciphertext = NULL;
4254 const uint8_t *digest = NULL;
4255 unsigned int plaintext_pad_len;
4256 unsigned int plaintext_len;
4257 unsigned int ciphertext_pad_len;
4258 unsigned int ciphertext_len;
4259 uint8_t buffer[10000];
4260 uint8_t digest_buffer[10000];
4262 struct rte_cryptodev_info dev_info;
4264 /* Verify the capabilities */
4265 struct rte_cryptodev_sym_capability_idx cap_idx;
4266 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4267 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4271 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4272 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4273 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4277 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4279 uint64_t feat_flags = dev_info.feature_flags;
4281 if (op_mode == IN_PLACE) {
4282 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4283 printf("Device doesn't support in-place scatter-gather "
4284 "in both input and output mbufs.\n");
4288 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4289 printf("Device doesn't support out-of-place scatter-gather "
4290 "in both input and output mbufs.\n");
4293 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4294 printf("Device doesn't support digest encrypted.\n");
4299 /* Create SNOW 3G session */
4300 retval = create_wireless_algo_auth_cipher_session(
4301 ts_params->valid_devs[0],
4302 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4303 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4304 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4305 : RTE_CRYPTO_AUTH_OP_GENERATE),
4306 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4307 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4308 tdata->key.data, tdata->key.len,
4309 tdata->auth_iv.len, tdata->digest.len,
4310 tdata->cipher_iv.len);
4315 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4316 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4317 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4318 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4320 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4321 plaintext_pad_len, 15, 0);
4322 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4323 "Failed to allocate input buffer in mempool");
4325 if (op_mode == OUT_OF_PLACE) {
4326 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4327 plaintext_pad_len, 15, 0);
4328 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4329 "Failed to allocate output buffer in mempool");
4333 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4334 tdata->ciphertext.data);
4335 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4336 ciphertext_len, buffer);
4337 debug_hexdump(stdout, "ciphertext:", ciphertext,
4340 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4341 tdata->plaintext.data);
4342 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4343 plaintext_len, buffer);
4344 debug_hexdump(stdout, "plaintext:", plaintext,
4347 memset(buffer, 0, sizeof(buffer));
4349 /* Create SNOW 3G operation */
4350 retval = create_wireless_algo_auth_cipher_operation(
4351 tdata->digest.data, tdata->digest.len,
4352 tdata->cipher_iv.data, tdata->cipher_iv.len,
4353 tdata->auth_iv.data, tdata->auth_iv.len,
4354 (tdata->digest.offset_bytes == 0 ?
4355 (verify ? ciphertext_pad_len : plaintext_pad_len)
4356 : tdata->digest.offset_bytes),
4357 tdata->validCipherLenInBits.len,
4358 tdata->cipher.offset_bits,
4359 tdata->validAuthLenInBits.len,
4360 tdata->auth.offset_bits,
4361 op_mode, 1, verify);
4366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4371 ut_params->obuf = (op_mode == IN_PLACE ?
4372 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4375 if (ut_params->obuf)
4376 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4377 plaintext_len, buffer);
4379 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4380 plaintext_len, buffer);
4382 debug_hexdump(stdout, "plaintext:", plaintext,
4383 (tdata->plaintext.len >> 3) - tdata->digest.len);
4384 debug_hexdump(stdout, "plaintext expected:",
4385 tdata->plaintext.data,
4386 (tdata->plaintext.len >> 3) - tdata->digest.len);
4388 if (ut_params->obuf)
4389 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4390 ciphertext_len, buffer);
4392 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4393 ciphertext_len, buffer);
4395 debug_hexdump(stdout, "ciphertext:", ciphertext,
4397 debug_hexdump(stdout, "ciphertext expected:",
4398 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4400 if (ut_params->obuf)
4401 digest = rte_pktmbuf_read(ut_params->obuf,
4402 (tdata->digest.offset_bytes == 0 ?
4403 plaintext_pad_len : tdata->digest.offset_bytes),
4404 tdata->digest.len, digest_buffer);
4406 digest = rte_pktmbuf_read(ut_params->ibuf,
4407 (tdata->digest.offset_bytes == 0 ?
4408 plaintext_pad_len : tdata->digest.offset_bytes),
4409 tdata->digest.len, digest_buffer);
4411 debug_hexdump(stdout, "digest:", digest,
4413 debug_hexdump(stdout, "digest expected:",
4414 tdata->digest.data, tdata->digest.len);
4419 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4421 tdata->plaintext.data,
4422 tdata->plaintext.len >> 3,
4423 "SNOW 3G Plaintext data not as expected");
4425 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4427 tdata->ciphertext.data,
4428 tdata->validDataLenInBits.len,
4429 "SNOW 3G Ciphertext data not as expected");
4431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4434 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4435 "SNOW 3G Generated auth tag not as expected");
4441 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4442 uint8_t op_mode, uint8_t verify)
4444 struct crypto_testsuite_params *ts_params = &testsuite_params;
4445 struct crypto_unittest_params *ut_params = &unittest_params;
4449 uint8_t *plaintext = NULL, *ciphertext = NULL;
4450 unsigned int plaintext_pad_len;
4451 unsigned int plaintext_len;
4452 unsigned int ciphertext_pad_len;
4453 unsigned int ciphertext_len;
4455 struct rte_cryptodev_info dev_info;
4457 /* Verify the capabilities */
4458 struct rte_cryptodev_sym_capability_idx cap_idx;
4459 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4460 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4461 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4464 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4465 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4466 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4470 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4472 uint64_t feat_flags = dev_info.feature_flags;
4474 if (op_mode == OUT_OF_PLACE) {
4475 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4476 printf("Device doesn't support digest encrypted.\n");
4481 /* Create KASUMI session */
4482 retval = create_wireless_algo_auth_cipher_session(
4483 ts_params->valid_devs[0],
4484 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4485 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4486 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4487 : RTE_CRYPTO_AUTH_OP_GENERATE),
4488 RTE_CRYPTO_AUTH_KASUMI_F9,
4489 RTE_CRYPTO_CIPHER_KASUMI_F8,
4490 tdata->key.data, tdata->key.len,
4491 0, tdata->digest.len,
4492 tdata->cipher_iv.len);
4497 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4498 if (op_mode == OUT_OF_PLACE)
4499 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4501 /* clear mbuf payload */
4502 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4503 rte_pktmbuf_tailroom(ut_params->ibuf));
4504 if (op_mode == OUT_OF_PLACE)
4505 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4506 rte_pktmbuf_tailroom(ut_params->obuf));
4508 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4509 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4510 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4511 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4514 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4515 ciphertext_pad_len);
4516 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4517 if (op_mode == OUT_OF_PLACE)
4518 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4519 debug_hexdump(stdout, "ciphertext:", ciphertext,
4522 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4524 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4525 if (op_mode == OUT_OF_PLACE)
4526 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4527 debug_hexdump(stdout, "plaintext:", plaintext,
4531 /* Create KASUMI operation */
4532 retval = create_wireless_algo_auth_cipher_operation(
4533 tdata->digest.data, tdata->digest.len,
4534 tdata->cipher_iv.data, tdata->cipher_iv.len,
4536 (tdata->digest.offset_bytes == 0 ?
4537 (verify ? ciphertext_pad_len : plaintext_pad_len)
4538 : tdata->digest.offset_bytes),
4539 tdata->validCipherLenInBits.len,
4540 tdata->validCipherOffsetInBits.len,
4541 tdata->validAuthLenInBits.len,
4543 op_mode, 0, verify);
4548 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4551 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4553 ut_params->obuf = (op_mode == IN_PLACE ?
4554 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4558 if (ut_params->obuf)
4559 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4562 plaintext = ciphertext;
4564 debug_hexdump(stdout, "plaintext:", plaintext,
4565 (tdata->plaintext.len >> 3) - tdata->digest.len);
4566 debug_hexdump(stdout, "plaintext expected:",
4567 tdata->plaintext.data,
4568 (tdata->plaintext.len >> 3) - tdata->digest.len);
4570 if (ut_params->obuf)
4571 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4574 ciphertext = plaintext;
4576 debug_hexdump(stdout, "ciphertext:", ciphertext,
4578 debug_hexdump(stdout, "ciphertext expected:",
4579 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4581 ut_params->digest = rte_pktmbuf_mtod(
4582 ut_params->obuf, uint8_t *) +
4583 (tdata->digest.offset_bytes == 0 ?
4584 plaintext_pad_len : tdata->digest.offset_bytes);
4586 debug_hexdump(stdout, "digest:", ut_params->digest,
4588 debug_hexdump(stdout, "digest expected:",
4589 tdata->digest.data, tdata->digest.len);
4594 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4596 tdata->plaintext.data,
4597 tdata->plaintext.len >> 3,
4598 "KASUMI Plaintext data not as expected");
4600 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4602 tdata->ciphertext.data,
4603 tdata->ciphertext.len >> 3,
4604 "KASUMI Ciphertext data not as expected");
4606 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4609 DIGEST_BYTE_LENGTH_KASUMI_F9,
4610 "KASUMI Generated auth tag not as expected");
4616 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4617 uint8_t op_mode, uint8_t verify)
4619 struct crypto_testsuite_params *ts_params = &testsuite_params;
4620 struct crypto_unittest_params *ut_params = &unittest_params;
4624 const uint8_t *plaintext = NULL;
4625 const uint8_t *ciphertext = NULL;
4626 const uint8_t *digest = NULL;
4627 unsigned int plaintext_pad_len;
4628 unsigned int plaintext_len;
4629 unsigned int ciphertext_pad_len;
4630 unsigned int ciphertext_len;
4631 uint8_t buffer[10000];
4632 uint8_t digest_buffer[10000];
4634 struct rte_cryptodev_info dev_info;
4636 /* Verify the capabilities */
4637 struct rte_cryptodev_sym_capability_idx cap_idx;
4638 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4639 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4640 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4643 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4644 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4645 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4649 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4651 uint64_t feat_flags = dev_info.feature_flags;
4653 if (op_mode == IN_PLACE) {
4654 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4655 printf("Device doesn't support in-place scatter-gather "
4656 "in both input and output mbufs.\n");
4660 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4661 printf("Device doesn't support out-of-place scatter-gather "
4662 "in both input and output mbufs.\n");
4665 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4666 printf("Device doesn't support digest encrypted.\n");
4671 /* Create KASUMI session */
4672 retval = create_wireless_algo_auth_cipher_session(
4673 ts_params->valid_devs[0],
4674 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4675 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4676 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4677 : RTE_CRYPTO_AUTH_OP_GENERATE),
4678 RTE_CRYPTO_AUTH_KASUMI_F9,
4679 RTE_CRYPTO_CIPHER_KASUMI_F8,
4680 tdata->key.data, tdata->key.len,
4681 0, tdata->digest.len,
4682 tdata->cipher_iv.len);
4687 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4688 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4689 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4692 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4693 plaintext_pad_len, 15, 0);
4694 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4695 "Failed to allocate input buffer in mempool");
4697 if (op_mode == OUT_OF_PLACE) {
4698 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4699 plaintext_pad_len, 15, 0);
4700 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4701 "Failed to allocate output buffer in mempool");
4705 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4706 tdata->ciphertext.data);
4707 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4708 ciphertext_len, buffer);
4709 debug_hexdump(stdout, "ciphertext:", ciphertext,
4712 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4713 tdata->plaintext.data);
4714 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4715 plaintext_len, buffer);
4716 debug_hexdump(stdout, "plaintext:", plaintext,
4719 memset(buffer, 0, sizeof(buffer));
4721 /* Create KASUMI operation */
4722 retval = create_wireless_algo_auth_cipher_operation(
4723 tdata->digest.data, tdata->digest.len,
4724 tdata->cipher_iv.data, tdata->cipher_iv.len,
4726 (tdata->digest.offset_bytes == 0 ?
4727 (verify ? ciphertext_pad_len : plaintext_pad_len)
4728 : tdata->digest.offset_bytes),
4729 tdata->validCipherLenInBits.len,
4730 tdata->validCipherOffsetInBits.len,
4731 tdata->validAuthLenInBits.len,
4733 op_mode, 1, verify);
4738 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4743 ut_params->obuf = (op_mode == IN_PLACE ?
4744 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4747 if (ut_params->obuf)
4748 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4749 plaintext_len, buffer);
4751 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4752 plaintext_len, buffer);
4754 debug_hexdump(stdout, "plaintext:", plaintext,
4755 (tdata->plaintext.len >> 3) - tdata->digest.len);
4756 debug_hexdump(stdout, "plaintext expected:",
4757 tdata->plaintext.data,
4758 (tdata->plaintext.len >> 3) - tdata->digest.len);
4760 if (ut_params->obuf)
4761 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4762 ciphertext_len, buffer);
4764 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4765 ciphertext_len, buffer);
4767 debug_hexdump(stdout, "ciphertext:", ciphertext,
4769 debug_hexdump(stdout, "ciphertext expected:",
4770 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4772 if (ut_params->obuf)
4773 digest = rte_pktmbuf_read(ut_params->obuf,
4774 (tdata->digest.offset_bytes == 0 ?
4775 plaintext_pad_len : tdata->digest.offset_bytes),
4776 tdata->digest.len, digest_buffer);
4778 digest = rte_pktmbuf_read(ut_params->ibuf,
4779 (tdata->digest.offset_bytes == 0 ?
4780 plaintext_pad_len : tdata->digest.offset_bytes),
4781 tdata->digest.len, digest_buffer);
4783 debug_hexdump(stdout, "digest:", digest,
4785 debug_hexdump(stdout, "digest expected:",
4786 tdata->digest.data, tdata->digest.len);
4791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4793 tdata->plaintext.data,
4794 tdata->plaintext.len >> 3,
4795 "KASUMI Plaintext data not as expected");
4797 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4799 tdata->ciphertext.data,
4800 tdata->validDataLenInBits.len,
4801 "KASUMI Ciphertext data not as expected");
4803 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4806 DIGEST_BYTE_LENGTH_KASUMI_F9,
4807 "KASUMI Generated auth tag not as expected");
4813 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4815 struct crypto_testsuite_params *ts_params = &testsuite_params;
4816 struct crypto_unittest_params *ut_params = &unittest_params;
4820 uint8_t *plaintext, *ciphertext;
4821 unsigned plaintext_pad_len;
4822 unsigned plaintext_len;
4824 /* Verify the capabilities */
4825 struct rte_cryptodev_sym_capability_idx cap_idx;
4826 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4827 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4828 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4831 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4832 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4833 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4837 /* Create KASUMI session */
4838 retval = create_wireless_algo_cipher_auth_session(
4839 ts_params->valid_devs[0],
4840 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4841 RTE_CRYPTO_AUTH_OP_GENERATE,
4842 RTE_CRYPTO_AUTH_KASUMI_F9,
4843 RTE_CRYPTO_CIPHER_KASUMI_F8,
4844 tdata->key.data, tdata->key.len,
4845 0, tdata->digest.len,
4846 tdata->cipher_iv.len);
4850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4852 /* clear mbuf payload */
4853 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4854 rte_pktmbuf_tailroom(ut_params->ibuf));
4856 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4857 /* Append data which is padded to a multiple of */
4858 /* the algorithms block size */
4859 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4860 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4862 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4864 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4866 /* Create KASUMI operation */
4867 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4868 tdata->digest.len, NULL, 0,
4869 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4870 tdata->cipher_iv.data, tdata->cipher_iv.len,
4871 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4872 tdata->validCipherOffsetInBits.len,
4873 tdata->validAuthLenInBits.len,
4879 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4881 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4883 if (ut_params->op->sym->m_dst)
4884 ut_params->obuf = ut_params->op->sym->m_dst;
4886 ut_params->obuf = ut_params->op->sym->m_src;
4888 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4889 tdata->validCipherOffsetInBits.len >> 3);
4891 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4892 + plaintext_pad_len;
4894 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4895 (tdata->validCipherOffsetInBits.len >> 3);
4897 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4899 reference_ciphertext,
4900 tdata->validCipherLenInBits.len,
4901 "KASUMI Ciphertext data not as expected");
4904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4907 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4908 "KASUMI Generated auth tag not as expected");
4913 test_zuc_encryption(const struct wireless_test_data *tdata)
4915 struct crypto_testsuite_params *ts_params = &testsuite_params;
4916 struct crypto_unittest_params *ut_params = &unittest_params;
4919 uint8_t *plaintext, *ciphertext;
4920 unsigned plaintext_pad_len;
4921 unsigned plaintext_len;
4923 struct rte_cryptodev_sym_capability_idx cap_idx;
4925 /* Check if device supports ZUC EEA3 */
4926 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4927 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4929 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4933 /* Create ZUC session */
4934 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4935 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4936 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4937 tdata->key.data, tdata->key.len,
4938 tdata->cipher_iv.len);
4942 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4944 /* Clear mbuf payload */
4945 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4946 rte_pktmbuf_tailroom(ut_params->ibuf));
4948 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4949 /* Append data which is padded to a multiple */
4950 /* of the algorithms block size */
4951 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4952 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4954 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4956 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4958 /* Create ZUC operation */
4959 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4960 tdata->cipher_iv.len,
4961 tdata->plaintext.len,
4966 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4968 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4970 ut_params->obuf = ut_params->op->sym->m_dst;
4971 if (ut_params->obuf)
4972 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4974 ciphertext = plaintext;
4976 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4979 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4981 tdata->ciphertext.data,
4982 tdata->validCipherLenInBits.len,
4983 "ZUC Ciphertext data not as expected");
4988 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4990 struct crypto_testsuite_params *ts_params = &testsuite_params;
4991 struct crypto_unittest_params *ut_params = &unittest_params;
4995 unsigned int plaintext_pad_len;
4996 unsigned int plaintext_len;
4997 const uint8_t *ciphertext;
4998 uint8_t ciphertext_buffer[2048];
4999 struct rte_cryptodev_info dev_info;
5001 struct rte_cryptodev_sym_capability_idx cap_idx;
5003 /* Check if device supports ZUC EEA3 */
5004 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5005 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5011 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5013 uint64_t feat_flags = dev_info.feature_flags;
5015 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5016 printf("Device doesn't support in-place scatter-gather. "
5021 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5023 /* Append data which is padded to a multiple */
5024 /* of the algorithms block size */
5025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5027 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5028 plaintext_pad_len, 10, 0);
5030 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5031 tdata->plaintext.data);
5033 /* Create ZUC session */
5034 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5035 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5036 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5037 tdata->key.data, tdata->key.len,
5038 tdata->cipher_iv.len);
5042 /* Clear mbuf payload */
5044 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5046 /* Create ZUC operation */
5047 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5048 tdata->cipher_iv.len, tdata->plaintext.len,
5053 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5055 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5057 ut_params->obuf = ut_params->op->sym->m_dst;
5058 if (ut_params->obuf)
5059 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5060 0, plaintext_len, ciphertext_buffer);
5062 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5063 0, plaintext_len, ciphertext_buffer);
5066 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5069 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5071 tdata->ciphertext.data,
5072 tdata->validCipherLenInBits.len,
5073 "ZUC Ciphertext data not as expected");
5079 test_zuc_authentication(const struct wireless_test_data *tdata)
5081 struct crypto_testsuite_params *ts_params = &testsuite_params;
5082 struct crypto_unittest_params *ut_params = &unittest_params;
5085 unsigned plaintext_pad_len;
5086 unsigned plaintext_len;
5089 struct rte_cryptodev_sym_capability_idx cap_idx;
5091 /* QAT PMD supports byte-aligned data only */
5092 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
5093 (gbl_driver_id == rte_cryptodev_driver_id_get(
5094 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
5097 /* Check if device supports ZUC EIA3 */
5098 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5099 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5101 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5105 /* Create ZUC session */
5106 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5107 tdata->key.data, tdata->key.len,
5108 tdata->auth_iv.len, tdata->digest.len,
5109 RTE_CRYPTO_AUTH_OP_GENERATE,
5110 RTE_CRYPTO_AUTH_ZUC_EIA3);
5114 /* alloc mbuf and set payload */
5115 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5117 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5118 rte_pktmbuf_tailroom(ut_params->ibuf));
5120 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5121 /* Append data which is padded to a multiple of */
5122 /* the algorithms block size */
5123 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5126 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5128 /* Create ZUC operation */
5129 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5130 tdata->auth_iv.data, tdata->auth_iv.len,
5131 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5132 tdata->validAuthLenInBits.len,
5137 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5139 ut_params->obuf = ut_params->op->sym->m_src;
5140 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5141 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5142 + plaintext_pad_len;
5145 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5149 "ZUC Generated auth tag not as expected");
5155 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5156 uint8_t op_mode, uint8_t verify)
5158 struct crypto_testsuite_params *ts_params = &testsuite_params;
5159 struct crypto_unittest_params *ut_params = &unittest_params;
5163 uint8_t *plaintext = NULL, *ciphertext = NULL;
5164 unsigned int plaintext_pad_len;
5165 unsigned int plaintext_len;
5166 unsigned int ciphertext_pad_len;
5167 unsigned int ciphertext_len;
5169 struct rte_cryptodev_info dev_info;
5170 struct rte_cryptodev_sym_capability_idx cap_idx;
5172 /* Check if device supports ZUC EIA3 */
5173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5174 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5176 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5180 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5182 uint64_t feat_flags = dev_info.feature_flags;
5184 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5185 printf("Device doesn't support digest encrypted.\n");
5189 /* Create ZUC session */
5190 retval = create_wireless_algo_auth_cipher_session(
5191 ts_params->valid_devs[0],
5192 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5193 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5194 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5195 : RTE_CRYPTO_AUTH_OP_GENERATE),
5196 RTE_CRYPTO_AUTH_ZUC_EIA3,
5197 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5198 tdata->key.data, tdata->key.len,
5199 tdata->auth_iv.len, tdata->digest.len,
5200 tdata->cipher_iv.len);
5205 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5206 if (op_mode == OUT_OF_PLACE)
5207 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5209 /* clear mbuf payload */
5210 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5211 rte_pktmbuf_tailroom(ut_params->ibuf));
5212 if (op_mode == OUT_OF_PLACE)
5213 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5214 rte_pktmbuf_tailroom(ut_params->obuf));
5216 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5217 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5218 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5219 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5222 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5223 ciphertext_pad_len);
5224 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5225 if (op_mode == OUT_OF_PLACE)
5226 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5227 debug_hexdump(stdout, "ciphertext:", ciphertext,
5230 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5232 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5233 if (op_mode == OUT_OF_PLACE)
5234 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5235 debug_hexdump(stdout, "plaintext:", plaintext,
5239 /* Create ZUC operation */
5240 retval = create_wireless_algo_auth_cipher_operation(
5241 tdata->digest.data, tdata->digest.len,
5242 tdata->cipher_iv.data, tdata->cipher_iv.len,
5243 tdata->auth_iv.data, tdata->auth_iv.len,
5244 (tdata->digest.offset_bytes == 0 ?
5245 (verify ? ciphertext_pad_len : plaintext_pad_len)
5246 : tdata->digest.offset_bytes),
5247 tdata->validCipherLenInBits.len,
5248 tdata->validCipherOffsetInBits.len,
5249 tdata->validAuthLenInBits.len,
5251 op_mode, 0, verify);
5256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5261 ut_params->obuf = (op_mode == IN_PLACE ?
5262 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5266 if (ut_params->obuf)
5267 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5270 plaintext = ciphertext;
5272 debug_hexdump(stdout, "plaintext:", plaintext,
5273 (tdata->plaintext.len >> 3) - tdata->digest.len);
5274 debug_hexdump(stdout, "plaintext expected:",
5275 tdata->plaintext.data,
5276 (tdata->plaintext.len >> 3) - tdata->digest.len);
5278 if (ut_params->obuf)
5279 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5282 ciphertext = plaintext;
5284 debug_hexdump(stdout, "ciphertext:", ciphertext,
5286 debug_hexdump(stdout, "ciphertext expected:",
5287 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5289 ut_params->digest = rte_pktmbuf_mtod(
5290 ut_params->obuf, uint8_t *) +
5291 (tdata->digest.offset_bytes == 0 ?
5292 plaintext_pad_len : tdata->digest.offset_bytes);
5294 debug_hexdump(stdout, "digest:", ut_params->digest,
5296 debug_hexdump(stdout, "digest expected:",
5297 tdata->digest.data, tdata->digest.len);
5302 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5304 tdata->plaintext.data,
5305 tdata->plaintext.len >> 3,
5306 "ZUC Plaintext data not as expected");
5308 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5310 tdata->ciphertext.data,
5311 tdata->ciphertext.len >> 3,
5312 "ZUC Ciphertext data not as expected");
5314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5317 DIGEST_BYTE_LENGTH_KASUMI_F9,
5318 "ZUC Generated auth tag not as expected");
5324 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5325 uint8_t op_mode, uint8_t verify)
5327 struct crypto_testsuite_params *ts_params = &testsuite_params;
5328 struct crypto_unittest_params *ut_params = &unittest_params;
5332 const uint8_t *plaintext = NULL;
5333 const uint8_t *ciphertext = NULL;
5334 const uint8_t *digest = NULL;
5335 unsigned int plaintext_pad_len;
5336 unsigned int plaintext_len;
5337 unsigned int ciphertext_pad_len;
5338 unsigned int ciphertext_len;
5339 uint8_t buffer[10000];
5340 uint8_t digest_buffer[10000];
5342 struct rte_cryptodev_info dev_info;
5343 struct rte_cryptodev_sym_capability_idx cap_idx;
5345 /* Check if device supports ZUC EIA3 */
5346 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5347 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5349 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5353 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5355 uint64_t feat_flags = dev_info.feature_flags;
5357 if (op_mode == IN_PLACE) {
5358 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5359 printf("Device doesn't support in-place scatter-gather "
5360 "in both input and output mbufs.\n");
5364 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5365 printf("Device doesn't support out-of-place scatter-gather "
5366 "in both input and output mbufs.\n");
5369 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5370 printf("Device doesn't support digest encrypted.\n");
5375 /* Create ZUC session */
5376 retval = create_wireless_algo_auth_cipher_session(
5377 ts_params->valid_devs[0],
5378 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5379 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5380 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5381 : RTE_CRYPTO_AUTH_OP_GENERATE),
5382 RTE_CRYPTO_AUTH_ZUC_EIA3,
5383 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5384 tdata->key.data, tdata->key.len,
5385 tdata->auth_iv.len, tdata->digest.len,
5386 tdata->cipher_iv.len);
5391 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5392 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5393 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5394 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5396 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5397 plaintext_pad_len, 15, 0);
5398 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5399 "Failed to allocate input buffer in mempool");
5401 if (op_mode == OUT_OF_PLACE) {
5402 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5403 plaintext_pad_len, 15, 0);
5404 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5405 "Failed to allocate output buffer in mempool");
5409 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5410 tdata->ciphertext.data);
5411 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5412 ciphertext_len, buffer);
5413 debug_hexdump(stdout, "ciphertext:", ciphertext,
5416 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5417 tdata->plaintext.data);
5418 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5419 plaintext_len, buffer);
5420 debug_hexdump(stdout, "plaintext:", plaintext,
5423 memset(buffer, 0, sizeof(buffer));
5425 /* Create ZUC operation */
5426 retval = create_wireless_algo_auth_cipher_operation(
5427 tdata->digest.data, tdata->digest.len,
5428 tdata->cipher_iv.data, tdata->cipher_iv.len,
5430 (tdata->digest.offset_bytes == 0 ?
5431 (verify ? ciphertext_pad_len : plaintext_pad_len)
5432 : tdata->digest.offset_bytes),
5433 tdata->validCipherLenInBits.len,
5434 tdata->validCipherOffsetInBits.len,
5435 tdata->validAuthLenInBits.len,
5437 op_mode, 1, verify);
5442 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5447 ut_params->obuf = (op_mode == IN_PLACE ?
5448 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5451 if (ut_params->obuf)
5452 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5453 plaintext_len, buffer);
5455 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5456 plaintext_len, buffer);
5458 debug_hexdump(stdout, "plaintext:", plaintext,
5459 (tdata->plaintext.len >> 3) - tdata->digest.len);
5460 debug_hexdump(stdout, "plaintext expected:",
5461 tdata->plaintext.data,
5462 (tdata->plaintext.len >> 3) - tdata->digest.len);
5464 if (ut_params->obuf)
5465 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5466 ciphertext_len, buffer);
5468 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5469 ciphertext_len, buffer);
5471 debug_hexdump(stdout, "ciphertext:", ciphertext,
5473 debug_hexdump(stdout, "ciphertext expected:",
5474 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5476 if (ut_params->obuf)
5477 digest = rte_pktmbuf_read(ut_params->obuf,
5478 (tdata->digest.offset_bytes == 0 ?
5479 plaintext_pad_len : tdata->digest.offset_bytes),
5480 tdata->digest.len, digest_buffer);
5482 digest = rte_pktmbuf_read(ut_params->ibuf,
5483 (tdata->digest.offset_bytes == 0 ?
5484 plaintext_pad_len : tdata->digest.offset_bytes),
5485 tdata->digest.len, digest_buffer);
5487 debug_hexdump(stdout, "digest:", digest,
5489 debug_hexdump(stdout, "digest expected:",
5490 tdata->digest.data, tdata->digest.len);
5495 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5497 tdata->plaintext.data,
5498 tdata->plaintext.len >> 3,
5499 "ZUC Plaintext data not as expected");
5501 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5503 tdata->ciphertext.data,
5504 tdata->validDataLenInBits.len,
5505 "ZUC Ciphertext data not as expected");
5507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5510 DIGEST_BYTE_LENGTH_KASUMI_F9,
5511 "ZUC Generated auth tag not as expected");
5517 test_kasumi_encryption_test_case_1(void)
5519 return test_kasumi_encryption(&kasumi_test_case_1);
5523 test_kasumi_encryption_test_case_1_sgl(void)
5525 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5529 test_kasumi_encryption_test_case_1_oop(void)
5531 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5535 test_kasumi_encryption_test_case_1_oop_sgl(void)
5537 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5541 test_kasumi_encryption_test_case_2(void)
5543 return test_kasumi_encryption(&kasumi_test_case_2);
5547 test_kasumi_encryption_test_case_3(void)
5549 return test_kasumi_encryption(&kasumi_test_case_3);
5553 test_kasumi_encryption_test_case_4(void)
5555 return test_kasumi_encryption(&kasumi_test_case_4);
5559 test_kasumi_encryption_test_case_5(void)
5561 return test_kasumi_encryption(&kasumi_test_case_5);
5565 test_kasumi_decryption_test_case_1(void)
5567 return test_kasumi_decryption(&kasumi_test_case_1);
5571 test_kasumi_decryption_test_case_1_oop(void)
5573 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5577 test_kasumi_decryption_test_case_2(void)
5579 return test_kasumi_decryption(&kasumi_test_case_2);
5583 test_kasumi_decryption_test_case_3(void)
5585 return test_kasumi_decryption(&kasumi_test_case_3);
5589 test_kasumi_decryption_test_case_4(void)
5591 return test_kasumi_decryption(&kasumi_test_case_4);
5595 test_kasumi_decryption_test_case_5(void)
5597 return test_kasumi_decryption(&kasumi_test_case_5);
5600 test_snow3g_encryption_test_case_1(void)
5602 return test_snow3g_encryption(&snow3g_test_case_1);
5606 test_snow3g_encryption_test_case_1_oop(void)
5608 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5612 test_snow3g_encryption_test_case_1_oop_sgl(void)
5614 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5619 test_snow3g_encryption_test_case_1_offset_oop(void)
5621 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5625 test_snow3g_encryption_test_case_2(void)
5627 return test_snow3g_encryption(&snow3g_test_case_2);
5631 test_snow3g_encryption_test_case_3(void)
5633 return test_snow3g_encryption(&snow3g_test_case_3);
5637 test_snow3g_encryption_test_case_4(void)
5639 return test_snow3g_encryption(&snow3g_test_case_4);
5643 test_snow3g_encryption_test_case_5(void)
5645 return test_snow3g_encryption(&snow3g_test_case_5);
5649 test_snow3g_decryption_test_case_1(void)
5651 return test_snow3g_decryption(&snow3g_test_case_1);
5655 test_snow3g_decryption_test_case_1_oop(void)
5657 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5661 test_snow3g_decryption_test_case_2(void)
5663 return test_snow3g_decryption(&snow3g_test_case_2);
5667 test_snow3g_decryption_test_case_3(void)
5669 return test_snow3g_decryption(&snow3g_test_case_3);
5673 test_snow3g_decryption_test_case_4(void)
5675 return test_snow3g_decryption(&snow3g_test_case_4);
5679 test_snow3g_decryption_test_case_5(void)
5681 return test_snow3g_decryption(&snow3g_test_case_5);
5685 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5686 * Pattern digest from snow3g_test_data must be allocated as
5687 * 4 last bytes in plaintext.
5690 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5691 struct snow3g_hash_test_data *output)
5693 if ((pattern != NULL) && (output != NULL)) {
5694 output->key.len = pattern->key.len;
5696 memcpy(output->key.data,
5697 pattern->key.data, pattern->key.len);
5699 output->auth_iv.len = pattern->auth_iv.len;
5701 memcpy(output->auth_iv.data,
5702 pattern->auth_iv.data, pattern->auth_iv.len);
5704 output->plaintext.len = pattern->plaintext.len;
5706 memcpy(output->plaintext.data,
5707 pattern->plaintext.data, pattern->plaintext.len >> 3);
5709 output->digest.len = pattern->digest.len;
5711 memcpy(output->digest.data,
5712 &pattern->plaintext.data[pattern->digest.offset_bytes],
5713 pattern->digest.len);
5715 output->validAuthLenInBits.len =
5716 pattern->validAuthLenInBits.len;
5721 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5724 test_snow3g_decryption_with_digest_test_case_1(void)
5726 struct snow3g_hash_test_data snow3g_hash_data;
5729 * Function prepare data for hash veryfication test case.
5730 * Digest is allocated in 4 last bytes in plaintext, pattern.
5732 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5734 return test_snow3g_decryption(&snow3g_test_case_7) &
5735 test_snow3g_authentication_verify(&snow3g_hash_data);
5739 test_snow3g_cipher_auth_test_case_1(void)
5741 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5745 test_snow3g_auth_cipher_test_case_1(void)
5747 return test_snow3g_auth_cipher(
5748 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5752 test_snow3g_auth_cipher_test_case_2(void)
5754 return test_snow3g_auth_cipher(
5755 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5759 test_snow3g_auth_cipher_test_case_2_oop(void)
5761 return test_snow3g_auth_cipher(
5762 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5766 test_snow3g_auth_cipher_part_digest_enc(void)
5768 return test_snow3g_auth_cipher(
5769 &snow3g_auth_cipher_partial_digest_encryption,
5774 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5776 return test_snow3g_auth_cipher(
5777 &snow3g_auth_cipher_partial_digest_encryption,
5782 test_snow3g_auth_cipher_test_case_3_sgl(void)
5784 return test_snow3g_auth_cipher_sgl(
5785 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5789 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5791 return test_snow3g_auth_cipher_sgl(
5792 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5796 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5798 return test_snow3g_auth_cipher_sgl(
5799 &snow3g_auth_cipher_partial_digest_encryption,
5804 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5806 return test_snow3g_auth_cipher_sgl(
5807 &snow3g_auth_cipher_partial_digest_encryption,
5812 test_snow3g_auth_cipher_verify_test_case_1(void)
5814 return test_snow3g_auth_cipher(
5815 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5819 test_snow3g_auth_cipher_verify_test_case_2(void)
5821 return test_snow3g_auth_cipher(
5822 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5826 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5828 return test_snow3g_auth_cipher(
5829 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5833 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5835 return test_snow3g_auth_cipher(
5836 &snow3g_auth_cipher_partial_digest_encryption,
5841 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5843 return test_snow3g_auth_cipher(
5844 &snow3g_auth_cipher_partial_digest_encryption,
5849 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5851 return test_snow3g_auth_cipher_sgl(
5852 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5856 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5858 return test_snow3g_auth_cipher_sgl(
5859 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5863 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5865 return test_snow3g_auth_cipher_sgl(
5866 &snow3g_auth_cipher_partial_digest_encryption,
5871 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5873 return test_snow3g_auth_cipher_sgl(
5874 &snow3g_auth_cipher_partial_digest_encryption,
5879 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5881 return test_snow3g_auth_cipher(
5882 &snow3g_test_case_7, IN_PLACE, 0);
5886 test_kasumi_auth_cipher_test_case_1(void)
5888 return test_kasumi_auth_cipher(
5889 &kasumi_test_case_3, IN_PLACE, 0);
5893 test_kasumi_auth_cipher_test_case_2(void)
5895 return test_kasumi_auth_cipher(
5896 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5900 test_kasumi_auth_cipher_test_case_2_oop(void)
5902 return test_kasumi_auth_cipher(
5903 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5907 test_kasumi_auth_cipher_test_case_2_sgl(void)
5909 return test_kasumi_auth_cipher_sgl(
5910 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5914 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5916 return test_kasumi_auth_cipher_sgl(
5917 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5921 test_kasumi_auth_cipher_verify_test_case_1(void)
5923 return test_kasumi_auth_cipher(
5924 &kasumi_test_case_3, IN_PLACE, 1);
5928 test_kasumi_auth_cipher_verify_test_case_2(void)
5930 return test_kasumi_auth_cipher(
5931 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5935 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5937 return test_kasumi_auth_cipher(
5938 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5942 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5944 return test_kasumi_auth_cipher_sgl(
5945 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5949 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5951 return test_kasumi_auth_cipher_sgl(
5952 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5956 test_kasumi_cipher_auth_test_case_1(void)
5958 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5962 test_zuc_encryption_test_case_1(void)
5964 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5968 test_zuc_encryption_test_case_2(void)
5970 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5974 test_zuc_encryption_test_case_3(void)
5976 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5980 test_zuc_encryption_test_case_4(void)
5982 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5986 test_zuc_encryption_test_case_5(void)
5988 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5992 test_zuc_encryption_test_case_6_sgl(void)
5994 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5998 test_zuc_hash_generate_test_case_1(void)
6000 return test_zuc_authentication(&zuc_test_case_auth_1b);
6004 test_zuc_hash_generate_test_case_2(void)
6006 return test_zuc_authentication(&zuc_test_case_auth_90b);
6010 test_zuc_hash_generate_test_case_3(void)
6012 return test_zuc_authentication(&zuc_test_case_auth_577b);
6016 test_zuc_hash_generate_test_case_4(void)
6018 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6022 test_zuc_hash_generate_test_case_5(void)
6024 return test_zuc_authentication(&zuc_test_auth_5670b);
6028 test_zuc_hash_generate_test_case_6(void)
6030 return test_zuc_authentication(&zuc_test_case_auth_128b);
6034 test_zuc_hash_generate_test_case_7(void)
6036 /* This test is not for SW ZUC PMD */
6037 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6038 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6041 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6045 test_zuc_hash_generate_test_case_8(void)
6047 return test_zuc_authentication(&zuc_test_case_auth_584b);
6051 test_zuc_cipher_auth_test_case_1(void)
6053 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6057 test_zuc_cipher_auth_test_case_2(void)
6059 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6063 test_zuc_auth_cipher_test_case_1(void)
6065 /* This test is not for SW ZUC PMD */
6066 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6067 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6070 return test_zuc_auth_cipher(
6071 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6075 test_zuc_auth_cipher_test_case_1_oop(void)
6077 return test_zuc_auth_cipher(
6078 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6082 test_zuc_auth_cipher_test_case_1_sgl(void)
6084 return test_zuc_auth_cipher_sgl(
6085 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6089 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6091 return test_zuc_auth_cipher_sgl(
6092 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6096 test_zuc_auth_cipher_verify_test_case_1(void)
6098 return test_zuc_auth_cipher(
6099 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6103 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6105 return test_zuc_auth_cipher(
6106 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6110 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6112 return test_zuc_auth_cipher_sgl(
6113 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6117 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6119 return test_zuc_auth_cipher_sgl(
6120 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6124 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6126 uint8_t dev_id = testsuite_params.valid_devs[0];
6128 struct rte_cryptodev_sym_capability_idx cap_idx;
6130 /* Check if device supports particular cipher algorithm */
6131 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6132 cap_idx.algo.cipher = tdata->cipher_algo;
6133 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6136 /* Check if device supports particular hash algorithm */
6137 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6138 cap_idx.algo.auth = tdata->auth_algo;
6139 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6146 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6147 uint8_t op_mode, uint8_t verify)
6149 struct crypto_testsuite_params *ts_params = &testsuite_params;
6150 struct crypto_unittest_params *ut_params = &unittest_params;
6154 uint8_t *plaintext = NULL, *ciphertext = NULL;
6155 unsigned int plaintext_pad_len;
6156 unsigned int plaintext_len;
6157 unsigned int ciphertext_pad_len;
6158 unsigned int ciphertext_len;
6160 struct rte_cryptodev_info dev_info;
6161 struct rte_crypto_op *op;
6163 /* Check if device supports particular algorithms separately */
6164 if (test_mixed_check_if_unsupported(tdata))
6167 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6169 uint64_t feat_flags = dev_info.feature_flags;
6171 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6172 printf("Device doesn't support digest encrypted.\n");
6176 /* Create the session */
6178 retval = create_wireless_algo_cipher_auth_session(
6179 ts_params->valid_devs[0],
6180 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6181 RTE_CRYPTO_AUTH_OP_VERIFY,
6184 tdata->auth_key.data, tdata->auth_key.len,
6185 tdata->auth_iv.len, tdata->digest_enc.len,
6186 tdata->cipher_iv.len);
6188 retval = create_wireless_algo_auth_cipher_session(
6189 ts_params->valid_devs[0],
6190 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6191 RTE_CRYPTO_AUTH_OP_GENERATE,
6194 tdata->auth_key.data, tdata->auth_key.len,
6195 tdata->auth_iv.len, tdata->digest_enc.len,
6196 tdata->cipher_iv.len);
6200 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6201 if (op_mode == OUT_OF_PLACE)
6202 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6204 /* clear mbuf payload */
6205 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6206 rte_pktmbuf_tailroom(ut_params->ibuf));
6207 if (op_mode == OUT_OF_PLACE)
6208 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6209 rte_pktmbuf_tailroom(ut_params->obuf));
6211 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6212 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6213 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6214 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6217 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6218 ciphertext_pad_len);
6219 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6220 if (op_mode == OUT_OF_PLACE)
6221 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6222 debug_hexdump(stdout, "ciphertext:", ciphertext,
6225 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6227 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6228 if (op_mode == OUT_OF_PLACE)
6229 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6230 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6233 /* Create the operation */
6234 retval = create_wireless_algo_auth_cipher_operation(
6235 tdata->digest_enc.data, tdata->digest_enc.len,
6236 tdata->cipher_iv.data, tdata->cipher_iv.len,
6237 tdata->auth_iv.data, tdata->auth_iv.len,
6238 (tdata->digest_enc.offset == 0 ?
6240 : tdata->digest_enc.offset),
6241 tdata->validCipherLen.len_bits,
6242 tdata->cipher.offset_bits,
6243 tdata->validAuthLen.len_bits,
6244 tdata->auth.offset_bits,
6245 op_mode, 0, verify);
6250 op = process_crypto_request(ts_params->valid_devs[0],
6253 /* Check if the op failed because the device doesn't */
6254 /* support this particular combination of algorithms */
6255 if (op == NULL && ut_params->op->status ==
6256 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6257 printf("Device doesn't support this mixed combination. "
6263 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6265 ut_params->obuf = (op_mode == IN_PLACE ?
6266 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6269 if (ut_params->obuf)
6270 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6273 plaintext = ciphertext +
6274 (tdata->cipher.offset_bits >> 3);
6276 debug_hexdump(stdout, "plaintext:", plaintext,
6277 tdata->plaintext.len_bits >> 3);
6278 debug_hexdump(stdout, "plaintext expected:",
6279 tdata->plaintext.data,
6280 tdata->plaintext.len_bits >> 3);
6282 if (ut_params->obuf)
6283 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6286 ciphertext = plaintext;
6288 debug_hexdump(stdout, "ciphertext:", ciphertext,
6290 debug_hexdump(stdout, "ciphertext expected:",
6291 tdata->ciphertext.data,
6292 tdata->ciphertext.len_bits >> 3);
6294 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6295 + (tdata->digest_enc.offset == 0 ?
6296 plaintext_pad_len : tdata->digest_enc.offset);
6298 debug_hexdump(stdout, "digest:", ut_params->digest,
6299 tdata->digest_enc.len);
6300 debug_hexdump(stdout, "digest expected:",
6301 tdata->digest_enc.data,
6302 tdata->digest_enc.len);
6307 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6309 tdata->plaintext.data,
6310 tdata->plaintext.len_bits >> 3,
6311 "Plaintext data not as expected");
6313 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6315 tdata->ciphertext.data,
6316 tdata->validDataLen.len_bits,
6317 "Ciphertext data not as expected");
6319 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6321 tdata->digest_enc.data,
6322 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6323 "Generated auth tag not as expected");
6326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6327 "crypto op processing failed");
6333 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6334 uint8_t op_mode, uint8_t verify)
6336 struct crypto_testsuite_params *ts_params = &testsuite_params;
6337 struct crypto_unittest_params *ut_params = &unittest_params;
6341 const uint8_t *plaintext = NULL;
6342 const uint8_t *ciphertext = NULL;
6343 const uint8_t *digest = NULL;
6344 unsigned int plaintext_pad_len;
6345 unsigned int plaintext_len;
6346 unsigned int ciphertext_pad_len;
6347 unsigned int ciphertext_len;
6348 uint8_t buffer[10000];
6349 uint8_t digest_buffer[10000];
6351 struct rte_cryptodev_info dev_info;
6352 struct rte_crypto_op *op;
6354 /* Check if device supports particular algorithms */
6355 if (test_mixed_check_if_unsupported(tdata))
6358 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6360 uint64_t feat_flags = dev_info.feature_flags;
6362 if (op_mode == IN_PLACE) {
6363 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6364 printf("Device doesn't support in-place scatter-gather "
6365 "in both input and output mbufs.\n");
6369 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6370 printf("Device doesn't support out-of-place scatter-gather "
6371 "in both input and output mbufs.\n");
6374 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6375 printf("Device doesn't support digest encrypted.\n");
6380 /* Create the session */
6382 retval = create_wireless_algo_cipher_auth_session(
6383 ts_params->valid_devs[0],
6384 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6385 RTE_CRYPTO_AUTH_OP_VERIFY,
6388 tdata->auth_key.data, tdata->auth_key.len,
6389 tdata->auth_iv.len, tdata->digest_enc.len,
6390 tdata->cipher_iv.len);
6392 retval = create_wireless_algo_auth_cipher_session(
6393 ts_params->valid_devs[0],
6394 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6395 RTE_CRYPTO_AUTH_OP_GENERATE,
6398 tdata->auth_key.data, tdata->auth_key.len,
6399 tdata->auth_iv.len, tdata->digest_enc.len,
6400 tdata->cipher_iv.len);
6404 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6405 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6406 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6407 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6409 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6410 ciphertext_pad_len, 15, 0);
6411 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6412 "Failed to allocate input buffer in mempool");
6414 if (op_mode == OUT_OF_PLACE) {
6415 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6416 plaintext_pad_len, 15, 0);
6417 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6418 "Failed to allocate output buffer in mempool");
6422 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6423 tdata->ciphertext.data);
6424 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6425 ciphertext_len, buffer);
6426 debug_hexdump(stdout, "ciphertext:", ciphertext,
6429 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6430 tdata->plaintext.data);
6431 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6432 plaintext_len, buffer);
6433 debug_hexdump(stdout, "plaintext:", plaintext,
6436 memset(buffer, 0, sizeof(buffer));
6438 /* Create the operation */
6439 retval = create_wireless_algo_auth_cipher_operation(
6440 tdata->digest_enc.data, tdata->digest_enc.len,
6441 tdata->cipher_iv.data, tdata->cipher_iv.len,
6442 tdata->auth_iv.data, tdata->auth_iv.len,
6443 (tdata->digest_enc.offset == 0 ?
6445 : tdata->digest_enc.offset),
6446 tdata->validCipherLen.len_bits,
6447 tdata->cipher.offset_bits,
6448 tdata->validAuthLen.len_bits,
6449 tdata->auth.offset_bits,
6450 op_mode, 1, verify);
6455 op = process_crypto_request(ts_params->valid_devs[0],
6458 /* Check if the op failed because the device doesn't */
6459 /* support this particular combination of algorithms */
6460 if (op == NULL && ut_params->op->status ==
6461 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6462 printf("Device doesn't support this mixed combination. "
6469 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6471 ut_params->obuf = (op_mode == IN_PLACE ?
6472 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6475 if (ut_params->obuf)
6476 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6477 plaintext_len, buffer);
6479 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6480 plaintext_len, buffer);
6482 debug_hexdump(stdout, "plaintext:", plaintext,
6483 (tdata->plaintext.len_bits >> 3) -
6484 tdata->digest_enc.len);
6485 debug_hexdump(stdout, "plaintext expected:",
6486 tdata->plaintext.data,
6487 (tdata->plaintext.len_bits >> 3) -
6488 tdata->digest_enc.len);
6490 if (ut_params->obuf)
6491 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6492 ciphertext_len, buffer);
6494 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6495 ciphertext_len, buffer);
6497 debug_hexdump(stdout, "ciphertext:", ciphertext,
6499 debug_hexdump(stdout, "ciphertext expected:",
6500 tdata->ciphertext.data,
6501 tdata->ciphertext.len_bits >> 3);
6503 if (ut_params->obuf)
6504 digest = rte_pktmbuf_read(ut_params->obuf,
6505 (tdata->digest_enc.offset == 0 ?
6507 tdata->digest_enc.offset),
6508 tdata->digest_enc.len, digest_buffer);
6510 digest = rte_pktmbuf_read(ut_params->ibuf,
6511 (tdata->digest_enc.offset == 0 ?
6513 tdata->digest_enc.offset),
6514 tdata->digest_enc.len, digest_buffer);
6516 debug_hexdump(stdout, "digest:", digest,
6517 tdata->digest_enc.len);
6518 debug_hexdump(stdout, "digest expected:",
6519 tdata->digest_enc.data, tdata->digest_enc.len);
6524 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6526 tdata->plaintext.data,
6527 tdata->plaintext.len_bits >> 3,
6528 "Plaintext data not as expected");
6530 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6532 tdata->ciphertext.data,
6533 tdata->validDataLen.len_bits,
6534 "Ciphertext data not as expected");
6535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6537 tdata->digest_enc.data,
6538 tdata->digest_enc.len,
6539 "Generated auth tag not as expected");
6542 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6543 "crypto op processing failed");
6548 /** AUTH AES CMAC + CIPHER AES CTR */
6551 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6553 return test_mixed_auth_cipher(
6554 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6558 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6560 return test_mixed_auth_cipher(
6561 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6565 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6567 return test_mixed_auth_cipher_sgl(
6568 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6572 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6574 return test_mixed_auth_cipher_sgl(
6575 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6579 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6581 return test_mixed_auth_cipher(
6582 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6586 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6588 return test_mixed_auth_cipher(
6589 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6593 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6595 return test_mixed_auth_cipher_sgl(
6596 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6600 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6602 return test_mixed_auth_cipher_sgl(
6603 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6606 /** MIXED AUTH + CIPHER */
6609 test_auth_zuc_cipher_snow_test_case_1(void)
6611 return test_mixed_auth_cipher(
6612 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6616 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6618 return test_mixed_auth_cipher(
6619 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6623 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6625 return test_mixed_auth_cipher(
6626 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6630 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6632 return test_mixed_auth_cipher(
6633 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6637 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6639 return test_mixed_auth_cipher(
6640 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6644 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6646 return test_mixed_auth_cipher(
6647 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6651 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6653 return test_mixed_auth_cipher(
6654 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6658 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6660 return test_mixed_auth_cipher(
6661 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6665 test_auth_snow_cipher_zuc_test_case_1(void)
6667 return test_mixed_auth_cipher(
6668 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6672 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6674 return test_mixed_auth_cipher(
6675 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6679 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6681 return test_mixed_auth_cipher(
6682 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6686 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6688 return test_mixed_auth_cipher(
6689 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6693 test_auth_null_cipher_snow_test_case_1(void)
6695 return test_mixed_auth_cipher(
6696 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6700 test_verify_auth_null_cipher_snow_test_case_1(void)
6702 return test_mixed_auth_cipher(
6703 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6707 test_auth_null_cipher_zuc_test_case_1(void)
6709 return test_mixed_auth_cipher(
6710 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6714 test_verify_auth_null_cipher_zuc_test_case_1(void)
6716 return test_mixed_auth_cipher(
6717 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6721 test_auth_snow_cipher_null_test_case_1(void)
6723 return test_mixed_auth_cipher(
6724 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6728 test_verify_auth_snow_cipher_null_test_case_1(void)
6730 return test_mixed_auth_cipher(
6731 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6735 test_auth_zuc_cipher_null_test_case_1(void)
6737 return test_mixed_auth_cipher(
6738 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6742 test_verify_auth_zuc_cipher_null_test_case_1(void)
6744 return test_mixed_auth_cipher(
6745 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6749 test_auth_null_cipher_aes_ctr_test_case_1(void)
6751 return test_mixed_auth_cipher(
6752 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6756 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6758 return test_mixed_auth_cipher(
6759 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6763 test_auth_aes_cmac_cipher_null_test_case_1(void)
6765 return test_mixed_auth_cipher(
6766 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6770 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6772 return test_mixed_auth_cipher(
6773 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6776 /* ***** AEAD algorithm Tests ***** */
6779 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6780 enum rte_crypto_aead_operation op,
6781 const uint8_t *key, const uint8_t key_len,
6782 const uint16_t aad_len, const uint8_t auth_len,
6785 uint8_t aead_key[key_len];
6787 struct crypto_testsuite_params *ts_params = &testsuite_params;
6788 struct crypto_unittest_params *ut_params = &unittest_params;
6790 memcpy(aead_key, key, key_len);
6792 /* Setup AEAD Parameters */
6793 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6794 ut_params->aead_xform.next = NULL;
6795 ut_params->aead_xform.aead.algo = algo;
6796 ut_params->aead_xform.aead.op = op;
6797 ut_params->aead_xform.aead.key.data = aead_key;
6798 ut_params->aead_xform.aead.key.length = key_len;
6799 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6800 ut_params->aead_xform.aead.iv.length = iv_len;
6801 ut_params->aead_xform.aead.digest_length = auth_len;
6802 ut_params->aead_xform.aead.aad_length = aad_len;
6804 debug_hexdump(stdout, "key:", key, key_len);
6806 /* Create Crypto session*/
6807 ut_params->sess = rte_cryptodev_sym_session_create(
6808 ts_params->session_mpool);
6810 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6811 &ut_params->aead_xform,
6812 ts_params->session_priv_mpool);
6814 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6820 create_aead_xform(struct rte_crypto_op *op,
6821 enum rte_crypto_aead_algorithm algo,
6822 enum rte_crypto_aead_operation aead_op,
6823 uint8_t *key, const uint8_t key_len,
6824 const uint8_t aad_len, const uint8_t auth_len,
6827 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6828 "failed to allocate space for crypto transform");
6830 struct rte_crypto_sym_op *sym_op = op->sym;
6832 /* Setup AEAD Parameters */
6833 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6834 sym_op->xform->next = NULL;
6835 sym_op->xform->aead.algo = algo;
6836 sym_op->xform->aead.op = aead_op;
6837 sym_op->xform->aead.key.data = key;
6838 sym_op->xform->aead.key.length = key_len;
6839 sym_op->xform->aead.iv.offset = IV_OFFSET;
6840 sym_op->xform->aead.iv.length = iv_len;
6841 sym_op->xform->aead.digest_length = auth_len;
6842 sym_op->xform->aead.aad_length = aad_len;
6844 debug_hexdump(stdout, "key:", key, key_len);
6850 create_aead_operation(enum rte_crypto_aead_operation op,
6851 const struct aead_test_data *tdata)
6853 struct crypto_testsuite_params *ts_params = &testsuite_params;
6854 struct crypto_unittest_params *ut_params = &unittest_params;
6856 uint8_t *plaintext, *ciphertext;
6857 unsigned int aad_pad_len, plaintext_pad_len;
6859 /* Generate Crypto op data structure */
6860 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6861 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6862 TEST_ASSERT_NOT_NULL(ut_params->op,
6863 "Failed to allocate symmetric crypto operation struct");
6865 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6867 /* Append aad data */
6868 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6869 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6870 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6872 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6873 "no room to append aad");
6875 sym_op->aead.aad.phys_addr =
6876 rte_pktmbuf_iova(ut_params->ibuf);
6877 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6878 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6879 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6882 /* Append IV at the end of the crypto operation*/
6883 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6884 uint8_t *, IV_OFFSET);
6886 /* Copy IV 1 byte after the IV pointer, according to the API */
6887 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6888 debug_hexdump(stdout, "iv:", iv_ptr,
6891 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6892 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6894 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6895 "no room to append aad");
6897 sym_op->aead.aad.phys_addr =
6898 rte_pktmbuf_iova(ut_params->ibuf);
6899 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6900 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6903 /* Append IV at the end of the crypto operation*/
6904 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6905 uint8_t *, IV_OFFSET);
6907 if (tdata->iv.len == 0) {
6908 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6909 debug_hexdump(stdout, "iv:", iv_ptr,
6912 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6913 debug_hexdump(stdout, "iv:", iv_ptr,
6918 /* Append plaintext/ciphertext */
6919 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6920 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6921 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6923 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6925 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6926 debug_hexdump(stdout, "plaintext:", plaintext,
6927 tdata->plaintext.len);
6929 if (ut_params->obuf) {
6930 ciphertext = (uint8_t *)rte_pktmbuf_append(
6932 plaintext_pad_len + aad_pad_len);
6933 TEST_ASSERT_NOT_NULL(ciphertext,
6934 "no room to append ciphertext");
6936 memset(ciphertext + aad_pad_len, 0,
6937 tdata->ciphertext.len);
6940 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6941 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6943 TEST_ASSERT_NOT_NULL(ciphertext,
6944 "no room to append ciphertext");
6946 memcpy(ciphertext, tdata->ciphertext.data,
6947 tdata->ciphertext.len);
6948 debug_hexdump(stdout, "ciphertext:", ciphertext,
6949 tdata->ciphertext.len);
6951 if (ut_params->obuf) {
6952 plaintext = (uint8_t *)rte_pktmbuf_append(
6954 plaintext_pad_len + aad_pad_len);
6955 TEST_ASSERT_NOT_NULL(plaintext,
6956 "no room to append plaintext");
6958 memset(plaintext + aad_pad_len, 0,
6959 tdata->plaintext.len);
6963 /* Append digest data */
6964 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6965 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6966 ut_params->obuf ? ut_params->obuf :
6968 tdata->auth_tag.len);
6969 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6970 "no room to append digest");
6971 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6972 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6973 ut_params->obuf ? ut_params->obuf :
6978 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6979 ut_params->ibuf, tdata->auth_tag.len);
6980 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6981 "no room to append digest");
6982 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6984 plaintext_pad_len + aad_pad_len);
6986 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6987 tdata->auth_tag.len);
6988 debug_hexdump(stdout, "digest:",
6989 sym_op->aead.digest.data,
6990 tdata->auth_tag.len);
6993 sym_op->aead.data.length = tdata->plaintext.len;
6994 sym_op->aead.data.offset = aad_pad_len;
7000 test_authenticated_encryption(const struct aead_test_data *tdata)
7002 struct crypto_testsuite_params *ts_params = &testsuite_params;
7003 struct crypto_unittest_params *ut_params = &unittest_params;
7006 uint8_t *ciphertext, *auth_tag;
7007 uint16_t plaintext_pad_len;
7010 /* Verify the capabilities */
7011 struct rte_cryptodev_sym_capability_idx cap_idx;
7012 const struct rte_cryptodev_symmetric_capability *capability;
7013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7014 cap_idx.algo.aead = tdata->algo;
7015 capability = rte_cryptodev_sym_capability_get(
7016 ts_params->valid_devs[0], &cap_idx);
7017 if (capability == NULL)
7019 if (rte_cryptodev_sym_capability_check_aead(
7020 capability, tdata->key.len, tdata->auth_tag.len,
7021 tdata->aad.len, tdata->iv.len))
7024 /* Create AEAD session */
7025 retval = create_aead_session(ts_params->valid_devs[0],
7027 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7028 tdata->key.data, tdata->key.len,
7029 tdata->aad.len, tdata->auth_tag.len,
7034 if (tdata->aad.len > MBUF_SIZE) {
7035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7036 /* Populate full size of add data */
7037 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7038 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7042 /* clear mbuf payload */
7043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7044 rte_pktmbuf_tailroom(ut_params->ibuf));
7046 /* Create AEAD operation */
7047 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7051 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7053 ut_params->op->sym->m_src = ut_params->ibuf;
7055 /* Process crypto operation */
7056 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7057 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7059 TEST_ASSERT_NOT_NULL(
7060 process_crypto_request(ts_params->valid_devs[0],
7061 ut_params->op), "failed to process sym crypto op");
7063 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7064 "crypto op processing failed");
7066 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7068 if (ut_params->op->sym->m_dst) {
7069 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7071 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7072 uint8_t *, plaintext_pad_len);
7074 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7076 ut_params->op->sym->cipher.data.offset);
7077 auth_tag = ciphertext + plaintext_pad_len;
7080 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7081 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7084 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7086 tdata->ciphertext.data,
7087 tdata->ciphertext.len,
7088 "Ciphertext data not as expected");
7090 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7092 tdata->auth_tag.data,
7093 tdata->auth_tag.len,
7094 "Generated auth tag not as expected");
7100 #ifdef RTE_LIBRTE_SECURITY
7101 /* Basic algorithm run function for async inplace mode.
7102 * Creates a session from input parameters and runs one operation
7103 * on input_vec. Checks the output of the crypto operation against
7107 test_pdcp_proto(int i, int oop,
7108 enum rte_crypto_cipher_operation opc,
7109 enum rte_crypto_auth_operation opa,
7111 unsigned int input_vec_len,
7112 uint8_t *output_vec,
7113 unsigned int output_vec_len)
7115 struct crypto_testsuite_params *ts_params = &testsuite_params;
7116 struct crypto_unittest_params *ut_params = &unittest_params;
7118 int ret = TEST_SUCCESS;
7119 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7120 rte_cryptodev_get_sec_ctx(
7121 ts_params->valid_devs[0]);
7123 /* Verify the capabilities */
7124 struct rte_security_capability_idx sec_cap_idx;
7126 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7127 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7128 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7129 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7132 /* Generate test mbuf data */
7133 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7135 /* clear mbuf payload */
7136 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7137 rte_pktmbuf_tailroom(ut_params->ibuf));
7139 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7141 memcpy(plaintext, input_vec, input_vec_len);
7143 /* Out of place support */
7146 * For out-op-place we need to alloc another mbuf
7148 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7149 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7152 /* Set crypto type as IPSEC */
7153 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7155 /* Setup Cipher Parameters */
7156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7157 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7158 ut_params->cipher_xform.cipher.op = opc;
7159 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7160 ut_params->cipher_xform.cipher.key.length =
7161 pdcp_test_params[i].cipher_key_len;
7162 ut_params->cipher_xform.cipher.iv.length = 0;
7164 /* Setup HMAC Parameters if ICV header is required */
7165 if (pdcp_test_params[i].auth_alg != 0) {
7166 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7167 ut_params->auth_xform.next = NULL;
7168 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7169 ut_params->auth_xform.auth.op = opa;
7170 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7171 ut_params->auth_xform.auth.key.length =
7172 pdcp_test_params[i].auth_key_len;
7174 ut_params->cipher_xform.next = &ut_params->auth_xform;
7176 ut_params->cipher_xform.next = NULL;
7179 struct rte_security_session_conf sess_conf = {
7180 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7181 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7183 .bearer = pdcp_test_bearer[i],
7184 .domain = pdcp_test_params[i].domain,
7185 .pkt_dir = pdcp_test_packet_direction[i],
7186 .sn_size = pdcp_test_data_sn_size[i],
7187 .hfn = pdcp_test_hfn[i],
7188 .hfn_threshold = pdcp_test_hfn_threshold[i],
7190 .crypto_xform = &ut_params->cipher_xform
7193 /* Create security session */
7194 ut_params->sec_session = rte_security_session_create(ctx,
7195 &sess_conf, ts_params->session_priv_mpool);
7197 if (!ut_params->sec_session) {
7198 printf("TestCase %s()-%d line %d failed %s: ",
7199 __func__, i, __LINE__, "Failed to allocate session");
7204 /* Generate crypto op data structure */
7205 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7206 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7207 if (!ut_params->op) {
7208 printf("TestCase %s()-%d line %d failed %s: ",
7209 __func__, i, __LINE__,
7210 "Failed to allocate symmetric crypto operation struct");
7215 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7217 /* set crypto operation source mbuf */
7218 ut_params->op->sym->m_src = ut_params->ibuf;
7220 ut_params->op->sym->m_dst = ut_params->obuf;
7222 /* Process crypto operation */
7223 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7225 printf("TestCase %s()-%d line %d failed %s: ",
7226 __func__, i, __LINE__,
7227 "failed to process sym crypto op");
7232 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7233 printf("TestCase %s()-%d line %d failed %s: ",
7234 __func__, i, __LINE__, "crypto op processing failed");
7240 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7243 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7247 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7248 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7249 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7250 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7256 rte_crypto_op_free(ut_params->op);
7257 ut_params->op = NULL;
7259 if (ut_params->sec_session)
7260 rte_security_session_destroy(ctx, ut_params->sec_session);
7261 ut_params->sec_session = NULL;
7263 rte_pktmbuf_free(ut_params->ibuf);
7264 ut_params->ibuf = NULL;
7266 rte_pktmbuf_free(ut_params->obuf);
7267 ut_params->obuf = NULL;
7274 test_pdcp_proto_SGL(int i, int oop,
7275 enum rte_crypto_cipher_operation opc,
7276 enum rte_crypto_auth_operation opa,
7278 unsigned int input_vec_len,
7279 uint8_t *output_vec,
7280 unsigned int output_vec_len,
7282 uint32_t fragsz_oop)
7284 struct crypto_testsuite_params *ts_params = &testsuite_params;
7285 struct crypto_unittest_params *ut_params = &unittest_params;
7287 struct rte_mbuf *buf, *buf_oop = NULL;
7288 int ret = TEST_SUCCESS;
7292 unsigned int trn_data = 0;
7293 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7294 rte_cryptodev_get_sec_ctx(
7295 ts_params->valid_devs[0]);
7297 /* Verify the capabilities */
7298 struct rte_security_capability_idx sec_cap_idx;
7300 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7301 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7302 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7303 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7306 if (fragsz > input_vec_len)
7307 fragsz = input_vec_len;
7309 uint16_t plaintext_len = fragsz;
7310 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7312 if (fragsz_oop > output_vec_len)
7313 frag_size_oop = output_vec_len;
7316 if (input_vec_len % fragsz != 0) {
7317 if (input_vec_len / fragsz + 1 > 16)
7319 } else if (input_vec_len / fragsz > 16)
7322 /* Out of place support */
7325 * For out-op-place we need to alloc another mbuf
7327 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7328 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7329 buf_oop = ut_params->obuf;
7332 /* Generate test mbuf data */
7333 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7335 /* clear mbuf payload */
7336 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7337 rte_pktmbuf_tailroom(ut_params->ibuf));
7339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7341 memcpy(plaintext, input_vec, plaintext_len);
7342 trn_data += plaintext_len;
7344 buf = ut_params->ibuf;
7347 * Loop until no more fragments
7350 while (trn_data < input_vec_len) {
7352 to_trn = (input_vec_len - trn_data < fragsz) ?
7353 (input_vec_len - trn_data) : fragsz;
7355 to_trn_tbl[ecx++] = to_trn;
7357 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7360 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7361 rte_pktmbuf_tailroom(buf));
7364 if (oop && !fragsz_oop) {
7366 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7367 buf_oop = buf_oop->next;
7368 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7369 0, rte_pktmbuf_tailroom(buf_oop));
7370 rte_pktmbuf_append(buf_oop, to_trn);
7373 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7376 memcpy(plaintext, input_vec + trn_data, to_trn);
7380 ut_params->ibuf->nb_segs = segs;
7383 if (fragsz_oop && oop) {
7387 trn_data = frag_size_oop;
7388 while (trn_data < output_vec_len) {
7391 (output_vec_len - trn_data <
7393 (output_vec_len - trn_data) :
7396 to_trn_tbl[ecx++] = to_trn;
7399 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7400 buf_oop = buf_oop->next;
7401 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7402 0, rte_pktmbuf_tailroom(buf_oop));
7403 rte_pktmbuf_append(buf_oop, to_trn);
7407 ut_params->obuf->nb_segs = segs;
7410 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7412 /* Setup Cipher Parameters */
7413 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7414 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7415 ut_params->cipher_xform.cipher.op = opc;
7416 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7417 ut_params->cipher_xform.cipher.key.length =
7418 pdcp_test_params[i].cipher_key_len;
7419 ut_params->cipher_xform.cipher.iv.length = 0;
7421 /* Setup HMAC Parameters if ICV header is required */
7422 if (pdcp_test_params[i].auth_alg != 0) {
7423 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7424 ut_params->auth_xform.next = NULL;
7425 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7426 ut_params->auth_xform.auth.op = opa;
7427 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7428 ut_params->auth_xform.auth.key.length =
7429 pdcp_test_params[i].auth_key_len;
7431 ut_params->cipher_xform.next = &ut_params->auth_xform;
7433 ut_params->cipher_xform.next = NULL;
7436 struct rte_security_session_conf sess_conf = {
7437 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7438 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7440 .bearer = pdcp_test_bearer[i],
7441 .domain = pdcp_test_params[i].domain,
7442 .pkt_dir = pdcp_test_packet_direction[i],
7443 .sn_size = pdcp_test_data_sn_size[i],
7444 .hfn = pdcp_test_hfn[i],
7445 .hfn_threshold = pdcp_test_hfn_threshold[i],
7447 .crypto_xform = &ut_params->cipher_xform
7450 /* Create security session */
7451 ut_params->sec_session = rte_security_session_create(ctx,
7452 &sess_conf, ts_params->session_priv_mpool);
7454 if (!ut_params->sec_session) {
7455 printf("TestCase %s()-%d line %d failed %s: ",
7456 __func__, i, __LINE__, "Failed to allocate session");
7461 /* Generate crypto op data structure */
7462 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7463 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7464 if (!ut_params->op) {
7465 printf("TestCase %s()-%d line %d failed %s: ",
7466 __func__, i, __LINE__,
7467 "Failed to allocate symmetric crypto operation struct");
7472 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7474 /* set crypto operation source mbuf */
7475 ut_params->op->sym->m_src = ut_params->ibuf;
7477 ut_params->op->sym->m_dst = ut_params->obuf;
7479 /* Process crypto operation */
7480 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7482 printf("TestCase %s()-%d line %d failed %s: ",
7483 __func__, i, __LINE__,
7484 "failed to process sym crypto op");
7489 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7490 printf("TestCase %s()-%d line %d failed %s: ",
7491 __func__, i, __LINE__, "crypto op processing failed");
7497 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7500 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7504 fragsz = frag_size_oop;
7505 if (memcmp(ciphertext, output_vec, fragsz)) {
7506 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7507 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7508 rte_hexdump(stdout, "reference", output_vec, fragsz);
7513 buf = ut_params->op->sym->m_src->next;
7515 buf = ut_params->op->sym->m_dst->next;
7517 unsigned int off = fragsz;
7521 ciphertext = rte_pktmbuf_mtod(buf,
7523 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7524 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7525 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7526 rte_hexdump(stdout, "reference", output_vec + off,
7531 off += to_trn_tbl[ecx++];
7535 rte_crypto_op_free(ut_params->op);
7536 ut_params->op = NULL;
7538 if (ut_params->sec_session)
7539 rte_security_session_destroy(ctx, ut_params->sec_session);
7540 ut_params->sec_session = NULL;
7542 rte_pktmbuf_free(ut_params->ibuf);
7543 ut_params->ibuf = NULL;
7545 rte_pktmbuf_free(ut_params->obuf);
7546 ut_params->obuf = NULL;
7553 test_pdcp_proto_cplane_encap(int i)
7555 return test_pdcp_proto(i, 0,
7556 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7557 RTE_CRYPTO_AUTH_OP_GENERATE,
7558 pdcp_test_data_in[i],
7559 pdcp_test_data_in_len[i],
7560 pdcp_test_data_out[i],
7561 pdcp_test_data_in_len[i]+4);
7565 test_pdcp_proto_uplane_encap(int i)
7567 return test_pdcp_proto(i, 0,
7568 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7569 RTE_CRYPTO_AUTH_OP_GENERATE,
7570 pdcp_test_data_in[i],
7571 pdcp_test_data_in_len[i],
7572 pdcp_test_data_out[i],
7573 pdcp_test_data_in_len[i]);
7578 test_pdcp_proto_uplane_encap_with_int(int i)
7580 return test_pdcp_proto(i, 0,
7581 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7582 RTE_CRYPTO_AUTH_OP_GENERATE,
7583 pdcp_test_data_in[i],
7584 pdcp_test_data_in_len[i],
7585 pdcp_test_data_out[i],
7586 pdcp_test_data_in_len[i] + 4);
7590 test_pdcp_proto_cplane_decap(int i)
7592 return test_pdcp_proto(i, 0,
7593 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7594 RTE_CRYPTO_AUTH_OP_VERIFY,
7595 pdcp_test_data_out[i],
7596 pdcp_test_data_in_len[i] + 4,
7597 pdcp_test_data_in[i],
7598 pdcp_test_data_in_len[i]);
7602 test_pdcp_proto_uplane_decap(int i)
7604 return test_pdcp_proto(i, 0,
7605 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7606 RTE_CRYPTO_AUTH_OP_VERIFY,
7607 pdcp_test_data_out[i],
7608 pdcp_test_data_in_len[i],
7609 pdcp_test_data_in[i],
7610 pdcp_test_data_in_len[i]);
7614 test_pdcp_proto_uplane_decap_with_int(int i)
7616 return test_pdcp_proto(i, 0,
7617 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7618 RTE_CRYPTO_AUTH_OP_VERIFY,
7619 pdcp_test_data_out[i],
7620 pdcp_test_data_in_len[i] + 4,
7621 pdcp_test_data_in[i],
7622 pdcp_test_data_in_len[i]);
7626 test_PDCP_PROTO_SGL_in_place_32B(void)
7628 /* i can be used for running any PDCP case
7629 * In this case it is uplane 12-bit AES-SNOW DL encap
7631 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7632 return test_pdcp_proto_SGL(i, IN_PLACE,
7633 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7634 RTE_CRYPTO_AUTH_OP_GENERATE,
7635 pdcp_test_data_in[i],
7636 pdcp_test_data_in_len[i],
7637 pdcp_test_data_out[i],
7638 pdcp_test_data_in_len[i]+4,
7642 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7644 /* i can be used for running any PDCP case
7645 * In this case it is uplane 18-bit NULL-NULL DL encap
7647 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7648 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7649 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7650 RTE_CRYPTO_AUTH_OP_GENERATE,
7651 pdcp_test_data_in[i],
7652 pdcp_test_data_in_len[i],
7653 pdcp_test_data_out[i],
7654 pdcp_test_data_in_len[i]+4,
7658 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7660 /* i can be used for running any PDCP case
7661 * In this case it is uplane 18-bit AES DL encap
7663 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7665 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7666 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7667 RTE_CRYPTO_AUTH_OP_GENERATE,
7668 pdcp_test_data_in[i],
7669 pdcp_test_data_in_len[i],
7670 pdcp_test_data_out[i],
7671 pdcp_test_data_in_len[i],
7675 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7677 /* i can be used for running any PDCP case
7678 * In this case it is cplane 12-bit AES-ZUC DL encap
7680 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7681 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7682 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7683 RTE_CRYPTO_AUTH_OP_GENERATE,
7684 pdcp_test_data_in[i],
7685 pdcp_test_data_in_len[i],
7686 pdcp_test_data_out[i],
7687 pdcp_test_data_in_len[i]+4,
7693 test_AES_GCM_authenticated_encryption_test_case_1(void)
7695 return test_authenticated_encryption(&gcm_test_case_1);
7699 test_AES_GCM_authenticated_encryption_test_case_2(void)
7701 return test_authenticated_encryption(&gcm_test_case_2);
7705 test_AES_GCM_authenticated_encryption_test_case_3(void)
7707 return test_authenticated_encryption(&gcm_test_case_3);
7711 test_AES_GCM_authenticated_encryption_test_case_4(void)
7713 return test_authenticated_encryption(&gcm_test_case_4);
7717 test_AES_GCM_authenticated_encryption_test_case_5(void)
7719 return test_authenticated_encryption(&gcm_test_case_5);
7723 test_AES_GCM_authenticated_encryption_test_case_6(void)
7725 return test_authenticated_encryption(&gcm_test_case_6);
7729 test_AES_GCM_authenticated_encryption_test_case_7(void)
7731 return test_authenticated_encryption(&gcm_test_case_7);
7735 test_AES_GCM_authenticated_encryption_test_case_8(void)
7737 return test_authenticated_encryption(&gcm_test_case_8);
7741 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7743 return test_authenticated_encryption(&gcm_J0_test_case_1);
7747 test_AES_GCM_auth_encryption_test_case_192_1(void)
7749 return test_authenticated_encryption(&gcm_test_case_192_1);
7753 test_AES_GCM_auth_encryption_test_case_192_2(void)
7755 return test_authenticated_encryption(&gcm_test_case_192_2);
7759 test_AES_GCM_auth_encryption_test_case_192_3(void)
7761 return test_authenticated_encryption(&gcm_test_case_192_3);
7765 test_AES_GCM_auth_encryption_test_case_192_4(void)
7767 return test_authenticated_encryption(&gcm_test_case_192_4);
7771 test_AES_GCM_auth_encryption_test_case_192_5(void)
7773 return test_authenticated_encryption(&gcm_test_case_192_5);
7777 test_AES_GCM_auth_encryption_test_case_192_6(void)
7779 return test_authenticated_encryption(&gcm_test_case_192_6);
7783 test_AES_GCM_auth_encryption_test_case_192_7(void)
7785 return test_authenticated_encryption(&gcm_test_case_192_7);
7789 test_AES_GCM_auth_encryption_test_case_256_1(void)
7791 return test_authenticated_encryption(&gcm_test_case_256_1);
7795 test_AES_GCM_auth_encryption_test_case_256_2(void)
7797 return test_authenticated_encryption(&gcm_test_case_256_2);
7801 test_AES_GCM_auth_encryption_test_case_256_3(void)
7803 return test_authenticated_encryption(&gcm_test_case_256_3);
7807 test_AES_GCM_auth_encryption_test_case_256_4(void)
7809 return test_authenticated_encryption(&gcm_test_case_256_4);
7813 test_AES_GCM_auth_encryption_test_case_256_5(void)
7815 return test_authenticated_encryption(&gcm_test_case_256_5);
7819 test_AES_GCM_auth_encryption_test_case_256_6(void)
7821 return test_authenticated_encryption(&gcm_test_case_256_6);
7825 test_AES_GCM_auth_encryption_test_case_256_7(void)
7827 return test_authenticated_encryption(&gcm_test_case_256_7);
7831 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7833 return test_authenticated_encryption(&gcm_test_case_aad_1);
7837 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7839 return test_authenticated_encryption(&gcm_test_case_aad_2);
7843 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7845 struct aead_test_data tdata;
7848 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7849 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7850 tdata.iv.data[0] += 1;
7851 res = test_authenticated_encryption(&tdata);
7852 if (res == -ENOTSUP)
7854 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7855 return TEST_SUCCESS;
7859 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7861 struct aead_test_data tdata;
7864 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7865 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7866 tdata.plaintext.data[0] += 1;
7867 res = test_authenticated_encryption(&tdata);
7868 if (res == -ENOTSUP)
7870 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7871 return TEST_SUCCESS;
7875 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7877 struct aead_test_data tdata;
7880 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7881 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7882 tdata.ciphertext.data[0] += 1;
7883 res = test_authenticated_encryption(&tdata);
7884 if (res == -ENOTSUP)
7886 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7887 return TEST_SUCCESS;
7891 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7893 struct aead_test_data tdata;
7896 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7897 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7899 res = test_authenticated_encryption(&tdata);
7900 if (res == -ENOTSUP)
7902 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7903 return TEST_SUCCESS;
7907 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7909 struct aead_test_data tdata;
7910 uint8_t aad[gcm_test_case_7.aad.len];
7913 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7914 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7915 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7917 tdata.aad.data = aad;
7918 res = test_authenticated_encryption(&tdata);
7919 if (res == -ENOTSUP)
7921 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7922 return TEST_SUCCESS;
7926 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7928 struct aead_test_data tdata;
7931 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7932 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7933 tdata.auth_tag.data[0] += 1;
7934 res = test_authenticated_encryption(&tdata);
7935 if (res == -ENOTSUP)
7937 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7938 return TEST_SUCCESS;
7942 test_authenticated_decryption(const struct aead_test_data *tdata)
7944 struct crypto_testsuite_params *ts_params = &testsuite_params;
7945 struct crypto_unittest_params *ut_params = &unittest_params;
7951 /* Verify the capabilities */
7952 struct rte_cryptodev_sym_capability_idx cap_idx;
7953 const struct rte_cryptodev_symmetric_capability *capability;
7954 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7955 cap_idx.algo.aead = tdata->algo;
7956 capability = rte_cryptodev_sym_capability_get(
7957 ts_params->valid_devs[0], &cap_idx);
7958 if (capability == NULL)
7960 if (rte_cryptodev_sym_capability_check_aead(
7961 capability, tdata->key.len, tdata->auth_tag.len,
7962 tdata->aad.len, tdata->iv.len))
7965 /* Create AEAD session */
7966 retval = create_aead_session(ts_params->valid_devs[0],
7968 RTE_CRYPTO_AEAD_OP_DECRYPT,
7969 tdata->key.data, tdata->key.len,
7970 tdata->aad.len, tdata->auth_tag.len,
7975 /* alloc mbuf and set payload */
7976 if (tdata->aad.len > MBUF_SIZE) {
7977 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7978 /* Populate full size of add data */
7979 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7980 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7985 rte_pktmbuf_tailroom(ut_params->ibuf));
7987 /* Create AEAD operation */
7988 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7992 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7994 ut_params->op->sym->m_src = ut_params->ibuf;
7996 /* Process crypto operation */
7997 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7998 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8000 TEST_ASSERT_NOT_NULL(
8001 process_crypto_request(ts_params->valid_devs[0],
8002 ut_params->op), "failed to process sym crypto op");
8004 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8005 "crypto op processing failed");
8007 if (ut_params->op->sym->m_dst)
8008 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8011 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8013 ut_params->op->sym->cipher.data.offset);
8015 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8018 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8020 tdata->plaintext.data,
8021 tdata->plaintext.len,
8022 "Plaintext data not as expected");
8024 TEST_ASSERT_EQUAL(ut_params->op->status,
8025 RTE_CRYPTO_OP_STATUS_SUCCESS,
8026 "Authentication failed");
8032 test_AES_GCM_authenticated_decryption_test_case_1(void)
8034 return test_authenticated_decryption(&gcm_test_case_1);
8038 test_AES_GCM_authenticated_decryption_test_case_2(void)
8040 return test_authenticated_decryption(&gcm_test_case_2);
8044 test_AES_GCM_authenticated_decryption_test_case_3(void)
8046 return test_authenticated_decryption(&gcm_test_case_3);
8050 test_AES_GCM_authenticated_decryption_test_case_4(void)
8052 return test_authenticated_decryption(&gcm_test_case_4);
8056 test_AES_GCM_authenticated_decryption_test_case_5(void)
8058 return test_authenticated_decryption(&gcm_test_case_5);
8062 test_AES_GCM_authenticated_decryption_test_case_6(void)
8064 return test_authenticated_decryption(&gcm_test_case_6);
8068 test_AES_GCM_authenticated_decryption_test_case_7(void)
8070 return test_authenticated_decryption(&gcm_test_case_7);
8074 test_AES_GCM_authenticated_decryption_test_case_8(void)
8076 return test_authenticated_decryption(&gcm_test_case_8);
8080 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8082 return test_authenticated_decryption(&gcm_J0_test_case_1);
8086 test_AES_GCM_auth_decryption_test_case_192_1(void)
8088 return test_authenticated_decryption(&gcm_test_case_192_1);
8092 test_AES_GCM_auth_decryption_test_case_192_2(void)
8094 return test_authenticated_decryption(&gcm_test_case_192_2);
8098 test_AES_GCM_auth_decryption_test_case_192_3(void)
8100 return test_authenticated_decryption(&gcm_test_case_192_3);
8104 test_AES_GCM_auth_decryption_test_case_192_4(void)
8106 return test_authenticated_decryption(&gcm_test_case_192_4);
8110 test_AES_GCM_auth_decryption_test_case_192_5(void)
8112 return test_authenticated_decryption(&gcm_test_case_192_5);
8116 test_AES_GCM_auth_decryption_test_case_192_6(void)
8118 return test_authenticated_decryption(&gcm_test_case_192_6);
8122 test_AES_GCM_auth_decryption_test_case_192_7(void)
8124 return test_authenticated_decryption(&gcm_test_case_192_7);
8128 test_AES_GCM_auth_decryption_test_case_256_1(void)
8130 return test_authenticated_decryption(&gcm_test_case_256_1);
8134 test_AES_GCM_auth_decryption_test_case_256_2(void)
8136 return test_authenticated_decryption(&gcm_test_case_256_2);
8140 test_AES_GCM_auth_decryption_test_case_256_3(void)
8142 return test_authenticated_decryption(&gcm_test_case_256_3);
8146 test_AES_GCM_auth_decryption_test_case_256_4(void)
8148 return test_authenticated_decryption(&gcm_test_case_256_4);
8152 test_AES_GCM_auth_decryption_test_case_256_5(void)
8154 return test_authenticated_decryption(&gcm_test_case_256_5);
8158 test_AES_GCM_auth_decryption_test_case_256_6(void)
8160 return test_authenticated_decryption(&gcm_test_case_256_6);
8164 test_AES_GCM_auth_decryption_test_case_256_7(void)
8166 return test_authenticated_decryption(&gcm_test_case_256_7);
8170 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8172 return test_authenticated_decryption(&gcm_test_case_aad_1);
8176 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8178 return test_authenticated_decryption(&gcm_test_case_aad_2);
8182 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8184 struct aead_test_data tdata;
8187 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8188 tdata.iv.data[0] += 1;
8189 res = test_authenticated_decryption(&tdata);
8190 if (res == -ENOTSUP)
8192 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8193 return TEST_SUCCESS;
8197 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8199 struct aead_test_data tdata;
8202 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8203 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8204 tdata.plaintext.data[0] += 1;
8205 res = test_authenticated_decryption(&tdata);
8206 if (res == -ENOTSUP)
8208 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8209 return TEST_SUCCESS;
8213 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8215 struct aead_test_data tdata;
8218 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8219 tdata.ciphertext.data[0] += 1;
8220 res = test_authenticated_decryption(&tdata);
8221 if (res == -ENOTSUP)
8223 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8224 return TEST_SUCCESS;
8228 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8230 struct aead_test_data tdata;
8233 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8235 res = test_authenticated_decryption(&tdata);
8236 if (res == -ENOTSUP)
8238 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8239 return TEST_SUCCESS;
8243 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8245 struct aead_test_data tdata;
8246 uint8_t aad[gcm_test_case_7.aad.len];
8249 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8250 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8252 tdata.aad.data = aad;
8253 res = test_authenticated_decryption(&tdata);
8254 if (res == -ENOTSUP)
8256 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8257 return TEST_SUCCESS;
8261 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8263 struct aead_test_data tdata;
8266 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8267 tdata.auth_tag.data[0] += 1;
8268 res = test_authenticated_decryption(&tdata);
8269 if (res == -ENOTSUP)
8271 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8272 return TEST_SUCCESS;
8276 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8278 struct crypto_testsuite_params *ts_params = &testsuite_params;
8279 struct crypto_unittest_params *ut_params = &unittest_params;
8282 uint8_t *ciphertext, *auth_tag;
8283 uint16_t plaintext_pad_len;
8285 /* Verify the capabilities */
8286 struct rte_cryptodev_sym_capability_idx cap_idx;
8287 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8288 cap_idx.algo.aead = tdata->algo;
8289 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8293 /* not supported with CPU crypto */
8294 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8297 /* Create AEAD session */
8298 retval = create_aead_session(ts_params->valid_devs[0],
8300 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8301 tdata->key.data, tdata->key.len,
8302 tdata->aad.len, tdata->auth_tag.len,
8307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8308 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8310 /* clear mbuf payload */
8311 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8312 rte_pktmbuf_tailroom(ut_params->ibuf));
8313 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8314 rte_pktmbuf_tailroom(ut_params->obuf));
8316 /* Create AEAD operation */
8317 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8321 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8323 ut_params->op->sym->m_src = ut_params->ibuf;
8324 ut_params->op->sym->m_dst = ut_params->obuf;
8326 /* Process crypto operation */
8327 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8328 ut_params->op), "failed to process sym crypto op");
8330 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8331 "crypto op processing failed");
8333 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8335 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8336 ut_params->op->sym->cipher.data.offset);
8337 auth_tag = ciphertext + plaintext_pad_len;
8339 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8340 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8343 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8345 tdata->ciphertext.data,
8346 tdata->ciphertext.len,
8347 "Ciphertext data not as expected");
8349 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8351 tdata->auth_tag.data,
8352 tdata->auth_tag.len,
8353 "Generated auth tag not as expected");
8360 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8362 return test_authenticated_encryption_oop(&gcm_test_case_5);
8366 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8368 struct crypto_testsuite_params *ts_params = &testsuite_params;
8369 struct crypto_unittest_params *ut_params = &unittest_params;
8374 /* Verify the capabilities */
8375 struct rte_cryptodev_sym_capability_idx cap_idx;
8376 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8377 cap_idx.algo.aead = tdata->algo;
8378 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8382 /* not supported with CPU crypto */
8383 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8386 /* Create AEAD session */
8387 retval = create_aead_session(ts_params->valid_devs[0],
8389 RTE_CRYPTO_AEAD_OP_DECRYPT,
8390 tdata->key.data, tdata->key.len,
8391 tdata->aad.len, tdata->auth_tag.len,
8396 /* alloc mbuf and set payload */
8397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8398 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8400 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8401 rte_pktmbuf_tailroom(ut_params->ibuf));
8402 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8403 rte_pktmbuf_tailroom(ut_params->obuf));
8405 /* Create AEAD operation */
8406 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8410 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8412 ut_params->op->sym->m_src = ut_params->ibuf;
8413 ut_params->op->sym->m_dst = ut_params->obuf;
8415 /* Process crypto operation */
8416 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8417 ut_params->op), "failed to process sym crypto op");
8419 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8420 "crypto op processing failed");
8422 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8423 ut_params->op->sym->cipher.data.offset);
8425 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8428 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8430 tdata->plaintext.data,
8431 tdata->plaintext.len,
8432 "Plaintext data not as expected");
8434 TEST_ASSERT_EQUAL(ut_params->op->status,
8435 RTE_CRYPTO_OP_STATUS_SUCCESS,
8436 "Authentication failed");
8441 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8443 return test_authenticated_decryption_oop(&gcm_test_case_5);
8447 test_authenticated_encryption_sessionless(
8448 const struct aead_test_data *tdata)
8450 struct crypto_testsuite_params *ts_params = &testsuite_params;
8451 struct crypto_unittest_params *ut_params = &unittest_params;
8454 uint8_t *ciphertext, *auth_tag;
8455 uint16_t plaintext_pad_len;
8456 uint8_t key[tdata->key.len + 1];
8458 /* This test is for AESNI MB and AESNI GCM PMDs only */
8459 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8460 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8461 (gbl_driver_id != rte_cryptodev_driver_id_get(
8462 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8465 /* not supported with CPU crypto */
8466 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8469 /* Verify the capabilities */
8470 struct rte_cryptodev_sym_capability_idx cap_idx;
8471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8472 cap_idx.algo.aead = tdata->algo;
8473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8477 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8479 /* clear mbuf payload */
8480 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8481 rte_pktmbuf_tailroom(ut_params->ibuf));
8483 /* Create AEAD operation */
8484 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8488 /* Create GCM xform */
8489 memcpy(key, tdata->key.data, tdata->key.len);
8490 retval = create_aead_xform(ut_params->op,
8492 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8493 key, tdata->key.len,
8494 tdata->aad.len, tdata->auth_tag.len,
8499 ut_params->op->sym->m_src = ut_params->ibuf;
8501 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8502 RTE_CRYPTO_OP_SESSIONLESS,
8503 "crypto op session type not sessionless");
8505 /* Process crypto operation */
8506 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8507 ut_params->op), "failed to process sym crypto op");
8509 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8511 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8512 "crypto op status not success");
8514 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8516 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8517 ut_params->op->sym->cipher.data.offset);
8518 auth_tag = ciphertext + plaintext_pad_len;
8520 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8521 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8524 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8526 tdata->ciphertext.data,
8527 tdata->ciphertext.len,
8528 "Ciphertext data not as expected");
8530 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8532 tdata->auth_tag.data,
8533 tdata->auth_tag.len,
8534 "Generated auth tag not as expected");
8541 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8543 return test_authenticated_encryption_sessionless(
8548 test_authenticated_decryption_sessionless(
8549 const struct aead_test_data *tdata)
8551 struct crypto_testsuite_params *ts_params = &testsuite_params;
8552 struct crypto_unittest_params *ut_params = &unittest_params;
8556 uint8_t key[tdata->key.len + 1];
8558 /* This test is for AESNI MB and AESNI GCM PMDs only */
8559 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8560 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8561 (gbl_driver_id != rte_cryptodev_driver_id_get(
8562 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8565 /* not supported with CPU crypto */
8566 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8569 /* Verify the capabilities */
8570 struct rte_cryptodev_sym_capability_idx cap_idx;
8571 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8572 cap_idx.algo.aead = tdata->algo;
8573 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8577 /* alloc mbuf and set payload */
8578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8581 rte_pktmbuf_tailroom(ut_params->ibuf));
8583 /* Create AEAD operation */
8584 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8588 /* Create AEAD xform */
8589 memcpy(key, tdata->key.data, tdata->key.len);
8590 retval = create_aead_xform(ut_params->op,
8592 RTE_CRYPTO_AEAD_OP_DECRYPT,
8593 key, tdata->key.len,
8594 tdata->aad.len, tdata->auth_tag.len,
8599 ut_params->op->sym->m_src = ut_params->ibuf;
8601 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8602 RTE_CRYPTO_OP_SESSIONLESS,
8603 "crypto op session type not sessionless");
8605 /* Process crypto operation */
8606 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8607 ut_params->op), "failed to process sym crypto op");
8609 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8611 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8612 "crypto op status not success");
8614 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8615 ut_params->op->sym->cipher.data.offset);
8617 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8620 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8622 tdata->plaintext.data,
8623 tdata->plaintext.len,
8624 "Plaintext data not as expected");
8626 TEST_ASSERT_EQUAL(ut_params->op->status,
8627 RTE_CRYPTO_OP_STATUS_SUCCESS,
8628 "Authentication failed");
8633 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8635 return test_authenticated_decryption_sessionless(
8640 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8642 return test_authenticated_encryption(&ccm_test_case_128_1);
8646 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8648 return test_authenticated_encryption(&ccm_test_case_128_2);
8652 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8654 return test_authenticated_encryption(&ccm_test_case_128_3);
8658 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8660 return test_authenticated_decryption(&ccm_test_case_128_1);
8664 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8666 return test_authenticated_decryption(&ccm_test_case_128_2);
8670 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8672 return test_authenticated_decryption(&ccm_test_case_128_3);
8676 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8678 return test_authenticated_encryption(&ccm_test_case_192_1);
8682 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8684 return test_authenticated_encryption(&ccm_test_case_192_2);
8688 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8690 return test_authenticated_encryption(&ccm_test_case_192_3);
8694 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8696 return test_authenticated_decryption(&ccm_test_case_192_1);
8700 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8702 return test_authenticated_decryption(&ccm_test_case_192_2);
8706 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8708 return test_authenticated_decryption(&ccm_test_case_192_3);
8712 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8714 return test_authenticated_encryption(&ccm_test_case_256_1);
8718 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8720 return test_authenticated_encryption(&ccm_test_case_256_2);
8724 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8726 return test_authenticated_encryption(&ccm_test_case_256_3);
8730 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8732 return test_authenticated_decryption(&ccm_test_case_256_1);
8736 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8738 return test_authenticated_decryption(&ccm_test_case_256_2);
8742 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8744 return test_authenticated_decryption(&ccm_test_case_256_3);
8750 struct crypto_testsuite_params *ts_params = &testsuite_params;
8751 struct rte_cryptodev_stats stats;
8752 struct rte_cryptodev *dev;
8753 cryptodev_stats_get_t temp_pfn;
8755 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8758 /* Verify the capabilities */
8759 struct rte_cryptodev_sym_capability_idx cap_idx;
8760 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8761 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8762 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8765 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8766 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8767 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8771 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8772 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8773 &stats) == -ENODEV),
8774 "rte_cryptodev_stats_get invalid dev failed");
8775 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8776 "rte_cryptodev_stats_get invalid Param failed");
8777 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8778 temp_pfn = dev->dev_ops->stats_get;
8779 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8780 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8782 "rte_cryptodev_stats_get invalid Param failed");
8783 dev->dev_ops->stats_get = temp_pfn;
8785 /* Test expected values */
8787 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8789 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8791 "rte_cryptodev_stats_get failed");
8792 TEST_ASSERT((stats.enqueued_count == 1),
8793 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8794 TEST_ASSERT((stats.dequeued_count == 1),
8795 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8796 TEST_ASSERT((stats.enqueue_err_count == 0),
8797 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8798 TEST_ASSERT((stats.dequeue_err_count == 0),
8799 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8801 /* invalid device but should ignore and not reset device stats*/
8802 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8803 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8805 "rte_cryptodev_stats_get failed");
8806 TEST_ASSERT((stats.enqueued_count == 1),
8807 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8809 /* check that a valid reset clears stats */
8810 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8811 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8813 "rte_cryptodev_stats_get failed");
8814 TEST_ASSERT((stats.enqueued_count == 0),
8815 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8816 TEST_ASSERT((stats.dequeued_count == 0),
8817 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8819 return TEST_SUCCESS;
8822 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8823 struct crypto_unittest_params *ut_params,
8824 enum rte_crypto_auth_operation op,
8825 const struct HMAC_MD5_vector *test_case)
8829 memcpy(key, test_case->key.data, test_case->key.len);
8831 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8832 ut_params->auth_xform.next = NULL;
8833 ut_params->auth_xform.auth.op = op;
8835 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8837 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8838 ut_params->auth_xform.auth.key.length = test_case->key.len;
8839 ut_params->auth_xform.auth.key.data = key;
8841 ut_params->sess = rte_cryptodev_sym_session_create(
8842 ts_params->session_mpool);
8844 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8845 ut_params->sess, &ut_params->auth_xform,
8846 ts_params->session_priv_mpool);
8848 if (ut_params->sess == NULL)
8851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8853 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8854 rte_pktmbuf_tailroom(ut_params->ibuf));
8859 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8860 const struct HMAC_MD5_vector *test_case,
8861 uint8_t **plaintext)
8863 uint16_t plaintext_pad_len;
8865 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8867 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8870 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8872 memcpy(*plaintext, test_case->plaintext.data,
8873 test_case->plaintext.len);
8875 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8876 ut_params->ibuf, MD5_DIGEST_LEN);
8877 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8878 "no room to append digest");
8879 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8880 ut_params->ibuf, plaintext_pad_len);
8882 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8883 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8884 test_case->auth_tag.len);
8887 sym_op->auth.data.offset = 0;
8888 sym_op->auth.data.length = test_case->plaintext.len;
8890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8891 ut_params->op->sym->m_src = ut_params->ibuf;
8897 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8899 uint16_t plaintext_pad_len;
8900 uint8_t *plaintext, *auth_tag;
8902 struct crypto_testsuite_params *ts_params = &testsuite_params;
8903 struct crypto_unittest_params *ut_params = &unittest_params;
8905 /* Verify the capabilities */
8906 struct rte_cryptodev_sym_capability_idx cap_idx;
8907 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8908 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8909 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8913 if (MD5_HMAC_create_session(ts_params, ut_params,
8914 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8917 /* Generate Crypto op data structure */
8918 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8919 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8920 TEST_ASSERT_NOT_NULL(ut_params->op,
8921 "Failed to allocate symmetric crypto operation struct");
8923 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8926 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8929 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8930 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8933 TEST_ASSERT_NOT_NULL(
8934 process_crypto_request(ts_params->valid_devs[0],
8936 "failed to process sym crypto op");
8938 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8939 "crypto op processing failed");
8941 if (ut_params->op->sym->m_dst) {
8942 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8943 uint8_t *, plaintext_pad_len);
8945 auth_tag = plaintext + plaintext_pad_len;
8948 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8950 test_case->auth_tag.data,
8951 test_case->auth_tag.len,
8952 "HMAC_MD5 generated tag not as expected");
8954 return TEST_SUCCESS;
8958 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8962 struct crypto_testsuite_params *ts_params = &testsuite_params;
8963 struct crypto_unittest_params *ut_params = &unittest_params;
8965 /* Verify the capabilities */
8966 struct rte_cryptodev_sym_capability_idx cap_idx;
8967 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8968 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8969 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8973 if (MD5_HMAC_create_session(ts_params, ut_params,
8974 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8978 /* Generate Crypto op data structure */
8979 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8980 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8981 TEST_ASSERT_NOT_NULL(ut_params->op,
8982 "Failed to allocate symmetric crypto operation struct");
8984 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8987 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8988 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8991 TEST_ASSERT_NOT_NULL(
8992 process_crypto_request(ts_params->valid_devs[0],
8994 "failed to process sym crypto op");
8996 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8997 "HMAC_MD5 crypto op processing failed");
8999 return TEST_SUCCESS;
9003 test_MD5_HMAC_generate_case_1(void)
9005 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9009 test_MD5_HMAC_verify_case_1(void)
9011 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9015 test_MD5_HMAC_generate_case_2(void)
9017 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9021 test_MD5_HMAC_verify_case_2(void)
9023 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9027 test_multi_session(void)
9029 struct crypto_testsuite_params *ts_params = &testsuite_params;
9030 struct crypto_unittest_params *ut_params = &unittest_params;
9032 struct rte_cryptodev_info dev_info;
9033 struct rte_cryptodev_sym_session **sessions;
9037 /* Verify the capabilities */
9038 struct rte_cryptodev_sym_capability_idx cap_idx;
9039 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9040 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9041 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9044 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9045 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9046 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9050 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9051 aes_cbc_key, hmac_sha512_key);
9054 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9056 sessions = rte_malloc(NULL,
9057 (sizeof(struct rte_cryptodev_sym_session *) *
9058 MAX_NB_SESSIONS) + 1, 0);
9060 /* Create multiple crypto sessions*/
9061 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9063 sessions[i] = rte_cryptodev_sym_session_create(
9064 ts_params->session_mpool);
9066 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9067 sessions[i], &ut_params->auth_xform,
9068 ts_params->session_priv_mpool);
9069 TEST_ASSERT_NOT_NULL(sessions[i],
9070 "Session creation failed at session number %u",
9073 /* Attempt to send a request on each session */
9074 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9078 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9079 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9081 "Failed to perform decrypt on request number %u.", i);
9082 /* free crypto operation structure */
9084 rte_crypto_op_free(ut_params->op);
9087 * free mbuf - both obuf and ibuf are usually the same,
9088 * so check if they point at the same address is necessary,
9089 * to avoid freeing the mbuf twice.
9091 if (ut_params->obuf) {
9092 rte_pktmbuf_free(ut_params->obuf);
9093 if (ut_params->ibuf == ut_params->obuf)
9094 ut_params->ibuf = 0;
9095 ut_params->obuf = 0;
9097 if (ut_params->ibuf) {
9098 rte_pktmbuf_free(ut_params->ibuf);
9099 ut_params->ibuf = 0;
9103 /* Next session create should fail */
9104 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9105 sessions[i], &ut_params->auth_xform,
9106 ts_params->session_priv_mpool);
9107 TEST_ASSERT_NULL(sessions[i],
9108 "Session creation succeeded unexpectedly!");
9110 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9111 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9113 rte_cryptodev_sym_session_free(sessions[i]);
9118 return TEST_SUCCESS;
9121 struct multi_session_params {
9122 struct crypto_unittest_params ut_params;
9123 uint8_t *cipher_key;
9125 const uint8_t *cipher;
9126 const uint8_t *digest;
9130 #define MB_SESSION_NUMBER 3
9133 test_multi_session_random_usage(void)
9135 struct crypto_testsuite_params *ts_params = &testsuite_params;
9136 struct rte_cryptodev_info dev_info;
9137 struct rte_cryptodev_sym_session **sessions;
9139 struct multi_session_params ut_paramz[] = {
9142 .cipher_key = ms_aes_cbc_key0,
9143 .hmac_key = ms_hmac_key0,
9144 .cipher = ms_aes_cbc_cipher0,
9145 .digest = ms_hmac_digest0,
9146 .iv = ms_aes_cbc_iv0
9149 .cipher_key = ms_aes_cbc_key1,
9150 .hmac_key = ms_hmac_key1,
9151 .cipher = ms_aes_cbc_cipher1,
9152 .digest = ms_hmac_digest1,
9153 .iv = ms_aes_cbc_iv1
9156 .cipher_key = ms_aes_cbc_key2,
9157 .hmac_key = ms_hmac_key2,
9158 .cipher = ms_aes_cbc_cipher2,
9159 .digest = ms_hmac_digest2,
9160 .iv = ms_aes_cbc_iv2
9165 /* Verify the capabilities */
9166 struct rte_cryptodev_sym_capability_idx cap_idx;
9167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9168 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9169 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9172 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9173 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9174 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9178 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9180 sessions = rte_malloc(NULL,
9181 (sizeof(struct rte_cryptodev_sym_session *)
9182 * MAX_NB_SESSIONS) + 1, 0);
9184 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9185 sessions[i] = rte_cryptodev_sym_session_create(
9186 ts_params->session_mpool);
9188 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9189 sizeof(struct crypto_unittest_params));
9191 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9192 &ut_paramz[i].ut_params,
9193 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9195 /* Create multiple crypto sessions*/
9196 rte_cryptodev_sym_session_init(
9197 ts_params->valid_devs[0],
9199 &ut_paramz[i].ut_params.auth_xform,
9200 ts_params->session_priv_mpool);
9202 TEST_ASSERT_NOT_NULL(sessions[i],
9203 "Session creation failed at session number %u",
9209 for (i = 0; i < 40000; i++) {
9211 j = rand() % MB_SESSION_NUMBER;
9213 TEST_ASSERT_SUCCESS(
9214 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9216 &ut_paramz[j].ut_params,
9217 ts_params, ut_paramz[j].cipher,
9218 ut_paramz[j].digest,
9220 "Failed to perform decrypt on request number %u.", i);
9222 if (ut_paramz[j].ut_params.op)
9223 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9226 * free mbuf - both obuf and ibuf are usually the same,
9227 * so check if they point at the same address is necessary,
9228 * to avoid freeing the mbuf twice.
9230 if (ut_paramz[j].ut_params.obuf) {
9231 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9232 if (ut_paramz[j].ut_params.ibuf
9233 == ut_paramz[j].ut_params.obuf)
9234 ut_paramz[j].ut_params.ibuf = 0;
9235 ut_paramz[j].ut_params.obuf = 0;
9237 if (ut_paramz[j].ut_params.ibuf) {
9238 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9239 ut_paramz[j].ut_params.ibuf = 0;
9243 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9244 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9246 rte_cryptodev_sym_session_free(sessions[i]);
9251 return TEST_SUCCESS;
9255 test_null_cipher_only_operation(void)
9257 struct crypto_testsuite_params *ts_params = &testsuite_params;
9258 struct crypto_unittest_params *ut_params = &unittest_params;
9260 /* Verify the capabilities */
9261 struct rte_cryptodev_sym_capability_idx cap_idx;
9262 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9263 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9264 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9268 /* Generate test mbuf data and space for digest */
9269 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9270 catch_22_quote, QUOTE_512_BYTES, 0);
9272 /* Setup Cipher Parameters */
9273 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9274 ut_params->cipher_xform.next = NULL;
9276 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9277 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9279 ut_params->sess = rte_cryptodev_sym_session_create(
9280 ts_params->session_mpool);
9282 /* Create Crypto session*/
9283 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9285 &ut_params->cipher_xform,
9286 ts_params->session_priv_mpool);
9287 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9289 /* Generate Crypto op data structure */
9290 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9291 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9292 TEST_ASSERT_NOT_NULL(ut_params->op,
9293 "Failed to allocate symmetric crypto operation struct");
9295 /* Set crypto operation data parameters */
9296 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9298 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9300 /* set crypto operation source mbuf */
9301 sym_op->m_src = ut_params->ibuf;
9303 sym_op->cipher.data.offset = 0;
9304 sym_op->cipher.data.length = QUOTE_512_BYTES;
9306 /* Process crypto operation */
9307 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9309 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9311 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9312 "crypto operation processing failed");
9315 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9316 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9319 "Ciphertext data not as expected");
9321 return TEST_SUCCESS;
9323 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9324 0xab, 0xab, 0xab, 0xab,
9325 0xab, 0xab, 0xab, 0xab,
9326 0xab, 0xab, 0xab, 0xab};
9328 test_null_auth_only_operation(void)
9330 struct crypto_testsuite_params *ts_params = &testsuite_params;
9331 struct crypto_unittest_params *ut_params = &unittest_params;
9334 /* Verify the capabilities */
9335 struct rte_cryptodev_sym_capability_idx cap_idx;
9336 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9337 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9338 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9342 /* Generate test mbuf data and space for digest */
9343 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9344 catch_22_quote, QUOTE_512_BYTES, 0);
9346 /* create a pointer for digest, but don't expect anything to be written
9347 * here in a NULL auth algo so no mbuf append done.
9349 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9351 /* prefill the memory pointed to by digest */
9352 memcpy(digest, orig_data, sizeof(orig_data));
9354 /* Setup HMAC Parameters */
9355 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9356 ut_params->auth_xform.next = NULL;
9358 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9359 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9361 ut_params->sess = rte_cryptodev_sym_session_create(
9362 ts_params->session_mpool);
9364 /* Create Crypto session*/
9365 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9366 ut_params->sess, &ut_params->auth_xform,
9367 ts_params->session_priv_mpool);
9368 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9370 /* Generate Crypto op data structure */
9371 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9372 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9373 TEST_ASSERT_NOT_NULL(ut_params->op,
9374 "Failed to allocate symmetric crypto operation struct");
9376 /* Set crypto operation data parameters */
9377 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9379 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9381 sym_op->m_src = ut_params->ibuf;
9383 sym_op->auth.data.offset = 0;
9384 sym_op->auth.data.length = QUOTE_512_BYTES;
9385 sym_op->auth.digest.data = digest;
9386 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9389 /* Process crypto operation */
9390 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9392 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9394 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9395 "crypto operation processing failed");
9396 /* Make sure memory pointed to by digest hasn't been overwritten */
9397 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9401 "Memory at digest ptr overwritten unexpectedly");
9403 return TEST_SUCCESS;
9408 test_null_cipher_auth_operation(void)
9410 struct crypto_testsuite_params *ts_params = &testsuite_params;
9411 struct crypto_unittest_params *ut_params = &unittest_params;
9414 /* Verify the capabilities */
9415 struct rte_cryptodev_sym_capability_idx cap_idx;
9416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9417 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9421 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9422 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9427 /* Generate test mbuf data and space for digest */
9428 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9429 catch_22_quote, QUOTE_512_BYTES, 0);
9431 /* create a pointer for digest, but don't expect anything to be written
9432 * here in a NULL auth algo so no mbuf append done.
9434 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9436 /* prefill the memory pointed to by digest */
9437 memcpy(digest, orig_data, sizeof(orig_data));
9439 /* Setup Cipher Parameters */
9440 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9441 ut_params->cipher_xform.next = &ut_params->auth_xform;
9443 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9444 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9446 /* Setup HMAC Parameters */
9447 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9448 ut_params->auth_xform.next = NULL;
9450 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9451 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9453 ut_params->sess = rte_cryptodev_sym_session_create(
9454 ts_params->session_mpool);
9456 /* Create Crypto session*/
9457 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9458 ut_params->sess, &ut_params->cipher_xform,
9459 ts_params->session_priv_mpool);
9460 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9462 /* Generate Crypto op data structure */
9463 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9464 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9465 TEST_ASSERT_NOT_NULL(ut_params->op,
9466 "Failed to allocate symmetric crypto operation struct");
9468 /* Set crypto operation data parameters */
9469 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9471 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9473 sym_op->m_src = ut_params->ibuf;
9475 sym_op->cipher.data.offset = 0;
9476 sym_op->cipher.data.length = QUOTE_512_BYTES;
9478 sym_op->auth.data.offset = 0;
9479 sym_op->auth.data.length = QUOTE_512_BYTES;
9480 sym_op->auth.digest.data = digest;
9481 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9484 /* Process crypto operation */
9485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9487 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9489 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9490 "crypto operation processing failed");
9493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9494 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9497 "Ciphertext data not as expected");
9498 /* Make sure memory pointed to by digest hasn't been overwritten */
9499 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9503 "Memory at digest ptr overwritten unexpectedly");
9505 return TEST_SUCCESS;
9509 test_null_auth_cipher_operation(void)
9511 struct crypto_testsuite_params *ts_params = &testsuite_params;
9512 struct crypto_unittest_params *ut_params = &unittest_params;
9515 /* Verify the capabilities */
9516 struct rte_cryptodev_sym_capability_idx cap_idx;
9517 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9518 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9519 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9522 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9523 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9524 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9528 /* Generate test mbuf data */
9529 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9530 catch_22_quote, QUOTE_512_BYTES, 0);
9532 /* create a pointer for digest, but don't expect anything to be written
9533 * here in a NULL auth algo so no mbuf append done.
9535 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9537 /* prefill the memory pointed to by digest */
9538 memcpy(digest, orig_data, sizeof(orig_data));
9540 /* Setup Cipher Parameters */
9541 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9542 ut_params->cipher_xform.next = NULL;
9544 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9545 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9547 /* Setup HMAC Parameters */
9548 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9549 ut_params->auth_xform.next = &ut_params->cipher_xform;
9551 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9552 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9554 ut_params->sess = rte_cryptodev_sym_session_create(
9555 ts_params->session_mpool);
9557 /* Create Crypto session*/
9558 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9559 ut_params->sess, &ut_params->cipher_xform,
9560 ts_params->session_priv_mpool);
9561 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9563 /* Generate Crypto op data structure */
9564 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9565 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9566 TEST_ASSERT_NOT_NULL(ut_params->op,
9567 "Failed to allocate symmetric crypto operation struct");
9569 /* Set crypto operation data parameters */
9570 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9572 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9574 sym_op->m_src = ut_params->ibuf;
9576 sym_op->cipher.data.offset = 0;
9577 sym_op->cipher.data.length = QUOTE_512_BYTES;
9579 sym_op->auth.data.offset = 0;
9580 sym_op->auth.data.length = QUOTE_512_BYTES;
9581 sym_op->auth.digest.data = digest;
9582 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9585 /* Process crypto operation */
9586 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9588 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9590 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9591 "crypto operation processing failed");
9594 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9595 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9598 "Ciphertext data not as expected");
9599 /* Make sure memory pointed to by digest hasn't been overwritten */
9600 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9604 "Memory at digest ptr overwritten unexpectedly");
9606 return TEST_SUCCESS;
9611 test_null_invalid_operation(void)
9613 struct crypto_testsuite_params *ts_params = &testsuite_params;
9614 struct crypto_unittest_params *ut_params = &unittest_params;
9617 /* This test is for NULL PMD only */
9618 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9619 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9622 /* Setup Cipher Parameters */
9623 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9624 ut_params->cipher_xform.next = NULL;
9626 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9627 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9629 ut_params->sess = rte_cryptodev_sym_session_create(
9630 ts_params->session_mpool);
9632 /* Create Crypto session*/
9633 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9634 ut_params->sess, &ut_params->cipher_xform,
9635 ts_params->session_priv_mpool);
9636 TEST_ASSERT(ret < 0,
9637 "Session creation succeeded unexpectedly");
9640 /* Setup HMAC Parameters */
9641 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9642 ut_params->auth_xform.next = NULL;
9644 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9645 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9647 ut_params->sess = rte_cryptodev_sym_session_create(
9648 ts_params->session_mpool);
9650 /* Create Crypto session*/
9651 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9652 ut_params->sess, &ut_params->auth_xform,
9653 ts_params->session_priv_mpool);
9654 TEST_ASSERT(ret < 0,
9655 "Session creation succeeded unexpectedly");
9657 return TEST_SUCCESS;
9661 #define NULL_BURST_LENGTH (32)
9664 test_null_burst_operation(void)
9666 struct crypto_testsuite_params *ts_params = &testsuite_params;
9667 struct crypto_unittest_params *ut_params = &unittest_params;
9669 unsigned i, burst_len = NULL_BURST_LENGTH;
9671 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9672 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9674 /* This test is for NULL PMD only */
9675 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9676 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9679 /* Setup Cipher Parameters */
9680 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9681 ut_params->cipher_xform.next = &ut_params->auth_xform;
9683 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9684 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9686 /* Setup HMAC Parameters */
9687 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9688 ut_params->auth_xform.next = NULL;
9690 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9691 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9693 ut_params->sess = rte_cryptodev_sym_session_create(
9694 ts_params->session_mpool);
9696 /* Create Crypto session*/
9697 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9698 ut_params->sess, &ut_params->cipher_xform,
9699 ts_params->session_priv_mpool);
9700 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9702 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9703 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9704 burst_len, "failed to generate burst of crypto ops");
9706 /* Generate an operation for each mbuf in burst */
9707 for (i = 0; i < burst_len; i++) {
9708 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9710 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9712 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9716 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9718 burst[i]->sym->m_src = m;
9721 /* Process crypto operation */
9722 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9723 0, burst, burst_len),
9725 "Error enqueuing burst");
9727 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9728 0, burst_dequeued, burst_len),
9730 "Error dequeuing burst");
9733 for (i = 0; i < burst_len; i++) {
9735 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9736 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9738 "data not as expected");
9740 rte_pktmbuf_free(burst[i]->sym->m_src);
9741 rte_crypto_op_free(burst[i]);
9744 return TEST_SUCCESS;
9748 generate_gmac_large_plaintext(uint8_t *data)
9752 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9753 memcpy(&data[i], &data[0], 32);
9757 create_gmac_operation(enum rte_crypto_auth_operation op,
9758 const struct gmac_test_data *tdata)
9760 struct crypto_testsuite_params *ts_params = &testsuite_params;
9761 struct crypto_unittest_params *ut_params = &unittest_params;
9762 struct rte_crypto_sym_op *sym_op;
9764 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9766 /* Generate Crypto op data structure */
9767 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9768 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9769 TEST_ASSERT_NOT_NULL(ut_params->op,
9770 "Failed to allocate symmetric crypto operation struct");
9772 sym_op = ut_params->op->sym;
9774 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9775 ut_params->ibuf, tdata->gmac_tag.len);
9776 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9777 "no room to append digest");
9779 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9780 ut_params->ibuf, plaintext_pad_len);
9782 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9783 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9784 tdata->gmac_tag.len);
9785 debug_hexdump(stdout, "digest:",
9786 sym_op->auth.digest.data,
9787 tdata->gmac_tag.len);
9790 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9791 uint8_t *, IV_OFFSET);
9793 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9795 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9797 sym_op->cipher.data.length = 0;
9798 sym_op->cipher.data.offset = 0;
9800 sym_op->auth.data.offset = 0;
9801 sym_op->auth.data.length = tdata->plaintext.len;
9806 static int create_gmac_session(uint8_t dev_id,
9807 const struct gmac_test_data *tdata,
9808 enum rte_crypto_auth_operation auth_op)
9810 uint8_t auth_key[tdata->key.len];
9812 struct crypto_testsuite_params *ts_params = &testsuite_params;
9813 struct crypto_unittest_params *ut_params = &unittest_params;
9815 memcpy(auth_key, tdata->key.data, tdata->key.len);
9817 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9818 ut_params->auth_xform.next = NULL;
9820 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9821 ut_params->auth_xform.auth.op = auth_op;
9822 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9823 ut_params->auth_xform.auth.key.length = tdata->key.len;
9824 ut_params->auth_xform.auth.key.data = auth_key;
9825 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9826 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9829 ut_params->sess = rte_cryptodev_sym_session_create(
9830 ts_params->session_mpool);
9832 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9833 &ut_params->auth_xform,
9834 ts_params->session_priv_mpool);
9836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9842 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9844 struct crypto_testsuite_params *ts_params = &testsuite_params;
9845 struct crypto_unittest_params *ut_params = &unittest_params;
9849 uint8_t *auth_tag, *plaintext;
9850 uint16_t plaintext_pad_len;
9852 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9853 "No GMAC length in the source data");
9855 /* Verify the capabilities */
9856 struct rte_cryptodev_sym_capability_idx cap_idx;
9857 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9858 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9859 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9863 retval = create_gmac_session(ts_params->valid_devs[0],
9864 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9869 if (tdata->plaintext.len > MBUF_SIZE)
9870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9873 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9874 "Failed to allocate input buffer in mempool");
9876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9877 rte_pktmbuf_tailroom(ut_params->ibuf));
9879 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9881 * Runtime generate the large plain text instead of use hard code
9882 * plain text vector. It is done to avoid create huge source file
9883 * with the test vector.
9885 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9886 generate_gmac_large_plaintext(tdata->plaintext.data);
9888 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9890 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9892 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9893 debug_hexdump(stdout, "plaintext:", plaintext,
9894 tdata->plaintext.len);
9896 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9902 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9904 ut_params->op->sym->m_src = ut_params->ibuf;
9906 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9907 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9910 TEST_ASSERT_NOT_NULL(
9911 process_crypto_request(ts_params->valid_devs[0],
9912 ut_params->op), "failed to process sym crypto op");
9914 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9915 "crypto op processing failed");
9917 if (ut_params->op->sym->m_dst) {
9918 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9919 uint8_t *, plaintext_pad_len);
9921 auth_tag = plaintext + plaintext_pad_len;
9924 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9926 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9928 tdata->gmac_tag.data,
9929 tdata->gmac_tag.len,
9930 "GMAC Generated auth tag not as expected");
9936 test_AES_GMAC_authentication_test_case_1(void)
9938 return test_AES_GMAC_authentication(&gmac_test_case_1);
9942 test_AES_GMAC_authentication_test_case_2(void)
9944 return test_AES_GMAC_authentication(&gmac_test_case_2);
9948 test_AES_GMAC_authentication_test_case_3(void)
9950 return test_AES_GMAC_authentication(&gmac_test_case_3);
9954 test_AES_GMAC_authentication_test_case_4(void)
9956 return test_AES_GMAC_authentication(&gmac_test_case_4);
9960 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9962 struct crypto_testsuite_params *ts_params = &testsuite_params;
9963 struct crypto_unittest_params *ut_params = &unittest_params;
9965 uint32_t plaintext_pad_len;
9968 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9969 "No GMAC length in the source data");
9971 /* Verify the capabilities */
9972 struct rte_cryptodev_sym_capability_idx cap_idx;
9973 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9974 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9975 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9979 retval = create_gmac_session(ts_params->valid_devs[0],
9980 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9985 if (tdata->plaintext.len > MBUF_SIZE)
9986 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9989 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9990 "Failed to allocate input buffer in mempool");
9992 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9993 rte_pktmbuf_tailroom(ut_params->ibuf));
9995 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9998 * Runtime generate the large plain text instead of use hard code
9999 * plain text vector. It is done to avoid create huge source file
10000 * with the test vector.
10002 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10003 generate_gmac_large_plaintext(tdata->plaintext.data);
10005 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10006 plaintext_pad_len);
10007 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10009 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10010 debug_hexdump(stdout, "plaintext:", plaintext,
10011 tdata->plaintext.len);
10013 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10019 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10021 ut_params->op->sym->m_src = ut_params->ibuf;
10023 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10024 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10027 TEST_ASSERT_NOT_NULL(
10028 process_crypto_request(ts_params->valid_devs[0],
10029 ut_params->op), "failed to process sym crypto op");
10031 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10032 "crypto op processing failed");
10039 test_AES_GMAC_authentication_verify_test_case_1(void)
10041 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10045 test_AES_GMAC_authentication_verify_test_case_2(void)
10047 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10051 test_AES_GMAC_authentication_verify_test_case_3(void)
10053 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10057 test_AES_GMAC_authentication_verify_test_case_4(void)
10059 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10062 struct test_crypto_vector {
10063 enum rte_crypto_cipher_algorithm crypto_algo;
10064 unsigned int cipher_offset;
10065 unsigned int cipher_len;
10078 const uint8_t *data;
10083 const uint8_t *data;
10087 enum rte_crypto_auth_algorithm auth_algo;
10088 unsigned int auth_offset;
10096 const uint8_t *data;
10106 static const struct test_crypto_vector
10107 hmac_sha1_test_crypto_vector = {
10108 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10110 .data = plaintext_hash,
10115 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10116 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10117 0xDE, 0xF4, 0xDE, 0xAD
10123 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10124 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10125 0x3F, 0x91, 0x64, 0x59
10131 static const struct test_crypto_vector
10132 aes128_gmac_test_vector = {
10133 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10135 .data = plaintext_hash,
10140 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10141 0x08, 0x09, 0x0A, 0x0B
10147 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10148 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10154 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10155 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10161 static const struct test_crypto_vector
10162 aes128cbc_hmac_sha1_test_vector = {
10163 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10164 .cipher_offset = 0,
10168 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10169 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10175 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10176 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10181 .data = plaintext_hash,
10185 .data = ciphertext512_aes128cbc,
10188 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10192 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10193 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10194 0xDE, 0xF4, 0xDE, 0xAD
10200 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10201 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10202 0x18, 0x8C, 0x1D, 0x32
10208 static const struct test_crypto_vector
10209 aes128cbc_hmac_sha1_aad_test_vector = {
10210 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10211 .cipher_offset = 12,
10215 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10216 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10222 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10223 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10228 .data = plaintext_hash,
10232 .data = ciphertext512_aes128cbc_aad,
10235 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10239 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10240 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10241 0xDE, 0xF4, 0xDE, 0xAD
10247 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10248 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10249 0x62, 0x8D, 0x62, 0x65
10256 data_corruption(uint8_t *data)
10262 tag_corruption(uint8_t *data, unsigned int tag_offset)
10264 data[tag_offset] += 1;
10268 create_auth_session(struct crypto_unittest_params *ut_params,
10270 const struct test_crypto_vector *reference,
10271 enum rte_crypto_auth_operation auth_op)
10273 struct crypto_testsuite_params *ts_params = &testsuite_params;
10274 uint8_t auth_key[reference->auth_key.len + 1];
10276 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10278 /* Setup Authentication Parameters */
10279 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10280 ut_params->auth_xform.auth.op = auth_op;
10281 ut_params->auth_xform.next = NULL;
10282 ut_params->auth_xform.auth.algo = reference->auth_algo;
10283 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10284 ut_params->auth_xform.auth.key.data = auth_key;
10285 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10287 /* Create Crypto session*/
10288 ut_params->sess = rte_cryptodev_sym_session_create(
10289 ts_params->session_mpool);
10291 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10292 &ut_params->auth_xform,
10293 ts_params->session_priv_mpool);
10295 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10301 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10303 const struct test_crypto_vector *reference,
10304 enum rte_crypto_auth_operation auth_op,
10305 enum rte_crypto_cipher_operation cipher_op)
10307 struct crypto_testsuite_params *ts_params = &testsuite_params;
10308 uint8_t cipher_key[reference->cipher_key.len + 1];
10309 uint8_t auth_key[reference->auth_key.len + 1];
10311 memcpy(cipher_key, reference->cipher_key.data,
10312 reference->cipher_key.len);
10313 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10315 /* Setup Authentication Parameters */
10316 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10317 ut_params->auth_xform.auth.op = auth_op;
10318 ut_params->auth_xform.auth.algo = reference->auth_algo;
10319 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10320 ut_params->auth_xform.auth.key.data = auth_key;
10321 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10323 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10324 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10325 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10327 ut_params->auth_xform.next = &ut_params->cipher_xform;
10329 /* Setup Cipher Parameters */
10330 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10331 ut_params->cipher_xform.next = NULL;
10332 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10333 ut_params->cipher_xform.cipher.op = cipher_op;
10334 ut_params->cipher_xform.cipher.key.data = cipher_key;
10335 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10336 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10337 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10340 /* Create Crypto session*/
10341 ut_params->sess = rte_cryptodev_sym_session_create(
10342 ts_params->session_mpool);
10344 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10345 &ut_params->auth_xform,
10346 ts_params->session_priv_mpool);
10348 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10354 create_auth_operation(struct crypto_testsuite_params *ts_params,
10355 struct crypto_unittest_params *ut_params,
10356 const struct test_crypto_vector *reference,
10357 unsigned int auth_generate)
10359 /* Generate Crypto op data structure */
10360 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10361 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10362 TEST_ASSERT_NOT_NULL(ut_params->op,
10363 "Failed to allocate pktmbuf offload");
10365 /* Set crypto operation data parameters */
10366 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10368 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10370 /* set crypto operation source mbuf */
10371 sym_op->m_src = ut_params->ibuf;
10374 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10375 ut_params->ibuf, reference->digest.len);
10377 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10378 "no room to append auth tag");
10380 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10381 ut_params->ibuf, reference->plaintext.len);
10384 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10386 memcpy(sym_op->auth.digest.data,
10387 reference->digest.data,
10388 reference->digest.len);
10390 debug_hexdump(stdout, "digest:",
10391 sym_op->auth.digest.data,
10392 reference->digest.len);
10394 sym_op->auth.data.length = reference->plaintext.len;
10395 sym_op->auth.data.offset = 0;
10401 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10402 struct crypto_unittest_params *ut_params,
10403 const struct test_crypto_vector *reference,
10404 unsigned int auth_generate)
10406 /* Generate Crypto op data structure */
10407 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10408 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10409 TEST_ASSERT_NOT_NULL(ut_params->op,
10410 "Failed to allocate pktmbuf offload");
10412 /* Set crypto operation data parameters */
10413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10415 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10417 /* set crypto operation source mbuf */
10418 sym_op->m_src = ut_params->ibuf;
10421 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10422 ut_params->ibuf, reference->digest.len);
10424 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10425 "no room to append auth tag");
10427 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10428 ut_params->ibuf, reference->ciphertext.len);
10431 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10433 memcpy(sym_op->auth.digest.data,
10434 reference->digest.data,
10435 reference->digest.len);
10437 debug_hexdump(stdout, "digest:",
10438 sym_op->auth.digest.data,
10439 reference->digest.len);
10441 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10442 reference->iv.data, reference->iv.len);
10444 sym_op->cipher.data.length = 0;
10445 sym_op->cipher.data.offset = 0;
10447 sym_op->auth.data.length = reference->plaintext.len;
10448 sym_op->auth.data.offset = 0;
10454 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10455 struct crypto_unittest_params *ut_params,
10456 const struct test_crypto_vector *reference,
10457 unsigned int auth_generate)
10459 /* Generate Crypto op data structure */
10460 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10461 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10462 TEST_ASSERT_NOT_NULL(ut_params->op,
10463 "Failed to allocate pktmbuf offload");
10465 /* Set crypto operation data parameters */
10466 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10468 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10470 /* set crypto operation source mbuf */
10471 sym_op->m_src = ut_params->ibuf;
10474 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10475 ut_params->ibuf, reference->digest.len);
10477 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10478 "no room to append auth tag");
10480 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10481 ut_params->ibuf, reference->ciphertext.len);
10484 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10486 memcpy(sym_op->auth.digest.data,
10487 reference->digest.data,
10488 reference->digest.len);
10490 debug_hexdump(stdout, "digest:",
10491 sym_op->auth.digest.data,
10492 reference->digest.len);
10494 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10495 reference->iv.data, reference->iv.len);
10497 sym_op->cipher.data.length = reference->cipher_len;
10498 sym_op->cipher.data.offset = reference->cipher_offset;
10500 sym_op->auth.data.length = reference->plaintext.len;
10501 sym_op->auth.data.offset = reference->auth_offset;
10507 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10508 struct crypto_unittest_params *ut_params,
10509 const struct test_crypto_vector *reference)
10511 return create_auth_operation(ts_params, ut_params, reference, 0);
10515 create_auth_verify_GMAC_operation(
10516 struct crypto_testsuite_params *ts_params,
10517 struct crypto_unittest_params *ut_params,
10518 const struct test_crypto_vector *reference)
10520 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10524 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10525 struct crypto_unittest_params *ut_params,
10526 const struct test_crypto_vector *reference)
10528 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10532 test_authentication_verify_fail_when_data_corruption(
10533 struct crypto_testsuite_params *ts_params,
10534 struct crypto_unittest_params *ut_params,
10535 const struct test_crypto_vector *reference,
10536 unsigned int data_corrupted)
10540 uint8_t *plaintext;
10542 /* Verify the capabilities */
10543 struct rte_cryptodev_sym_capability_idx cap_idx;
10544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10545 cap_idx.algo.auth = reference->auth_algo;
10546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10550 /* Create session */
10551 retval = create_auth_session(ut_params,
10552 ts_params->valid_devs[0],
10554 RTE_CRYPTO_AUTH_OP_VERIFY);
10558 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10559 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10560 "Failed to allocate input buffer in mempool");
10562 /* clear mbuf payload */
10563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10564 rte_pktmbuf_tailroom(ut_params->ibuf));
10566 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10567 reference->plaintext.len);
10568 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10569 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10571 debug_hexdump(stdout, "plaintext:", plaintext,
10572 reference->plaintext.len);
10574 /* Create operation */
10575 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10580 if (data_corrupted)
10581 data_corruption(plaintext);
10583 tag_corruption(plaintext, reference->plaintext.len);
10585 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10586 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10588 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10589 RTE_CRYPTO_OP_STATUS_SUCCESS,
10590 "authentication not failed");
10592 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10594 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10601 test_authentication_verify_GMAC_fail_when_corruption(
10602 struct crypto_testsuite_params *ts_params,
10603 struct crypto_unittest_params *ut_params,
10604 const struct test_crypto_vector *reference,
10605 unsigned int data_corrupted)
10608 uint8_t *plaintext;
10610 /* Verify the capabilities */
10611 struct rte_cryptodev_sym_capability_idx cap_idx;
10612 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10613 cap_idx.algo.auth = reference->auth_algo;
10614 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10618 /* Create session */
10619 retval = create_auth_cipher_session(ut_params,
10620 ts_params->valid_devs[0],
10622 RTE_CRYPTO_AUTH_OP_VERIFY,
10623 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10628 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10629 "Failed to allocate input buffer in mempool");
10631 /* clear mbuf payload */
10632 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10633 rte_pktmbuf_tailroom(ut_params->ibuf));
10635 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10636 reference->plaintext.len);
10637 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10638 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10640 debug_hexdump(stdout, "plaintext:", plaintext,
10641 reference->plaintext.len);
10643 /* Create operation */
10644 retval = create_auth_verify_GMAC_operation(ts_params,
10651 if (data_corrupted)
10652 data_corruption(plaintext);
10654 tag_corruption(plaintext, reference->aad.len);
10656 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10657 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10659 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10660 RTE_CRYPTO_OP_STATUS_SUCCESS,
10661 "authentication not failed");
10663 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10665 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10672 test_authenticated_decryption_fail_when_corruption(
10673 struct crypto_testsuite_params *ts_params,
10674 struct crypto_unittest_params *ut_params,
10675 const struct test_crypto_vector *reference,
10676 unsigned int data_corrupted)
10680 uint8_t *ciphertext;
10682 /* Verify the capabilities */
10683 struct rte_cryptodev_sym_capability_idx cap_idx;
10684 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10685 cap_idx.algo.auth = reference->auth_algo;
10686 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10689 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10690 cap_idx.algo.cipher = reference->crypto_algo;
10691 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10695 /* Create session */
10696 retval = create_auth_cipher_session(ut_params,
10697 ts_params->valid_devs[0],
10699 RTE_CRYPTO_AUTH_OP_VERIFY,
10700 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10705 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10706 "Failed to allocate input buffer in mempool");
10708 /* clear mbuf payload */
10709 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10710 rte_pktmbuf_tailroom(ut_params->ibuf));
10712 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10713 reference->ciphertext.len);
10714 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10715 memcpy(ciphertext, reference->ciphertext.data,
10716 reference->ciphertext.len);
10718 /* Create operation */
10719 retval = create_cipher_auth_verify_operation(ts_params,
10726 if (data_corrupted)
10727 data_corruption(ciphertext);
10729 tag_corruption(ciphertext, reference->ciphertext.len);
10731 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10732 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10734 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10735 RTE_CRYPTO_OP_STATUS_SUCCESS,
10736 "authentication not failed");
10738 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10740 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10747 test_authenticated_encryt_with_esn(
10748 struct crypto_testsuite_params *ts_params,
10749 struct crypto_unittest_params *ut_params,
10750 const struct test_crypto_vector *reference)
10754 uint8_t *authciphertext, *plaintext, *auth_tag;
10755 uint16_t plaintext_pad_len;
10756 uint8_t cipher_key[reference->cipher_key.len + 1];
10757 uint8_t auth_key[reference->auth_key.len + 1];
10759 /* Verify the capabilities */
10760 struct rte_cryptodev_sym_capability_idx cap_idx;
10761 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10762 cap_idx.algo.auth = reference->auth_algo;
10763 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10767 cap_idx.algo.cipher = reference->crypto_algo;
10768 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10772 /* Create session */
10773 memcpy(cipher_key, reference->cipher_key.data,
10774 reference->cipher_key.len);
10775 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10777 /* Setup Cipher Parameters */
10778 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10779 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10780 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10781 ut_params->cipher_xform.cipher.key.data = cipher_key;
10782 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10783 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10784 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10786 ut_params->cipher_xform.next = &ut_params->auth_xform;
10788 /* Setup Authentication Parameters */
10789 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10790 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10791 ut_params->auth_xform.auth.algo = reference->auth_algo;
10792 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10793 ut_params->auth_xform.auth.key.data = auth_key;
10794 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10795 ut_params->auth_xform.next = NULL;
10797 /* Create Crypto session*/
10798 ut_params->sess = rte_cryptodev_sym_session_create(
10799 ts_params->session_mpool);
10801 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10803 &ut_params->cipher_xform,
10804 ts_params->session_priv_mpool);
10806 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10809 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10810 "Failed to allocate input buffer in mempool");
10812 /* clear mbuf payload */
10813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10814 rte_pktmbuf_tailroom(ut_params->ibuf));
10816 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10817 reference->plaintext.len);
10818 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10819 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10821 /* Create operation */
10822 retval = create_cipher_auth_operation(ts_params,
10829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10830 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10833 ut_params->op = process_crypto_request(
10834 ts_params->valid_devs[0], ut_params->op);
10836 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10838 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10839 "crypto op processing failed");
10841 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10843 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10844 ut_params->op->sym->auth.data.offset);
10845 auth_tag = authciphertext + plaintext_pad_len;
10846 debug_hexdump(stdout, "ciphertext:", authciphertext,
10847 reference->ciphertext.len);
10848 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10850 /* Validate obuf */
10851 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10853 reference->ciphertext.data,
10854 reference->ciphertext.len,
10855 "Ciphertext data not as expected");
10857 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10859 reference->digest.data,
10860 reference->digest.len,
10861 "Generated digest not as expected");
10863 return TEST_SUCCESS;
10868 test_authenticated_decrypt_with_esn(
10869 struct crypto_testsuite_params *ts_params,
10870 struct crypto_unittest_params *ut_params,
10871 const struct test_crypto_vector *reference)
10875 uint8_t *ciphertext;
10876 uint8_t cipher_key[reference->cipher_key.len + 1];
10877 uint8_t auth_key[reference->auth_key.len + 1];
10879 /* Verify the capabilities */
10880 struct rte_cryptodev_sym_capability_idx cap_idx;
10881 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10882 cap_idx.algo.auth = reference->auth_algo;
10883 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10886 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10887 cap_idx.algo.cipher = reference->crypto_algo;
10888 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10892 /* Create session */
10893 memcpy(cipher_key, reference->cipher_key.data,
10894 reference->cipher_key.len);
10895 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10897 /* Setup Authentication Parameters */
10898 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10899 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10900 ut_params->auth_xform.auth.algo = reference->auth_algo;
10901 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10902 ut_params->auth_xform.auth.key.data = auth_key;
10903 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10904 ut_params->auth_xform.next = &ut_params->cipher_xform;
10906 /* Setup Cipher Parameters */
10907 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10908 ut_params->cipher_xform.next = NULL;
10909 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10910 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10911 ut_params->cipher_xform.cipher.key.data = cipher_key;
10912 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10913 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10914 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10916 /* Create Crypto session*/
10917 ut_params->sess = rte_cryptodev_sym_session_create(
10918 ts_params->session_mpool);
10920 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10922 &ut_params->auth_xform,
10923 ts_params->session_priv_mpool);
10925 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10927 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10928 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10929 "Failed to allocate input buffer in mempool");
10931 /* clear mbuf payload */
10932 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10933 rte_pktmbuf_tailroom(ut_params->ibuf));
10935 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10936 reference->ciphertext.len);
10937 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10938 memcpy(ciphertext, reference->ciphertext.data,
10939 reference->ciphertext.len);
10941 /* Create operation */
10942 retval = create_cipher_auth_verify_operation(ts_params,
10949 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10950 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10956 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10957 TEST_ASSERT_EQUAL(ut_params->op->status,
10958 RTE_CRYPTO_OP_STATUS_SUCCESS,
10959 "crypto op processing passed");
10961 ut_params->obuf = ut_params->op->sym->m_src;
10962 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10968 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10969 const struct aead_test_data *tdata,
10970 void *digest_mem, uint64_t digest_phys)
10972 struct crypto_testsuite_params *ts_params = &testsuite_params;
10973 struct crypto_unittest_params *ut_params = &unittest_params;
10975 const unsigned int auth_tag_len = tdata->auth_tag.len;
10976 const unsigned int iv_len = tdata->iv.len;
10977 unsigned int aad_len = tdata->aad.len;
10978 unsigned int aad_len_pad = 0;
10980 /* Generate Crypto op data structure */
10981 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10982 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10983 TEST_ASSERT_NOT_NULL(ut_params->op,
10984 "Failed to allocate symmetric crypto operation struct");
10986 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10988 sym_op->aead.digest.data = digest_mem;
10990 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10991 "no room to append digest");
10993 sym_op->aead.digest.phys_addr = digest_phys;
10995 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10996 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10998 debug_hexdump(stdout, "digest:",
10999 sym_op->aead.digest.data,
11003 /* Append aad data */
11004 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11005 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11006 uint8_t *, IV_OFFSET);
11008 /* Copy IV 1 byte after the IV pointer, according to the API */
11009 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11011 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11013 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11014 ut_params->ibuf, aad_len);
11015 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11016 "no room to prepend aad");
11017 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11020 memset(sym_op->aead.aad.data, 0, aad_len);
11021 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11022 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11024 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11025 debug_hexdump(stdout, "aad:",
11026 sym_op->aead.aad.data, aad_len);
11028 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11029 uint8_t *, IV_OFFSET);
11031 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11033 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11035 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11036 ut_params->ibuf, aad_len_pad);
11037 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11038 "no room to prepend aad");
11039 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11042 memset(sym_op->aead.aad.data, 0, aad_len);
11043 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11045 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11046 debug_hexdump(stdout, "aad:",
11047 sym_op->aead.aad.data, aad_len);
11050 sym_op->aead.data.length = tdata->plaintext.len;
11051 sym_op->aead.data.offset = aad_len_pad;
11056 #define SGL_MAX_NO 16
11059 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11060 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11062 struct crypto_testsuite_params *ts_params = &testsuite_params;
11063 struct crypto_unittest_params *ut_params = &unittest_params;
11064 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11067 int to_trn_tbl[SGL_MAX_NO];
11069 unsigned int trn_data = 0;
11070 uint8_t *plaintext, *ciphertext, *auth_tag;
11071 struct rte_cryptodev_info dev_info;
11073 /* Verify the capabilities */
11074 struct rte_cryptodev_sym_capability_idx cap_idx;
11075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11076 cap_idx.algo.aead = tdata->algo;
11077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11081 /* OOP not supported with CPU crypto */
11082 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11085 /* Detailed check for the particular SGL support flag */
11086 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11088 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11089 if (sgl_in && (!(dev_info.feature_flags &
11090 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11093 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11094 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11095 tdata->plaintext.len;
11096 if (sgl_in && !sgl_out) {
11097 if (!(dev_info.feature_flags &
11098 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11100 } else if (!sgl_in && sgl_out) {
11101 if (!(dev_info.feature_flags &
11102 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11104 } else if (sgl_in && sgl_out) {
11105 if (!(dev_info.feature_flags &
11106 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11111 if (fragsz > tdata->plaintext.len)
11112 fragsz = tdata->plaintext.len;
11114 uint16_t plaintext_len = fragsz;
11115 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11117 if (fragsz_oop > tdata->plaintext.len)
11118 frag_size_oop = tdata->plaintext.len;
11121 void *digest_mem = NULL;
11123 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11125 if (tdata->plaintext.len % fragsz != 0) {
11126 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11129 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11134 * For out-op-place we need to alloc another mbuf
11137 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11138 rte_pktmbuf_append(ut_params->obuf,
11139 frag_size_oop + prepend_len);
11140 buf_oop = ut_params->obuf;
11143 /* Create AEAD session */
11144 retval = create_aead_session(ts_params->valid_devs[0],
11146 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11147 tdata->key.data, tdata->key.len,
11148 tdata->aad.len, tdata->auth_tag.len,
11153 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11155 /* clear mbuf payload */
11156 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11157 rte_pktmbuf_tailroom(ut_params->ibuf));
11159 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11162 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11164 trn_data += plaintext_len;
11166 buf = ut_params->ibuf;
11169 * Loop until no more fragments
11172 while (trn_data < tdata->plaintext.len) {
11174 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11175 (tdata->plaintext.len - trn_data) : fragsz;
11177 to_trn_tbl[ecx++] = to_trn;
11179 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11182 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11183 rte_pktmbuf_tailroom(buf));
11186 if (oop && !fragsz_oop) {
11187 buf_last_oop = buf_oop->next =
11188 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11189 buf_oop = buf_oop->next;
11190 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11191 0, rte_pktmbuf_tailroom(buf_oop));
11192 rte_pktmbuf_append(buf_oop, to_trn);
11195 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11198 memcpy(plaintext, tdata->plaintext.data + trn_data,
11200 trn_data += to_trn;
11201 if (trn_data == tdata->plaintext.len) {
11204 digest_mem = rte_pktmbuf_append(buf_oop,
11205 tdata->auth_tag.len);
11207 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11208 tdata->auth_tag.len);
11212 uint64_t digest_phys = 0;
11214 ut_params->ibuf->nb_segs = segs;
11217 if (fragsz_oop && oop) {
11221 if (frag_size_oop == tdata->plaintext.len) {
11222 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11223 tdata->auth_tag.len);
11225 digest_phys = rte_pktmbuf_iova_offset(
11227 tdata->plaintext.len + prepend_len);
11230 trn_data = frag_size_oop;
11231 while (trn_data < tdata->plaintext.len) {
11234 (tdata->plaintext.len - trn_data <
11236 (tdata->plaintext.len - trn_data) :
11239 to_trn_tbl[ecx++] = to_trn;
11241 buf_last_oop = buf_oop->next =
11242 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11243 buf_oop = buf_oop->next;
11244 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11245 0, rte_pktmbuf_tailroom(buf_oop));
11246 rte_pktmbuf_append(buf_oop, to_trn);
11248 trn_data += to_trn;
11250 if (trn_data == tdata->plaintext.len) {
11251 digest_mem = rte_pktmbuf_append(buf_oop,
11252 tdata->auth_tag.len);
11256 ut_params->obuf->nb_segs = segs;
11260 * Place digest at the end of the last buffer
11263 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11264 if (oop && buf_last_oop)
11265 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11267 if (!digest_mem && !oop) {
11268 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11269 + tdata->auth_tag.len);
11270 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11271 tdata->plaintext.len);
11274 /* Create AEAD operation */
11275 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11276 tdata, digest_mem, digest_phys);
11281 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11283 ut_params->op->sym->m_src = ut_params->ibuf;
11285 ut_params->op->sym->m_dst = ut_params->obuf;
11287 /* Process crypto operation */
11288 if (oop == IN_PLACE &&
11289 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11290 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11292 TEST_ASSERT_NOT_NULL(
11293 process_crypto_request(ts_params->valid_devs[0],
11294 ut_params->op), "failed to process sym crypto op");
11296 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11297 "crypto op processing failed");
11300 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11301 uint8_t *, prepend_len);
11303 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11304 uint8_t *, prepend_len);
11308 fragsz = fragsz_oop;
11310 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11312 tdata->ciphertext.data,
11314 "Ciphertext data not as expected");
11316 buf = ut_params->op->sym->m_src->next;
11318 buf = ut_params->op->sym->m_dst->next;
11320 unsigned int off = fragsz;
11324 ciphertext = rte_pktmbuf_mtod(buf,
11327 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11329 tdata->ciphertext.data + off,
11331 "Ciphertext data not as expected");
11333 off += to_trn_tbl[ecx++];
11337 auth_tag = digest_mem;
11338 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11340 tdata->auth_tag.data,
11341 tdata->auth_tag.len,
11342 "Generated auth tag not as expected");
11348 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11350 return test_authenticated_encryption_SGL(
11351 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11355 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11357 return test_authenticated_encryption_SGL(
11358 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11362 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11364 return test_authenticated_encryption_SGL(
11365 &gcm_test_case_8, OUT_OF_PLACE, 400,
11366 gcm_test_case_8.plaintext.len);
11370 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11372 /* This test is not for OPENSSL PMD */
11373 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11374 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11377 return test_authenticated_encryption_SGL(
11378 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11382 test_authentication_verify_fail_when_data_corrupted(
11383 struct crypto_testsuite_params *ts_params,
11384 struct crypto_unittest_params *ut_params,
11385 const struct test_crypto_vector *reference)
11387 return test_authentication_verify_fail_when_data_corruption(
11388 ts_params, ut_params, reference, 1);
11392 test_authentication_verify_fail_when_tag_corrupted(
11393 struct crypto_testsuite_params *ts_params,
11394 struct crypto_unittest_params *ut_params,
11395 const struct test_crypto_vector *reference)
11397 return test_authentication_verify_fail_when_data_corruption(
11398 ts_params, ut_params, reference, 0);
11402 test_authentication_verify_GMAC_fail_when_data_corrupted(
11403 struct crypto_testsuite_params *ts_params,
11404 struct crypto_unittest_params *ut_params,
11405 const struct test_crypto_vector *reference)
11407 return test_authentication_verify_GMAC_fail_when_corruption(
11408 ts_params, ut_params, reference, 1);
11412 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11413 struct crypto_testsuite_params *ts_params,
11414 struct crypto_unittest_params *ut_params,
11415 const struct test_crypto_vector *reference)
11417 return test_authentication_verify_GMAC_fail_when_corruption(
11418 ts_params, ut_params, reference, 0);
11422 test_authenticated_decryption_fail_when_data_corrupted(
11423 struct crypto_testsuite_params *ts_params,
11424 struct crypto_unittest_params *ut_params,
11425 const struct test_crypto_vector *reference)
11427 return test_authenticated_decryption_fail_when_corruption(
11428 ts_params, ut_params, reference, 1);
11432 test_authenticated_decryption_fail_when_tag_corrupted(
11433 struct crypto_testsuite_params *ts_params,
11434 struct crypto_unittest_params *ut_params,
11435 const struct test_crypto_vector *reference)
11437 return test_authenticated_decryption_fail_when_corruption(
11438 ts_params, ut_params, reference, 0);
11442 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11444 return test_authentication_verify_fail_when_data_corrupted(
11445 &testsuite_params, &unittest_params,
11446 &hmac_sha1_test_crypto_vector);
11450 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11452 return test_authentication_verify_fail_when_tag_corrupted(
11453 &testsuite_params, &unittest_params,
11454 &hmac_sha1_test_crypto_vector);
11458 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11460 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11461 &testsuite_params, &unittest_params,
11462 &aes128_gmac_test_vector);
11466 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11468 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11469 &testsuite_params, &unittest_params,
11470 &aes128_gmac_test_vector);
11474 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11476 return test_authenticated_decryption_fail_when_data_corrupted(
11479 &aes128cbc_hmac_sha1_test_vector);
11483 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11485 return test_authenticated_decryption_fail_when_tag_corrupted(
11488 &aes128cbc_hmac_sha1_test_vector);
11492 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11494 return test_authenticated_encryt_with_esn(
11497 &aes128cbc_hmac_sha1_aad_test_vector);
11501 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11503 return test_authenticated_decrypt_with_esn(
11506 &aes128cbc_hmac_sha1_aad_test_vector);
11509 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11511 /* global AESNI slave IDs for the scheduler test */
11512 uint8_t aesni_ids[2];
11515 test_scheduler_attach_slave_op(void)
11517 struct crypto_testsuite_params *ts_params = &testsuite_params;
11518 uint8_t sched_id = ts_params->valid_devs[0];
11519 uint32_t nb_devs, i, nb_devs_attached = 0;
11521 char vdev_name[32];
11523 /* create 2 AESNI_MB if necessary */
11524 nb_devs = rte_cryptodev_device_count_by_driver(
11525 rte_cryptodev_driver_id_get(
11526 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11528 for (i = nb_devs; i < 2; i++) {
11529 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11530 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11532 ret = rte_vdev_init(vdev_name, NULL);
11534 TEST_ASSERT(ret == 0,
11535 "Failed to create instance %u of"
11537 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11541 /* attach 2 AESNI_MB cdevs */
11542 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11544 struct rte_cryptodev_info info;
11545 unsigned int session_size;
11547 rte_cryptodev_info_get(i, &info);
11548 if (info.driver_id != rte_cryptodev_driver_id_get(
11549 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11552 session_size = rte_cryptodev_sym_get_private_session_size(i);
11554 * Create the session mempool again, since now there are new devices
11555 * to use the mempool.
11557 if (ts_params->session_mpool) {
11558 rte_mempool_free(ts_params->session_mpool);
11559 ts_params->session_mpool = NULL;
11561 if (ts_params->session_priv_mpool) {
11562 rte_mempool_free(ts_params->session_priv_mpool);
11563 ts_params->session_priv_mpool = NULL;
11566 if (info.sym.max_nb_sessions != 0 &&
11567 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11568 RTE_LOG(ERR, USER1,
11569 "Device does not support "
11570 "at least %u sessions\n",
11572 return TEST_FAILED;
11575 * Create mempool with maximum number of sessions,
11576 * to include the session headers
11578 if (ts_params->session_mpool == NULL) {
11579 ts_params->session_mpool =
11580 rte_cryptodev_sym_session_pool_create(
11582 MAX_NB_SESSIONS, 0, 0, 0,
11584 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11585 "session mempool allocation failed");
11589 * Create mempool with maximum number of sessions,
11590 * to include device specific session private data
11592 if (ts_params->session_priv_mpool == NULL) {
11593 ts_params->session_priv_mpool = rte_mempool_create(
11594 "test_sess_mp_priv",
11597 0, 0, NULL, NULL, NULL,
11598 NULL, SOCKET_ID_ANY,
11601 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11602 "session mempool allocation failed");
11605 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11606 ts_params->qp_conf.mp_session_private =
11607 ts_params->session_priv_mpool;
11609 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11612 TEST_ASSERT(ret == 0,
11613 "Failed to attach device %u of pmd : %s", i,
11614 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11616 aesni_ids[nb_devs_attached] = (uint8_t)i;
11618 nb_devs_attached++;
11625 test_scheduler_detach_slave_op(void)
11627 struct crypto_testsuite_params *ts_params = &testsuite_params;
11628 uint8_t sched_id = ts_params->valid_devs[0];
11632 for (i = 0; i < 2; i++) {
11633 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11635 TEST_ASSERT(ret == 0,
11636 "Failed to detach device %u", aesni_ids[i]);
11643 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11645 struct crypto_testsuite_params *ts_params = &testsuite_params;
11646 uint8_t sched_id = ts_params->valid_devs[0];
11648 return rte_cryptodev_scheduler_mode_set(sched_id,
11653 test_scheduler_mode_roundrobin_op(void)
11655 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11656 0, "Failed to set roundrobin mode");
11662 test_scheduler_mode_multicore_op(void)
11664 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11665 0, "Failed to set multicore mode");
11671 test_scheduler_mode_failover_op(void)
11673 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11674 0, "Failed to set failover mode");
11680 test_scheduler_mode_pkt_size_distr_op(void)
11682 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11683 0, "Failed to set pktsize mode");
11688 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11689 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11690 .setup = testsuite_setup,
11691 .teardown = testsuite_teardown,
11692 .unit_test_cases = {
11694 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11695 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11696 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11697 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11698 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11699 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11702 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11703 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11704 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11705 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11706 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11707 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11710 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11711 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11712 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11713 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11714 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11715 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11718 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11719 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11720 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11721 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11722 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11723 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11725 TEST_CASES_END() /**< NULL terminate unit test array */
11729 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11731 static struct unit_test_suite cryptodev_testsuite = {
11732 .suite_name = "Crypto Unit Test Suite",
11733 .setup = testsuite_setup,
11734 .teardown = testsuite_teardown,
11735 .unit_test_cases = {
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_device_configure_invalid_dev_id),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_device_configure_invalid_queue_pair_ids),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_queue_pair_descriptor_setup),
11743 TEST_CASE_ST(ut_setup, ut_teardown,
11744 test_multi_session),
11745 TEST_CASE_ST(ut_setup, ut_teardown,
11746 test_multi_session_random_usage),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_null_invalid_operation),
11750 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11752 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11753 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11754 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11755 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11757 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11758 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11759 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11760 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11762 /** AES CCM Authenticated Encryption 128 bits key */
11763 TEST_CASE_ST(ut_setup, ut_teardown,
11764 test_AES_CCM_authenticated_encryption_test_case_128_1),
11765 TEST_CASE_ST(ut_setup, ut_teardown,
11766 test_AES_CCM_authenticated_encryption_test_case_128_2),
11767 TEST_CASE_ST(ut_setup, ut_teardown,
11768 test_AES_CCM_authenticated_encryption_test_case_128_3),
11770 /** AES CCM Authenticated Decryption 128 bits key*/
11771 TEST_CASE_ST(ut_setup, ut_teardown,
11772 test_AES_CCM_authenticated_decryption_test_case_128_1),
11773 TEST_CASE_ST(ut_setup, ut_teardown,
11774 test_AES_CCM_authenticated_decryption_test_case_128_2),
11775 TEST_CASE_ST(ut_setup, ut_teardown,
11776 test_AES_CCM_authenticated_decryption_test_case_128_3),
11778 /** AES CCM Authenticated Encryption 192 bits key */
11779 TEST_CASE_ST(ut_setup, ut_teardown,
11780 test_AES_CCM_authenticated_encryption_test_case_192_1),
11781 TEST_CASE_ST(ut_setup, ut_teardown,
11782 test_AES_CCM_authenticated_encryption_test_case_192_2),
11783 TEST_CASE_ST(ut_setup, ut_teardown,
11784 test_AES_CCM_authenticated_encryption_test_case_192_3),
11786 /** AES CCM Authenticated Decryption 192 bits key*/
11787 TEST_CASE_ST(ut_setup, ut_teardown,
11788 test_AES_CCM_authenticated_decryption_test_case_192_1),
11789 TEST_CASE_ST(ut_setup, ut_teardown,
11790 test_AES_CCM_authenticated_decryption_test_case_192_2),
11791 TEST_CASE_ST(ut_setup, ut_teardown,
11792 test_AES_CCM_authenticated_decryption_test_case_192_3),
11794 /** AES CCM Authenticated Encryption 256 bits key */
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_AES_CCM_authenticated_encryption_test_case_256_1),
11797 TEST_CASE_ST(ut_setup, ut_teardown,
11798 test_AES_CCM_authenticated_encryption_test_case_256_2),
11799 TEST_CASE_ST(ut_setup, ut_teardown,
11800 test_AES_CCM_authenticated_encryption_test_case_256_3),
11802 /** AES CCM Authenticated Decryption 256 bits key*/
11803 TEST_CASE_ST(ut_setup, ut_teardown,
11804 test_AES_CCM_authenticated_decryption_test_case_256_1),
11805 TEST_CASE_ST(ut_setup, ut_teardown,
11806 test_AES_CCM_authenticated_decryption_test_case_256_2),
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_AES_CCM_authenticated_decryption_test_case_256_3),
11810 /** AES GCM Authenticated Encryption */
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_AES_GCM_authenticated_encryption_test_case_1),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_GCM_authenticated_encryption_test_case_2),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_AES_GCM_authenticated_encryption_test_case_3),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_GCM_authenticated_encryption_test_case_4),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_GCM_authenticated_encryption_test_case_5),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_GCM_authenticated_encryption_test_case_6),
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_GCM_authenticated_encryption_test_case_7),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_GCM_authenticated_encryption_test_case_8),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11838 /** AES GCM Authenticated Decryption */
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_GCM_authenticated_decryption_test_case_1),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_GCM_authenticated_decryption_test_case_2),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_GCM_authenticated_decryption_test_case_3),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_GCM_authenticated_decryption_test_case_4),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_GCM_authenticated_decryption_test_case_5),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_GCM_authenticated_decryption_test_case_6),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_GCM_authenticated_decryption_test_case_7),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_GCM_authenticated_decryption_test_case_8),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11858 /** AES GCM Authenticated Encryption 192 bits key */
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_auth_encryption_test_case_192_1),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_auth_encryption_test_case_192_2),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_auth_encryption_test_case_192_3),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_auth_encryption_test_case_192_4),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_auth_encryption_test_case_192_5),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_auth_encryption_test_case_192_6),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_auth_encryption_test_case_192_7),
11874 /** AES GCM Authenticated Decryption 192 bits key */
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_auth_decryption_test_case_192_1),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_auth_decryption_test_case_192_2),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_auth_decryption_test_case_192_3),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_auth_decryption_test_case_192_4),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_auth_decryption_test_case_192_5),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_auth_decryption_test_case_192_6),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_auth_decryption_test_case_192_7),
11890 /** AES GCM Authenticated Encryption 256 bits key */
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_auth_encryption_test_case_256_1),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_auth_encryption_test_case_256_2),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_auth_encryption_test_case_256_3),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_auth_encryption_test_case_256_4),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_auth_encryption_test_case_256_5),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_auth_encryption_test_case_256_6),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_auth_encryption_test_case_256_7),
11906 /** AES GCM Authenticated Decryption 256 bits key */
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_decryption_test_case_256_1),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_decryption_test_case_256_2),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_decryption_test_case_256_3),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_decryption_test_case_256_4),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_decryption_test_case_256_5),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_decryption_test_case_256_6),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_auth_decryption_test_case_256_7),
11922 /** AES GCM Authenticated Encryption big aad size */
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_encryption_test_case_aad_1),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_encryption_test_case_aad_2),
11928 /** AES GCM Authenticated Decryption big aad size */
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_decryption_test_case_aad_1),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_decryption_test_case_aad_2),
11934 /** Out of place tests */
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11940 /** Session-less tests */
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11946 /** AES GMAC Authentication */
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GMAC_authentication_test_case_1),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GMAC_authentication_verify_test_case_1),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GMAC_authentication_test_case_2),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GMAC_authentication_verify_test_case_2),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GMAC_authentication_test_case_3),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GMAC_authentication_verify_test_case_3),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GMAC_authentication_test_case_4),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GMAC_authentication_verify_test_case_4),
11964 /** SNOW 3G encrypt only (UEA2) */
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_snow3g_encryption_test_case_1),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_snow3g_encryption_test_case_2),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_snow3g_encryption_test_case_3),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_snow3g_encryption_test_case_4),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_snow3g_encryption_test_case_5),
11976 TEST_CASE_ST(ut_setup, ut_teardown,
11977 test_snow3g_encryption_test_case_1_oop),
11978 TEST_CASE_ST(ut_setup, ut_teardown,
11979 test_snow3g_encryption_test_case_1_oop_sgl),
11980 TEST_CASE_ST(ut_setup, ut_teardown,
11981 test_snow3g_encryption_test_case_1_offset_oop),
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_snow3g_decryption_test_case_1_oop),
11985 /** SNOW 3G generate auth, then encrypt (UEA2) */
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_snow3g_auth_cipher_test_case_1),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_snow3g_auth_cipher_test_case_2),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_snow3g_auth_cipher_test_case_2_oop),
11992 TEST_CASE_ST(ut_setup, ut_teardown,
11993 test_snow3g_auth_cipher_part_digest_enc),
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_snow3g_auth_cipher_part_digest_enc_oop),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_snow3g_auth_cipher_test_case_3_sgl),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12000 TEST_CASE_ST(ut_setup, ut_teardown,
12001 test_snow3g_auth_cipher_part_digest_enc_sgl),
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12005 /** SNOW 3G decrypt (UEA2), then verify auth */
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_snow3g_auth_cipher_verify_test_case_1),
12008 TEST_CASE_ST(ut_setup, ut_teardown,
12009 test_snow3g_auth_cipher_verify_test_case_2),
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_snow3g_auth_cipher_verify_test_case_2_oop),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_snow3g_auth_cipher_verify_part_digest_enc),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12025 /** SNOW 3G decrypt only (UEA2) */
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_decryption_test_case_1),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_decryption_test_case_2),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_snow3g_decryption_test_case_3),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_decryption_test_case_4),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_snow3g_decryption_test_case_5),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_decryption_with_digest_test_case_1),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_hash_generate_test_case_1),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_hash_generate_test_case_2),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_hash_generate_test_case_3),
12044 /* Tests with buffers which length is not byte-aligned */
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_snow3g_hash_generate_test_case_4),
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_snow3g_hash_generate_test_case_5),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_snow3g_hash_generate_test_case_6),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_snow3g_hash_verify_test_case_1),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_snow3g_hash_verify_test_case_2),
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_snow3g_hash_verify_test_case_3),
12057 /* Tests with buffers which length is not byte-aligned */
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_hash_verify_test_case_4),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_hash_verify_test_case_5),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_hash_verify_test_case_6),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_cipher_auth_test_case_1),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_auth_cipher_with_digest_test_case_1),
12069 /** ZUC encrypt only (EEA3) */
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_zuc_encryption_test_case_1),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_zuc_encryption_test_case_2),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_zuc_encryption_test_case_3),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_zuc_encryption_test_case_4),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_zuc_encryption_test_case_5),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 test_zuc_encryption_test_case_6_sgl),
12083 /** ZUC authenticate (EIA3) */
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_zuc_hash_generate_test_case_1),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_zuc_hash_generate_test_case_2),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_zuc_hash_generate_test_case_3),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_zuc_hash_generate_test_case_4),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_zuc_hash_generate_test_case_5),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_zuc_hash_generate_test_case_6),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_zuc_hash_generate_test_case_7),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_zuc_hash_generate_test_case_8),
12101 /** ZUC alg-chain (EEA3/EIA3) */
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_zuc_cipher_auth_test_case_1),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_zuc_cipher_auth_test_case_2),
12107 /** ZUC generate auth, then encrypt (EEA3) */
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_zuc_auth_cipher_test_case_1),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_zuc_auth_cipher_test_case_1_oop),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_zuc_auth_cipher_test_case_1_sgl),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_zuc_auth_cipher_test_case_1_oop_sgl),
12117 /** ZUC decrypt (EEA3), then verify auth */
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_zuc_auth_cipher_verify_test_case_1),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_auth_cipher_verify_test_case_1_oop),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_auth_cipher_verify_test_case_1_sgl),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12127 /** HMAC_MD5 Authentication */
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_MD5_HMAC_generate_case_1),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_MD5_HMAC_verify_case_1),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_MD5_HMAC_generate_case_2),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_MD5_HMAC_verify_case_2),
12137 /** KASUMI hash only (UIA1) */
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_kasumi_hash_generate_test_case_1),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_kasumi_hash_generate_test_case_2),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_kasumi_hash_generate_test_case_3),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_kasumi_hash_generate_test_case_4),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_kasumi_hash_generate_test_case_5),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_kasumi_hash_generate_test_case_6),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_kasumi_hash_verify_test_case_1),
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_kasumi_hash_verify_test_case_2),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_kasumi_hash_verify_test_case_3),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_kasumi_hash_verify_test_case_4),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_kasumi_hash_verify_test_case_5),
12162 /** KASUMI encrypt only (UEA1) */
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_kasumi_encryption_test_case_1),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_kasumi_encryption_test_case_1_sgl),
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_kasumi_encryption_test_case_1_oop),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_kasumi_encryption_test_case_1_oop_sgl),
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 test_kasumi_encryption_test_case_2),
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 test_kasumi_encryption_test_case_3),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_kasumi_encryption_test_case_4),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_kasumi_encryption_test_case_5),
12180 /** KASUMI decrypt only (UEA1) */
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_kasumi_decryption_test_case_1),
12183 TEST_CASE_ST(ut_setup, ut_teardown,
12184 test_kasumi_decryption_test_case_2),
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_kasumi_decryption_test_case_3),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_decryption_test_case_4),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_decryption_test_case_5),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_kasumi_decryption_test_case_1_oop),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_kasumi_cipher_auth_test_case_1),
12197 /** KASUMI generate auth, then encrypt (F8) */
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_kasumi_auth_cipher_test_case_1),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_kasumi_auth_cipher_test_case_2),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_kasumi_auth_cipher_test_case_2_oop),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_kasumi_auth_cipher_test_case_2_sgl),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12209 /** KASUMI decrypt (F8), then verify auth */
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_kasumi_auth_cipher_verify_test_case_1),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_kasumi_auth_cipher_verify_test_case_2),
12214 TEST_CASE_ST(ut_setup, ut_teardown,
12215 test_kasumi_auth_cipher_verify_test_case_2_oop),
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12221 /** ESN Testcase */
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12227 /** Negative tests */
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12230 TEST_CASE_ST(ut_setup, ut_teardown,
12231 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 authentication_verify_AES128_GMAC_fail_data_corrupt),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12265 /** Mixed CIPHER + HASH algorithms */
12266 /** AUTH AES CMAC + CIPHER AES CTR */
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12284 /** AUTH ZUC + CIPHER SNOW3G */
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_auth_zuc_cipher_snow_test_case_1),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_verify_auth_zuc_cipher_snow_test_case_1),
12289 /** AUTH AES CMAC + CIPHER SNOW3G */
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_auth_aes_cmac_cipher_snow_test_case_1),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12294 /** AUTH ZUC + CIPHER AES CTR */
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_auth_zuc_cipher_aes_ctr_test_case_1),
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12299 /** AUTH SNOW3G + CIPHER AES CTR */
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_auth_snow_cipher_aes_ctr_test_case_1),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12304 /** AUTH SNOW3G + CIPHER ZUC */
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_auth_snow_cipher_zuc_test_case_1),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_verify_auth_snow_cipher_zuc_test_case_1),
12309 /** AUTH AES CMAC + CIPHER ZUC */
12310 TEST_CASE_ST(ut_setup, ut_teardown,
12311 test_auth_aes_cmac_cipher_zuc_test_case_1),
12312 TEST_CASE_ST(ut_setup, ut_teardown,
12313 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12315 /** AUTH NULL + CIPHER SNOW3G */
12316 TEST_CASE_ST(ut_setup, ut_teardown,
12317 test_auth_null_cipher_snow_test_case_1),
12318 TEST_CASE_ST(ut_setup, ut_teardown,
12319 test_verify_auth_null_cipher_snow_test_case_1),
12320 /** AUTH NULL + CIPHER ZUC */
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_auth_null_cipher_zuc_test_case_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_verify_auth_null_cipher_zuc_test_case_1),
12325 /** AUTH SNOW3G + CIPHER NULL */
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_auth_snow_cipher_null_test_case_1),
12328 TEST_CASE_ST(ut_setup, ut_teardown,
12329 test_verify_auth_snow_cipher_null_test_case_1),
12330 /** AUTH ZUC + CIPHER NULL */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_auth_zuc_cipher_null_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_verify_auth_zuc_cipher_null_test_case_1),
12335 /** AUTH NULL + CIPHER AES CTR */
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_auth_null_cipher_aes_ctr_test_case_1),
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12340 /** AUTH AES CMAC + CIPHER NULL */
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_auth_aes_cmac_cipher_null_test_case_1),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12346 TEST_CASES_END() /**< NULL terminate unit test array */
12350 static struct unit_test_suite cryptodev_virtio_testsuite = {
12351 .suite_name = "Crypto VIRTIO Unit Test Suite",
12352 .setup = testsuite_setup,
12353 .teardown = testsuite_teardown,
12354 .unit_test_cases = {
12355 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12357 TEST_CASES_END() /**< NULL terminate unit test array */
12361 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12362 .suite_name = "Crypto CAAM JR Unit Test Suite",
12363 .setup = testsuite_setup,
12364 .teardown = testsuite_teardown,
12365 .unit_test_cases = {
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_device_configure_invalid_dev_id),
12368 TEST_CASE_ST(ut_setup, ut_teardown,
12369 test_multi_session),
12371 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12372 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12373 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12374 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12375 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12377 TEST_CASES_END() /**< NULL terminate unit test array */
12381 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12382 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12383 .setup = testsuite_setup,
12384 .teardown = testsuite_teardown,
12385 .unit_test_cases = {
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_device_configure_invalid_dev_id),
12388 TEST_CASE_ST(ut_setup, ut_teardown,
12389 test_multi_session),
12391 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12392 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12393 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12394 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12395 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12397 #ifdef RTE_LIBRTE_SECURITY
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_PDCP_PROTO_cplane_encap_all),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_PDCP_PROTO_cplane_decap_all),
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_PDCP_PROTO_uplane_encap_all),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_PDCP_PROTO_uplane_decap_all),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_PDCP_PROTO_SGL_in_place_32B),
12412 TEST_CASE_ST(ut_setup, ut_teardown,
12413 test_PDCP_PROTO_SGL_oop_32B_128B),
12414 TEST_CASE_ST(ut_setup, ut_teardown,
12415 test_PDCP_PROTO_SGL_oop_32B_40B),
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_PDCP_PROTO_SGL_oop_128B_32B),
12419 /** AES GCM Authenticated Encryption */
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12426 TEST_CASE_ST(ut_setup, ut_teardown,
12427 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_AES_GCM_authenticated_encryption_test_case_1),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 test_AES_GCM_authenticated_encryption_test_case_2),
12432 TEST_CASE_ST(ut_setup, ut_teardown,
12433 test_AES_GCM_authenticated_encryption_test_case_3),
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_AES_GCM_authenticated_encryption_test_case_4),
12436 TEST_CASE_ST(ut_setup, ut_teardown,
12437 test_AES_GCM_authenticated_encryption_test_case_5),
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_AES_GCM_authenticated_encryption_test_case_6),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_AES_GCM_authenticated_encryption_test_case_7),
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_AES_GCM_authenticated_encryption_test_case_8),
12445 /** AES GCM Authenticated Decryption */
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_AES_GCM_authenticated_decryption_test_case_1),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_AES_GCM_authenticated_decryption_test_case_2),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_AES_GCM_authenticated_decryption_test_case_3),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_AES_GCM_authenticated_decryption_test_case_4),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_AES_GCM_authenticated_decryption_test_case_5),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_AES_GCM_authenticated_decryption_test_case_6),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_AES_GCM_authenticated_decryption_test_case_7),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_authenticated_decryption_test_case_8),
12463 /** AES GCM Authenticated Encryption 192 bits key */
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_AES_GCM_auth_encryption_test_case_192_1),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_AES_GCM_auth_encryption_test_case_192_2),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_AES_GCM_auth_encryption_test_case_192_3),
12470 TEST_CASE_ST(ut_setup, ut_teardown,
12471 test_AES_GCM_auth_encryption_test_case_192_4),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_AES_GCM_auth_encryption_test_case_192_5),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_AES_GCM_auth_encryption_test_case_192_6),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_AES_GCM_auth_encryption_test_case_192_7),
12479 /** AES GCM Authenticated Decryption 192 bits key */
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_AES_GCM_auth_decryption_test_case_192_1),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_AES_GCM_auth_decryption_test_case_192_2),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_AES_GCM_auth_decryption_test_case_192_3),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_GCM_auth_decryption_test_case_192_4),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_AES_GCM_auth_decryption_test_case_192_5),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_AES_GCM_auth_decryption_test_case_192_6),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_AES_GCM_auth_decryption_test_case_192_7),
12495 /** AES GCM Authenticated Encryption 256 bits key */
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_AES_GCM_auth_encryption_test_case_256_1),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_AES_GCM_auth_encryption_test_case_256_2),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_auth_encryption_test_case_256_3),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_auth_encryption_test_case_256_4),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_auth_encryption_test_case_256_5),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_auth_encryption_test_case_256_6),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_auth_encryption_test_case_256_7),
12511 /** AES GCM Authenticated Decryption 256 bits key */
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_auth_decryption_test_case_256_1),
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_AES_GCM_auth_decryption_test_case_256_2),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_auth_decryption_test_case_256_3),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_auth_decryption_test_case_256_4),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_auth_decryption_test_case_256_5),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_auth_decryption_test_case_256_6),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_auth_decryption_test_case_256_7),
12527 /** Out of place tests */
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12533 /** SNOW 3G encrypt only (UEA2) */
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_snow3g_encryption_test_case_1),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_snow3g_encryption_test_case_2),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_snow3g_encryption_test_case_3),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_snow3g_encryption_test_case_4),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_snow3g_encryption_test_case_5),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_snow3g_encryption_test_case_1_oop),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_snow3g_encryption_test_case_1_oop_sgl),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_snow3g_decryption_test_case_1_oop),
12552 /** SNOW 3G decrypt only (UEA2) */
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_snow3g_decryption_test_case_1),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_snow3g_decryption_test_case_2),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_snow3g_decryption_test_case_3),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_snow3g_decryption_test_case_4),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_snow3g_decryption_test_case_5),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_snow3g_hash_generate_test_case_1),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_snow3g_hash_generate_test_case_2),
12568 TEST_CASE_ST(ut_setup, ut_teardown,
12569 test_snow3g_hash_generate_test_case_3),
12570 TEST_CASE_ST(ut_setup, ut_teardown,
12571 test_snow3g_hash_verify_test_case_1),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_hash_verify_test_case_2),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_hash_verify_test_case_3),
12577 /** ZUC encrypt only (EEA3) */
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_zuc_encryption_test_case_1),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_zuc_encryption_test_case_2),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_zuc_encryption_test_case_3),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_zuc_encryption_test_case_4),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_zuc_encryption_test_case_5),
12589 /** ZUC authenticate (EIA3) */
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_zuc_hash_generate_test_case_6),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_zuc_hash_generate_test_case_7),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_zuc_hash_generate_test_case_8),
12597 /** Negative tests */
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12637 TEST_CASES_END() /**< NULL terminate unit test array */
12641 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12642 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12643 .setup = testsuite_setup,
12644 .teardown = testsuite_teardown,
12645 .unit_test_cases = {
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_device_configure_invalid_dev_id),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_multi_session),
12650 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12651 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12652 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12653 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12654 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12656 #ifdef RTE_LIBRTE_SECURITY
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_PDCP_PROTO_cplane_encap_all),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 test_PDCP_PROTO_cplane_decap_all),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_PDCP_PROTO_uplane_encap_all),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_PDCP_PROTO_uplane_decap_all),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_PDCP_PROTO_SGL_in_place_32B),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_PDCP_PROTO_SGL_oop_32B_128B),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_PDCP_PROTO_SGL_oop_32B_40B),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_PDCP_PROTO_SGL_oop_128B_32B),
12678 /** AES GCM Authenticated Encryption */
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_AES_GCM_authenticated_encryption_test_case_1),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_AES_GCM_authenticated_encryption_test_case_2),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_AES_GCM_authenticated_encryption_test_case_3),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_AES_GCM_authenticated_encryption_test_case_4),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_AES_GCM_authenticated_encryption_test_case_5),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_AES_GCM_authenticated_encryption_test_case_6),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_AES_GCM_authenticated_encryption_test_case_7),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_AES_GCM_authenticated_encryption_test_case_8),
12704 /** AES GCM Authenticated Decryption */
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_AES_GCM_authenticated_decryption_test_case_1),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_AES_GCM_authenticated_decryption_test_case_2),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_authenticated_decryption_test_case_3),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_AES_GCM_authenticated_decryption_test_case_4),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_authenticated_decryption_test_case_5),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_authenticated_decryption_test_case_6),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_authenticated_decryption_test_case_7),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_authenticated_decryption_test_case_8),
12722 /** AES GCM Authenticated Encryption 192 bits key */
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_auth_encryption_test_case_192_1),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_auth_encryption_test_case_192_2),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_auth_encryption_test_case_192_3),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_auth_encryption_test_case_192_4),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_auth_encryption_test_case_192_5),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_auth_encryption_test_case_192_6),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_auth_encryption_test_case_192_7),
12738 /** AES GCM Authenticated Decryption 192 bits key */
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_auth_decryption_test_case_192_1),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_auth_decryption_test_case_192_2),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_auth_decryption_test_case_192_3),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_auth_decryption_test_case_192_4),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_auth_decryption_test_case_192_5),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_auth_decryption_test_case_192_6),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_auth_decryption_test_case_192_7),
12754 /** AES GCM Authenticated Encryption 256 bits key */
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_auth_encryption_test_case_256_1),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_encryption_test_case_256_2),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_auth_encryption_test_case_256_3),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_256_4),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_256_5),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_256_6),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_auth_encryption_test_case_256_7),
12770 /** AES GCM Authenticated Decryption 256 bits key */
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_auth_decryption_test_case_256_1),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_auth_decryption_test_case_256_2),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_auth_decryption_test_case_256_3),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_256_4),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_256_5),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_256_6),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_auth_decryption_test_case_256_7),
12786 /** Out of place tests */
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12792 /** SNOW 3G encrypt only (UEA2) */
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_snow3g_encryption_test_case_1),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_snow3g_encryption_test_case_2),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_snow3g_encryption_test_case_3),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_snow3g_encryption_test_case_4),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_snow3g_encryption_test_case_5),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_snow3g_encryption_test_case_1_oop),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_snow3g_encryption_test_case_1_oop_sgl),
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_snow3g_decryption_test_case_1_oop),
12811 /** SNOW 3G decrypt only (UEA2) */
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_snow3g_decryption_test_case_1),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_snow3g_decryption_test_case_2),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_snow3g_decryption_test_case_3),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_snow3g_decryption_test_case_4),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_snow3g_decryption_test_case_5),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_snow3g_hash_generate_test_case_1),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_snow3g_hash_generate_test_case_2),
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_snow3g_hash_generate_test_case_3),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_hash_verify_test_case_1),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_snow3g_hash_verify_test_case_2),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_snow3g_hash_verify_test_case_3),
12836 /** ZUC encrypt only (EEA3) */
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_zuc_encryption_test_case_1),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_zuc_encryption_test_case_2),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_zuc_encryption_test_case_3),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_zuc_encryption_test_case_4),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_zuc_encryption_test_case_5),
12848 /** ZUC authenticate (EIA3) */
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_zuc_hash_generate_test_case_6),
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_zuc_hash_generate_test_case_7),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_zuc_hash_generate_test_case_8),
12856 /** HMAC_MD5 Authentication */
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_MD5_HMAC_generate_case_1),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_MD5_HMAC_verify_case_1),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_MD5_HMAC_generate_case_2),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_MD5_HMAC_verify_case_2),
12866 /** Negative tests */
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12895 TEST_CASE_ST(ut_setup, ut_teardown,
12896 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12907 TEST_CASES_END() /**< NULL terminate unit test array */
12911 static struct unit_test_suite cryptodev_armv8_testsuite = {
12912 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12913 .setup = testsuite_setup,
12914 .teardown = testsuite_teardown,
12915 .unit_test_cases = {
12916 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12918 /** Negative tests */
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12924 TEST_CASES_END() /**< NULL terminate unit test array */
12928 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12929 .suite_name = "Crypto Device Marvell Component Test Suite",
12930 .setup = testsuite_setup,
12931 .teardown = testsuite_teardown,
12932 .unit_test_cases = {
12933 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_multi_session_random_usage),
12936 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12937 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12938 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12939 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12940 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12942 /** Negative tests */
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12945 TEST_CASE_ST(ut_setup, ut_teardown,
12946 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12952 TEST_CASES_END() /**< NULL terminate unit test array */
12956 static struct unit_test_suite cryptodev_ccp_testsuite = {
12957 .suite_name = "Crypto Device CCP Unit Test Suite",
12958 .setup = testsuite_setup,
12959 .teardown = testsuite_teardown,
12960 .unit_test_cases = {
12961 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_multi_session_random_usage),
12964 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12965 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12966 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12967 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12968 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12970 /** Negative tests */
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12980 TEST_CASES_END() /**< NULL terminate unit test array */
12984 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12985 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12986 .setup = testsuite_setup,
12987 .teardown = testsuite_teardown,
12988 .unit_test_cases = {
12989 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12990 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12991 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12992 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12993 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12995 /** AES GCM Authenticated Encryption */
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_AES_GCM_authenticated_encryption_test_case_1),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_AES_GCM_authenticated_encryption_test_case_2),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_AES_GCM_authenticated_encryption_test_case_3),
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_AES_GCM_authenticated_encryption_test_case_4),
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_AES_GCM_authenticated_encryption_test_case_5),
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_AES_GCM_authenticated_encryption_test_case_6),
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_AES_GCM_authenticated_encryption_test_case_7),
13011 /** AES GCM Authenticated Decryption */
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_AES_GCM_authenticated_decryption_test_case_1),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_AES_GCM_authenticated_decryption_test_case_2),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_AES_GCM_authenticated_decryption_test_case_3),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_AES_GCM_authenticated_decryption_test_case_4),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_AES_GCM_authenticated_decryption_test_case_5),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_AES_GCM_authenticated_decryption_test_case_6),
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_AES_GCM_authenticated_decryption_test_case_7),
13026 /** AES GMAC Authentication */
13027 TEST_CASE_ST(ut_setup, ut_teardown,
13028 test_AES_GMAC_authentication_test_case_1),
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_AES_GMAC_authentication_verify_test_case_1),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_AES_GMAC_authentication_test_case_2),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_AES_GMAC_authentication_verify_test_case_2),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_AES_GMAC_authentication_test_case_3),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_AES_GMAC_authentication_verify_test_case_3),
13040 /** SNOW 3G encrypt only (UEA2) */
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_snow3g_encryption_test_case_1),
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 test_snow3g_encryption_test_case_2),
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 test_snow3g_encryption_test_case_3),
13047 TEST_CASE_ST(ut_setup, ut_teardown,
13048 test_snow3g_encryption_test_case_4),
13049 TEST_CASE_ST(ut_setup, ut_teardown,
13050 test_snow3g_encryption_test_case_5),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_snow3g_encryption_test_case_1_oop),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_snow3g_decryption_test_case_1_oop),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_snow3g_encryption_test_case_1_oop_sgl),
13059 /** SNOW 3G decrypt only (UEA2) */
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_snow3g_decryption_test_case_1),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_snow3g_decryption_test_case_2),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_snow3g_decryption_test_case_3),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_snow3g_decryption_test_case_4),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_snow3g_decryption_test_case_5),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_snow3g_hash_generate_test_case_1),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_snow3g_hash_generate_test_case_2),
13075 TEST_CASE_ST(ut_setup, ut_teardown,
13076 test_snow3g_hash_generate_test_case_3),
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_snow3g_hash_verify_test_case_1),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_hash_verify_test_case_2),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_snow3g_hash_verify_test_case_3),
13084 /** ZUC encrypt only (EEA3) */
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_zuc_encryption_test_case_1),
13087 TEST_CASE_ST(ut_setup, ut_teardown,
13088 test_zuc_encryption_test_case_2),
13089 TEST_CASE_ST(ut_setup, ut_teardown,
13090 test_zuc_encryption_test_case_3),
13091 TEST_CASE_ST(ut_setup, ut_teardown,
13092 test_zuc_encryption_test_case_4),
13093 TEST_CASE_ST(ut_setup, ut_teardown,
13094 test_zuc_encryption_test_case_5),
13095 TEST_CASE_ST(ut_setup, ut_teardown,
13096 test_zuc_hash_generate_test_case_1),
13097 TEST_CASE_ST(ut_setup, ut_teardown,
13098 test_zuc_hash_generate_test_case_2),
13099 TEST_CASE_ST(ut_setup, ut_teardown,
13100 test_zuc_hash_generate_test_case_3),
13101 TEST_CASE_ST(ut_setup, ut_teardown,
13102 test_zuc_hash_generate_test_case_4),
13103 TEST_CASE_ST(ut_setup, ut_teardown,
13104 test_zuc_hash_generate_test_case_5),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_zuc_encryption_test_case_6_sgl),
13108 /** KASUMI encrypt only (UEA1) */
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_kasumi_encryption_test_case_1),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_kasumi_encryption_test_case_2),
13113 TEST_CASE_ST(ut_setup, ut_teardown,
13114 test_kasumi_encryption_test_case_3),
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_kasumi_encryption_test_case_4),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_kasumi_encryption_test_case_5),
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 test_kasumi_encryption_test_case_1_sgl),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_kasumi_encryption_test_case_1_oop_sgl),
13123 /** KASUMI decrypt only (UEA1) */
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_kasumi_decryption_test_case_1),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_kasumi_decryption_test_case_2),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_kasumi_decryption_test_case_3),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_kasumi_decryption_test_case_4),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_kasumi_decryption_test_case_5),
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 test_kasumi_encryption_test_case_1_oop),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_kasumi_decryption_test_case_1_oop),
13140 /** KASUMI hash only (UIA1) */
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_kasumi_hash_generate_test_case_1),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_kasumi_hash_generate_test_case_2),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_kasumi_hash_generate_test_case_3),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_kasumi_hash_generate_test_case_4),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_kasumi_hash_generate_test_case_5),
13151 TEST_CASE_ST(ut_setup, ut_teardown,
13152 test_kasumi_hash_generate_test_case_6),
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_kasumi_hash_verify_test_case_1),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_kasumi_hash_verify_test_case_2),
13157 TEST_CASE_ST(ut_setup, ut_teardown,
13158 test_kasumi_hash_verify_test_case_3),
13159 TEST_CASE_ST(ut_setup, ut_teardown,
13160 test_kasumi_hash_verify_test_case_4),
13161 TEST_CASE_ST(ut_setup, ut_teardown,
13162 test_kasumi_hash_verify_test_case_5),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_null_cipher_only_operation),
13167 TEST_CASE_ST(ut_setup, ut_teardown,
13168 test_null_auth_only_operation),
13169 TEST_CASE_ST(ut_setup, ut_teardown,
13170 test_null_cipher_auth_operation),
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_null_auth_cipher_operation),
13174 /** Negative tests */
13175 TEST_CASE_ST(ut_setup, ut_teardown,
13176 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13177 TEST_CASE_ST(ut_setup, ut_teardown,
13178 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 authentication_verify_AES128_GMAC_fail_data_corrupt),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13187 TEST_CASES_END() /**< NULL terminate unit test array */
13191 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13192 .suite_name = "Crypto NITROX Unit Test Suite",
13193 .setup = testsuite_setup,
13194 .teardown = testsuite_teardown,
13195 .unit_test_cases = {
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_device_configure_invalid_dev_id),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_device_configure_invalid_queue_pair_ids),
13200 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13201 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13203 TEST_CASES_END() /**< NULL terminate unit test array */
13207 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13208 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13209 .setup = testsuite_setup,
13210 .teardown = testsuite_teardown,
13211 .unit_test_cases = {
13212 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13213 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13214 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13215 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13216 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13218 /** AES GCM Authenticated Encryption */
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 test_AES_GCM_authenticated_encryption_test_case_1),
13221 TEST_CASE_ST(ut_setup, ut_teardown,
13222 test_AES_GCM_authenticated_encryption_test_case_2),
13223 TEST_CASE_ST(ut_setup, ut_teardown,
13224 test_AES_GCM_authenticated_encryption_test_case_3),
13225 TEST_CASE_ST(ut_setup, ut_teardown,
13226 test_AES_GCM_authenticated_encryption_test_case_4),
13227 TEST_CASE_ST(ut_setup, ut_teardown,
13228 test_AES_GCM_authenticated_encryption_test_case_5),
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_AES_GCM_authenticated_encryption_test_case_6),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_AES_GCM_authenticated_encryption_test_case_7),
13234 /** AES GCM Authenticated Decryption */
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_AES_GCM_authenticated_decryption_test_case_1),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_AES_GCM_authenticated_decryption_test_case_2),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_AES_GCM_authenticated_decryption_test_case_3),
13241 TEST_CASE_ST(ut_setup, ut_teardown,
13242 test_AES_GCM_authenticated_decryption_test_case_4),
13243 TEST_CASE_ST(ut_setup, ut_teardown,
13244 test_AES_GCM_authenticated_decryption_test_case_5),
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 test_AES_GCM_authenticated_decryption_test_case_6),
13247 TEST_CASE_ST(ut_setup, ut_teardown,
13248 test_AES_GCM_authenticated_decryption_test_case_7),
13249 /** AES GMAC Authentication */
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_AES_GMAC_authentication_test_case_1),
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_AES_GMAC_authentication_verify_test_case_1),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_AES_GMAC_authentication_test_case_2),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_AES_GMAC_authentication_verify_test_case_2),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_AES_GMAC_authentication_test_case_3),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_AES_GMAC_authentication_verify_test_case_3),
13263 /** SNOW 3G encrypt only (UEA2) */
13264 TEST_CASE_ST(ut_setup, ut_teardown,
13265 test_snow3g_encryption_test_case_1),
13266 TEST_CASE_ST(ut_setup, ut_teardown,
13267 test_snow3g_encryption_test_case_2),
13268 TEST_CASE_ST(ut_setup, ut_teardown,
13269 test_snow3g_encryption_test_case_3),
13270 TEST_CASE_ST(ut_setup, ut_teardown,
13271 test_snow3g_encryption_test_case_4),
13272 TEST_CASE_ST(ut_setup, ut_teardown,
13273 test_snow3g_encryption_test_case_5),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_snow3g_encryption_test_case_1_oop),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_snow3g_decryption_test_case_1_oop),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_snow3g_encryption_test_case_1_oop_sgl),
13282 /** SNOW 3G decrypt only (UEA2) */
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_snow3g_decryption_test_case_1),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_snow3g_decryption_test_case_2),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_snow3g_decryption_test_case_3),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_decryption_test_case_4),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_snow3g_decryption_test_case_5),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_hash_generate_test_case_1),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_snow3g_hash_generate_test_case_2),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_snow3g_hash_generate_test_case_3),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_hash_verify_test_case_1),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_hash_verify_test_case_2),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_hash_verify_test_case_3),
13307 /** ZUC encrypt only (EEA3) */
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_zuc_encryption_test_case_1),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_zuc_encryption_test_case_2),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_zuc_encryption_test_case_3),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_zuc_encryption_test_case_4),
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 test_zuc_encryption_test_case_5),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_zuc_hash_generate_test_case_1),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_zuc_hash_generate_test_case_2),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_zuc_hash_generate_test_case_3),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_zuc_hash_generate_test_case_4),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_zuc_hash_generate_test_case_5),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_zuc_encryption_test_case_6_sgl),
13331 /** KASUMI encrypt only (UEA1) */
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_kasumi_encryption_test_case_1),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_kasumi_encryption_test_case_2),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_kasumi_encryption_test_case_3),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_kasumi_encryption_test_case_4),
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 test_kasumi_encryption_test_case_5),
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_kasumi_encryption_test_case_1_sgl),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_kasumi_encryption_test_case_1_oop_sgl),
13346 /** KASUMI decrypt only (UEA1) */
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_kasumi_decryption_test_case_1),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_kasumi_decryption_test_case_2),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_kasumi_decryption_test_case_3),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_kasumi_decryption_test_case_4),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 test_kasumi_decryption_test_case_5),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_kasumi_encryption_test_case_1_oop),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_kasumi_decryption_test_case_1_oop),
13363 /** KASUMI hash only (UIA1) */
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_kasumi_hash_generate_test_case_1),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_kasumi_hash_generate_test_case_2),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_kasumi_hash_generate_test_case_3),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_kasumi_hash_generate_test_case_4),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_hash_generate_test_case_5),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_kasumi_hash_generate_test_case_6),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_kasumi_hash_verify_test_case_1),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_kasumi_hash_verify_test_case_2),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_kasumi_hash_verify_test_case_3),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_kasumi_hash_verify_test_case_4),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_kasumi_hash_verify_test_case_5),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_null_cipher_only_operation),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_null_auth_only_operation),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_null_cipher_auth_operation),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_null_auth_cipher_operation),
13397 /** Negative tests */
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 authentication_verify_AES128_GMAC_fail_data_corrupt),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13410 TEST_CASES_END() /**< NULL terminate unit test array */
13415 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13417 gbl_driver_id = rte_cryptodev_driver_id_get(
13418 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13420 if (gbl_driver_id == -1) {
13421 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13422 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13423 "are enabled in config file to run this testsuite.\n");
13424 return TEST_SKIPPED;
13427 return unit_test_suite_runner(&cryptodev_testsuite);
13431 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13433 gbl_driver_id = rte_cryptodev_driver_id_get(
13434 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13436 if (gbl_driver_id == -1) {
13437 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13438 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13439 "in config file to run this testsuite.\n");
13440 return TEST_FAILED;
13443 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13447 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13449 gbl_driver_id = rte_cryptodev_driver_id_get(
13450 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13452 if (gbl_driver_id == -1) {
13453 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13454 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13455 "in config file to run this testsuite.\n");
13456 return TEST_SKIPPED;
13459 return unit_test_suite_runner(&cryptodev_testsuite);
13463 test_cryptodev_cpu_aesni_mb(void)
13466 enum rte_security_session_action_type at;
13468 gbl_driver_id = rte_cryptodev_driver_id_get(
13469 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13471 if (gbl_driver_id == -1) {
13472 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13473 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13474 "in config file to run this testsuite.\n");
13475 return TEST_SKIPPED;
13478 at = gbl_action_type;
13479 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13480 rc = unit_test_suite_runner(&cryptodev_testsuite);
13481 gbl_action_type = at;
13486 test_cryptodev_openssl(void)
13488 gbl_driver_id = rte_cryptodev_driver_id_get(
13489 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13491 if (gbl_driver_id == -1) {
13492 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13493 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13494 "in config file to run this testsuite.\n");
13495 return TEST_SKIPPED;
13498 return unit_test_suite_runner(&cryptodev_testsuite);
13502 test_cryptodev_aesni_gcm(void)
13504 gbl_driver_id = rte_cryptodev_driver_id_get(
13505 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13507 if (gbl_driver_id == -1) {
13508 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13509 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13510 "in config file to run this testsuite.\n");
13511 return TEST_SKIPPED;
13514 return unit_test_suite_runner(&cryptodev_testsuite);
13518 test_cryptodev_cpu_aesni_gcm(void)
13521 enum rte_security_session_action_type at;
13523 gbl_driver_id = rte_cryptodev_driver_id_get(
13524 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13526 if (gbl_driver_id == -1) {
13527 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13528 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13529 "in config file to run this testsuite.\n");
13530 return TEST_SKIPPED;
13533 at = gbl_action_type;
13534 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13535 rc = unit_test_suite_runner(&cryptodev_testsuite);
13536 gbl_action_type = at;
13541 test_cryptodev_null(void)
13543 gbl_driver_id = rte_cryptodev_driver_id_get(
13544 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13546 if (gbl_driver_id == -1) {
13547 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13548 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13549 "in config file to run this testsuite.\n");
13550 return TEST_SKIPPED;
13553 return unit_test_suite_runner(&cryptodev_testsuite);
13557 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13559 gbl_driver_id = rte_cryptodev_driver_id_get(
13560 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13562 if (gbl_driver_id == -1) {
13563 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13564 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13565 "in config file to run this testsuite.\n");
13566 return TEST_SKIPPED;
13569 return unit_test_suite_runner(&cryptodev_testsuite);
13573 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13575 gbl_driver_id = rte_cryptodev_driver_id_get(
13576 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13578 if (gbl_driver_id == -1) {
13579 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13580 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13581 "in config file to run this testsuite.\n");
13582 return TEST_SKIPPED;
13585 return unit_test_suite_runner(&cryptodev_testsuite);
13589 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13591 gbl_driver_id = rte_cryptodev_driver_id_get(
13592 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13594 if (gbl_driver_id == -1) {
13595 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13596 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13597 "in config file to run this testsuite.\n");
13598 return TEST_SKIPPED;
13601 return unit_test_suite_runner(&cryptodev_testsuite);
13605 test_cryptodev_armv8(void)
13607 gbl_driver_id = rte_cryptodev_driver_id_get(
13608 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13610 if (gbl_driver_id == -1) {
13611 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13612 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13613 "in config file to run this testsuite.\n");
13614 return TEST_SKIPPED;
13617 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13621 test_cryptodev_mrvl(void)
13623 gbl_driver_id = rte_cryptodev_driver_id_get(
13624 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13626 if (gbl_driver_id == -1) {
13627 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13628 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13629 "in config file to run this testsuite.\n");
13630 return TEST_SKIPPED;
13633 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13636 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13639 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13641 gbl_driver_id = rte_cryptodev_driver_id_get(
13642 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13644 if (gbl_driver_id == -1) {
13645 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13646 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13647 "in config file to run this testsuite.\n");
13648 return TEST_SKIPPED;
13651 if (rte_cryptodev_driver_id_get(
13652 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13653 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13654 " enabled in config file to run this testsuite.\n");
13655 return TEST_SKIPPED;
13657 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13660 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13665 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13667 gbl_driver_id = rte_cryptodev_driver_id_get(
13668 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13670 if (gbl_driver_id == -1) {
13671 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13672 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13673 "in config file to run this testsuite.\n");
13674 return TEST_SKIPPED;
13677 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13681 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13683 gbl_driver_id = rte_cryptodev_driver_id_get(
13684 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13686 if (gbl_driver_id == -1) {
13687 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13688 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13689 "in config file to run this testsuite.\n");
13690 return TEST_SKIPPED;
13693 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13697 test_cryptodev_ccp(void)
13699 gbl_driver_id = rte_cryptodev_driver_id_get(
13700 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13702 if (gbl_driver_id == -1) {
13703 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13704 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13705 "in config file to run this testsuite.\n");
13706 return TEST_FAILED;
13709 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13713 test_cryptodev_octeontx(void)
13715 gbl_driver_id = rte_cryptodev_driver_id_get(
13716 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13717 if (gbl_driver_id == -1) {
13718 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13719 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13720 "enabled in config file to run this "
13722 return TEST_FAILED;
13724 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13728 test_cryptodev_octeontx2(void)
13730 gbl_driver_id = rte_cryptodev_driver_id_get(
13731 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13732 if (gbl_driver_id == -1) {
13733 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13734 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13735 "enabled in config file to run this "
13737 return TEST_FAILED;
13739 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13743 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13745 gbl_driver_id = rte_cryptodev_driver_id_get(
13746 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13748 if (gbl_driver_id == -1) {
13749 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13750 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13751 "in config file to run this testsuite.\n");
13752 return TEST_FAILED;
13755 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13759 test_cryptodev_nitrox(void)
13761 gbl_driver_id = rte_cryptodev_driver_id_get(
13762 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13764 if (gbl_driver_id == -1) {
13765 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13766 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13767 "in config file to run this testsuite.\n");
13768 return TEST_FAILED;
13771 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13774 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13775 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13776 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13777 test_cryptodev_cpu_aesni_mb);
13778 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13779 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13780 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13781 test_cryptodev_cpu_aesni_gcm);
13782 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13783 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13784 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13785 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13786 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13787 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13788 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13789 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13790 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13791 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13792 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13793 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13794 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13795 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);