1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* Stop the device in case it's started so it can be configured */
771 rte_cryptodev_stop(ts_params->valid_devs[0]);
773 /* valid - max value queue pairs */
774 ts_params->conf.nb_queue_pairs = orig_nb_qps;
776 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
778 "Failed to configure cryptodev: dev_id %u, qp_id %u",
779 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
781 /* valid - one queue pairs */
782 ts_params->conf.nb_queue_pairs = 1;
784 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
786 "Failed to configure cryptodev: dev_id %u, qp_id %u",
787 ts_params->valid_devs[0],
788 ts_params->conf.nb_queue_pairs);
791 /* invalid - zero queue pairs */
792 ts_params->conf.nb_queue_pairs = 0;
794 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
796 "Failed test for rte_cryptodev_configure, dev_id %u,"
798 ts_params->valid_devs[0],
799 ts_params->conf.nb_queue_pairs);
802 /* invalid - max value supported by field queue pairs */
803 ts_params->conf.nb_queue_pairs = UINT16_MAX;
805 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
807 "Failed test for rte_cryptodev_configure, dev_id %u,"
809 ts_params->valid_devs[0],
810 ts_params->conf.nb_queue_pairs);
813 /* invalid - max value + 1 queue pairs */
814 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
816 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
818 "Failed test for rte_cryptodev_configure, dev_id %u,"
820 ts_params->valid_devs[0],
821 ts_params->conf.nb_queue_pairs);
823 /* revert to original testsuite value */
824 ts_params->conf.nb_queue_pairs = orig_nb_qps;
830 test_queue_pair_descriptor_setup(void)
832 struct crypto_testsuite_params *ts_params = &testsuite_params;
833 struct rte_cryptodev_qp_conf qp_conf = {
834 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
838 /* Stop the device in case it's started so it can be configured */
839 rte_cryptodev_stop(ts_params->valid_devs[0]);
841 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
843 "Failed to configure cryptodev %u",
844 ts_params->valid_devs[0]);
847 * Test various ring sizes on this device. memzones can't be
848 * freed so are re-used if ring is released and re-created.
850 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
851 qp_conf.mp_session = ts_params->session_mpool;
852 qp_conf.mp_session_private = ts_params->session_priv_mpool;
854 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
856 ts_params->valid_devs[0], qp_id, &qp_conf,
857 rte_cryptodev_socket_id(
858 ts_params->valid_devs[0])),
860 "rte_cryptodev_queue_pair_setup: num_inflights "
861 "%u on qp %u on cryptodev %u",
862 qp_conf.nb_descriptors, qp_id,
863 ts_params->valid_devs[0]);
866 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
868 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
869 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
870 ts_params->valid_devs[0], qp_id, &qp_conf,
871 rte_cryptodev_socket_id(
872 ts_params->valid_devs[0])),
874 " rte_cryptodev_queue_pair_setup: num_inflights"
875 " %u on qp %u on cryptodev %u",
876 qp_conf.nb_descriptors, qp_id,
877 ts_params->valid_devs[0]);
880 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
882 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
883 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
884 ts_params->valid_devs[0], qp_id, &qp_conf,
885 rte_cryptodev_socket_id(
886 ts_params->valid_devs[0])),
888 "rte_cryptodev_queue_pair_setup: num_inflights"
889 " %u on qp %u on cryptodev %u",
890 qp_conf.nb_descriptors, qp_id,
891 ts_params->valid_devs[0]);
894 /* invalid number of descriptors - max supported + 2 */
895 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
897 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
898 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
899 ts_params->valid_devs[0], qp_id, &qp_conf,
900 rte_cryptodev_socket_id(
901 ts_params->valid_devs[0])),
902 "Unexpectedly passed test for "
903 "rte_cryptodev_queue_pair_setup:"
904 "num_inflights %u on qp %u on cryptodev %u",
905 qp_conf.nb_descriptors, qp_id,
906 ts_params->valid_devs[0]);
909 /* invalid number of descriptors - max value of parameter */
910 qp_conf.nb_descriptors = UINT32_MAX-1;
912 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
913 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
914 ts_params->valid_devs[0], qp_id, &qp_conf,
915 rte_cryptodev_socket_id(
916 ts_params->valid_devs[0])),
917 "Unexpectedly passed test for "
918 "rte_cryptodev_queue_pair_setup:"
919 "num_inflights %u on qp %u on cryptodev %u",
920 qp_conf.nb_descriptors, qp_id,
921 ts_params->valid_devs[0]);
924 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
926 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
927 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
928 ts_params->valid_devs[0], qp_id, &qp_conf,
929 rte_cryptodev_socket_id(
930 ts_params->valid_devs[0])),
932 " rte_cryptodev_queue_pair_setup:"
933 "num_inflights %u on qp %u on cryptodev %u",
934 qp_conf.nb_descriptors, qp_id,
935 ts_params->valid_devs[0]);
938 /* invalid number of descriptors - max supported + 1 */
939 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
941 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
942 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
943 ts_params->valid_devs[0], qp_id, &qp_conf,
944 rte_cryptodev_socket_id(
945 ts_params->valid_devs[0])),
946 "Unexpectedly passed test for "
947 "rte_cryptodev_queue_pair_setup:"
948 "num_inflights %u on qp %u on cryptodev %u",
949 qp_conf.nb_descriptors, qp_id,
950 ts_params->valid_devs[0]);
953 /* test invalid queue pair id */
954 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
956 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
958 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
959 ts_params->valid_devs[0],
961 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
962 "Failed test for rte_cryptodev_queue_pair_setup:"
963 "invalid qp %u on cryptodev %u",
964 qp_id, ts_params->valid_devs[0]);
966 qp_id = 0xffff; /*invalid*/
968 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
969 ts_params->valid_devs[0],
971 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
972 "Failed test for rte_cryptodev_queue_pair_setup:"
973 "invalid qp %u on cryptodev %u",
974 qp_id, ts_params->valid_devs[0]);
979 /* ***** Plaintext data for tests ***** */
981 const char catch_22_quote_1[] =
982 "There was only one catch and that was Catch-22, which "
983 "specified that a concern for one's safety in the face of "
984 "dangers that were real and immediate was the process of a "
985 "rational mind. Orr was crazy and could be grounded. All he "
986 "had to do was ask; and as soon as he did, he would no longer "
987 "be crazy and would have to fly more missions. Orr would be "
988 "crazy to fly more missions and sane if he didn't, but if he "
989 "was sane he had to fly them. If he flew them he was crazy "
990 "and didn't have to; but if he didn't want to he was sane and "
991 "had to. Yossarian was moved very deeply by the absolute "
992 "simplicity of this clause of Catch-22 and let out a "
993 "respectful whistle. \"That's some catch, that Catch-22\", he "
994 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
996 const char catch_22_quote[] =
997 "What a lousy earth! He wondered how many people were "
998 "destitute that same night even in his own prosperous country, "
999 "how many homes were shanties, how many husbands were drunk "
1000 "and wives socked, and how many children were bullied, abused, "
1001 "or abandoned. How many families hungered for food they could "
1002 "not afford to buy? How many hearts were broken? How many "
1003 "suicides would take place that same night, how many people "
1004 "would go insane? How many cockroaches and landlords would "
1005 "triumph? How many winners were losers, successes failures, "
1006 "and rich men poor men? How many wise guys were stupid? How "
1007 "many happy endings were unhappy endings? How many honest men "
1008 "were liars, brave men cowards, loyal men traitors, how many "
1009 "sainted men were corrupt, how many people in positions of "
1010 "trust had sold their souls to bodyguards, how many had never "
1011 "had souls? How many straight-and-narrow paths were crooked "
1012 "paths? How many best families were worst families and how "
1013 "many good people were bad people? When you added them all up "
1014 "and then subtracted, you might be left with only the children, "
1015 "and perhaps with Albert Einstein and an old violinist or "
1016 "sculptor somewhere.";
1018 #define QUOTE_480_BYTES (480)
1019 #define QUOTE_512_BYTES (512)
1020 #define QUOTE_768_BYTES (768)
1021 #define QUOTE_1024_BYTES (1024)
1025 /* ***** SHA1 Hash Tests ***** */
1027 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1029 static uint8_t hmac_sha1_key[] = {
1030 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1031 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1032 0xDE, 0xF4, 0xDE, 0xAD };
1034 /* ***** SHA224 Hash Tests ***** */
1036 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1039 /* ***** AES-CBC Cipher Tests ***** */
1041 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1042 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1044 static uint8_t aes_cbc_key[] = {
1045 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1046 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1048 static uint8_t aes_cbc_iv[] = {
1049 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1050 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1053 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1055 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1056 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1057 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1058 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1059 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1060 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1061 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1062 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1063 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1064 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1065 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1066 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1067 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1068 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1069 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1070 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1071 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1072 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1073 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1074 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1075 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1076 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1077 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1078 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1079 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1080 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1081 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1082 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1083 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1084 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1085 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1086 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1087 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1088 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1089 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1090 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1091 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1092 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1093 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1094 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1095 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1096 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1097 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1098 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1099 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1100 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1101 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1102 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1103 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1104 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1105 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1106 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1107 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1108 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1109 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1110 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1111 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1112 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1113 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1114 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1115 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1116 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1117 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1118 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1119 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1122 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1123 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1124 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1125 0x18, 0x8c, 0x1d, 0x32
1129 /* Multisession Vector context Test */
1130 /*Begin Session 0 */
1131 static uint8_t ms_aes_cbc_key0[] = {
1132 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1133 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1136 static uint8_t ms_aes_cbc_iv0[] = {
1137 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1138 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1141 static const uint8_t ms_aes_cbc_cipher0[] = {
1142 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1143 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1144 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1145 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1146 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1147 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1148 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1149 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1150 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1151 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1152 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1153 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1154 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1155 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1156 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1157 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1158 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1159 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1160 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1161 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1162 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1163 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1164 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1165 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1166 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1167 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1168 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1169 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1170 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1171 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1172 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1173 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1174 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1175 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1176 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1177 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1178 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1179 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1180 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1181 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1182 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1183 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1184 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1185 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1186 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1187 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1188 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1189 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1190 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1191 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1192 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1193 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1194 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1195 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1196 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1197 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1198 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1199 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1200 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1201 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1202 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1203 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1204 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1205 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1209 static uint8_t ms_hmac_key0[] = {
1210 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1211 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1212 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1213 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1214 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1215 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1216 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1217 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1220 static const uint8_t ms_hmac_digest0[] = {
1221 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1222 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1223 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1224 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1225 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1226 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1227 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1228 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1232 /* Begin session 1 */
1234 static uint8_t ms_aes_cbc_key1[] = {
1235 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1236 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1239 static uint8_t ms_aes_cbc_iv1[] = {
1240 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1241 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1244 static const uint8_t ms_aes_cbc_cipher1[] = {
1245 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1246 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1247 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1248 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1249 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1250 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1251 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1252 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1253 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1254 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1255 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1256 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1257 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1258 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1259 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1260 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1261 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1262 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1263 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1264 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1265 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1266 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1267 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1268 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1269 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1270 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1271 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1272 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1273 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1274 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1275 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1276 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1277 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1278 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1279 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1280 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1281 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1282 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1283 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1284 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1285 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1286 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1287 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1288 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1289 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1290 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1291 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1292 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1293 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1294 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1295 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1296 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1297 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1298 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1299 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1300 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1301 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1302 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1303 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1304 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1305 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1306 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1307 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1308 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1312 static uint8_t ms_hmac_key1[] = {
1313 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1314 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1315 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1316 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1317 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1318 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1319 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1320 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1323 static const uint8_t ms_hmac_digest1[] = {
1324 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1325 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1326 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1327 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1328 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1329 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1330 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1331 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1334 /* Begin Session 2 */
1335 static uint8_t ms_aes_cbc_key2[] = {
1336 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1337 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1340 static uint8_t ms_aes_cbc_iv2[] = {
1341 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1342 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1345 static const uint8_t ms_aes_cbc_cipher2[] = {
1346 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1347 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1348 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1349 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1350 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1351 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1352 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1353 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1354 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1355 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1356 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1357 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1358 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1359 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1360 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1361 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1362 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1363 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1364 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1365 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1366 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1367 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1368 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1369 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1370 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1371 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1372 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1373 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1374 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1375 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1376 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1377 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1378 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1379 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1380 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1381 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1382 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1383 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1384 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1385 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1386 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1387 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1388 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1389 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1390 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1391 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1392 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1393 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1394 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1395 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1396 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1397 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1398 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1399 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1400 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1401 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1402 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1403 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1404 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1405 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1406 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1407 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1408 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1409 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1412 static uint8_t ms_hmac_key2[] = {
1413 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1414 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1415 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1416 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1417 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1418 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1419 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1420 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1423 static const uint8_t ms_hmac_digest2[] = {
1424 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1425 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1426 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1427 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1428 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1429 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1430 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1431 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1438 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1440 struct crypto_testsuite_params *ts_params = &testsuite_params;
1441 struct crypto_unittest_params *ut_params = &unittest_params;
1443 /* Verify the capabilities */
1444 struct rte_cryptodev_sym_capability_idx cap_idx;
1445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1446 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1451 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1452 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1456 /* Generate test mbuf data and space for digest */
1457 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1458 catch_22_quote, QUOTE_512_BYTES, 0);
1460 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1461 DIGEST_BYTE_LENGTH_SHA1);
1462 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1464 /* Setup Cipher Parameters */
1465 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1466 ut_params->cipher_xform.next = &ut_params->auth_xform;
1468 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1469 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1470 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1471 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1472 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1473 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1475 /* Setup HMAC Parameters */
1476 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1478 ut_params->auth_xform.next = NULL;
1480 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1481 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1482 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1483 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1484 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1486 ut_params->sess = rte_cryptodev_sym_session_create(
1487 ts_params->session_mpool);
1489 /* Create crypto session*/
1490 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1491 ut_params->sess, &ut_params->cipher_xform,
1492 ts_params->session_priv_mpool);
1493 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1495 /* Generate crypto op data structure */
1496 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1497 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1498 TEST_ASSERT_NOT_NULL(ut_params->op,
1499 "Failed to allocate symmetric crypto operation struct");
1501 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1503 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1505 /* set crypto operation source mbuf */
1506 sym_op->m_src = ut_params->ibuf;
1508 /* Set crypto operation authentication parameters */
1509 sym_op->auth.digest.data = ut_params->digest;
1510 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1511 ut_params->ibuf, QUOTE_512_BYTES);
1513 sym_op->auth.data.offset = 0;
1514 sym_op->auth.data.length = QUOTE_512_BYTES;
1516 /* Copy IV at the end of the crypto operation */
1517 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1518 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1520 /* Set crypto operation cipher parameters */
1521 sym_op->cipher.data.offset = 0;
1522 sym_op->cipher.data.length = QUOTE_512_BYTES;
1524 /* Process crypto operation */
1525 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1526 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1529 TEST_ASSERT_NOT_NULL(
1530 process_crypto_request(ts_params->valid_devs[0],
1532 "failed to process sym crypto op");
1534 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1535 "crypto op processing failed");
1538 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1541 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1542 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1544 "ciphertext data not as expected");
1546 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1548 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1549 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1550 gbl_driver_id == rte_cryptodev_driver_id_get(
1551 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1552 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1553 DIGEST_BYTE_LENGTH_SHA1,
1554 "Generated digest data not as expected");
1556 return TEST_SUCCESS;
1559 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1561 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1563 static uint8_t hmac_sha512_key[] = {
1564 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1565 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1566 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1567 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1568 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1569 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1570 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1571 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1573 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1574 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1575 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1576 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1577 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1578 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1579 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1580 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1581 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1586 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1587 struct crypto_unittest_params *ut_params,
1588 uint8_t *cipher_key,
1592 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1593 struct crypto_unittest_params *ut_params,
1594 struct crypto_testsuite_params *ts_params,
1595 const uint8_t *cipher,
1596 const uint8_t *digest,
1601 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1602 struct crypto_unittest_params *ut_params,
1603 uint8_t *cipher_key,
1607 /* Setup Cipher Parameters */
1608 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1609 ut_params->cipher_xform.next = NULL;
1611 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1612 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1613 ut_params->cipher_xform.cipher.key.data = cipher_key;
1614 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1615 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1616 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1618 /* Setup HMAC Parameters */
1619 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1620 ut_params->auth_xform.next = &ut_params->cipher_xform;
1622 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1623 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1624 ut_params->auth_xform.auth.key.data = hmac_key;
1625 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1626 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1628 return TEST_SUCCESS;
1633 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1634 struct crypto_unittest_params *ut_params,
1635 struct crypto_testsuite_params *ts_params,
1636 const uint8_t *cipher,
1637 const uint8_t *digest,
1640 /* Generate test mbuf data and digest */
1641 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1644 QUOTE_512_BYTES, 0);
1646 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1647 DIGEST_BYTE_LENGTH_SHA512);
1648 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1650 rte_memcpy(ut_params->digest,
1652 DIGEST_BYTE_LENGTH_SHA512);
1654 /* Generate Crypto op data structure */
1655 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1656 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1657 TEST_ASSERT_NOT_NULL(ut_params->op,
1658 "Failed to allocate symmetric crypto operation struct");
1660 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1662 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1664 /* set crypto operation source mbuf */
1665 sym_op->m_src = ut_params->ibuf;
1667 sym_op->auth.digest.data = ut_params->digest;
1668 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1669 ut_params->ibuf, QUOTE_512_BYTES);
1671 sym_op->auth.data.offset = 0;
1672 sym_op->auth.data.length = QUOTE_512_BYTES;
1674 /* Copy IV at the end of the crypto operation */
1675 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1676 iv, CIPHER_IV_LENGTH_AES_CBC);
1678 sym_op->cipher.data.offset = 0;
1679 sym_op->cipher.data.length = QUOTE_512_BYTES;
1681 /* Process crypto operation */
1682 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1683 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1686 TEST_ASSERT_NOT_NULL(
1687 process_crypto_request(ts_params->valid_devs[0],
1689 "failed to process sym crypto op");
1691 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1692 "crypto op processing failed");
1694 ut_params->obuf = ut_params->op->sym->m_src;
1697 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1698 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1701 "Plaintext data not as expected");
1704 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1705 "Digest verification failed");
1707 return TEST_SUCCESS;
1711 test_blockcipher(enum blockcipher_test_type test_type)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1717 ts_params->op_mpool,
1718 ts_params->session_mpool, ts_params->session_priv_mpool,
1719 ts_params->valid_devs[0],
1722 if (status == -ENOTSUP)
1725 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1727 return TEST_SUCCESS;
1731 test_AES_cipheronly_all(void)
1733 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1737 test_AES_docsis_all(void)
1739 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1743 test_DES_docsis_all(void)
1745 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1749 test_DES_cipheronly_all(void)
1751 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1755 test_authonly_all(void)
1757 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1761 test_AES_chain_all(void)
1763 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1767 test_3DES_chain_all(void)
1769 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1773 test_3DES_cipheronly_all(void)
1775 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1778 /* ***** SNOW 3G Tests ***** */
1780 create_wireless_algo_hash_session(uint8_t dev_id,
1781 const uint8_t *key, const uint8_t key_len,
1782 const uint8_t iv_len, const uint8_t auth_len,
1783 enum rte_crypto_auth_operation op,
1784 enum rte_crypto_auth_algorithm algo)
1786 uint8_t hash_key[key_len];
1789 struct crypto_testsuite_params *ts_params = &testsuite_params;
1790 struct crypto_unittest_params *ut_params = &unittest_params;
1792 memcpy(hash_key, key, key_len);
1794 debug_hexdump(stdout, "key:", key, key_len);
1796 /* Setup Authentication Parameters */
1797 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1798 ut_params->auth_xform.next = NULL;
1800 ut_params->auth_xform.auth.op = op;
1801 ut_params->auth_xform.auth.algo = algo;
1802 ut_params->auth_xform.auth.key.length = key_len;
1803 ut_params->auth_xform.auth.key.data = hash_key;
1804 ut_params->auth_xform.auth.digest_length = auth_len;
1805 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1806 ut_params->auth_xform.auth.iv.length = iv_len;
1807 ut_params->sess = rte_cryptodev_sym_session_create(
1808 ts_params->session_mpool);
1810 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1811 &ut_params->auth_xform,
1812 ts_params->session_priv_mpool);
1813 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1814 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1819 create_wireless_algo_cipher_session(uint8_t dev_id,
1820 enum rte_crypto_cipher_operation op,
1821 enum rte_crypto_cipher_algorithm algo,
1822 const uint8_t *key, const uint8_t key_len,
1825 uint8_t cipher_key[key_len];
1827 struct crypto_testsuite_params *ts_params = &testsuite_params;
1828 struct crypto_unittest_params *ut_params = &unittest_params;
1830 memcpy(cipher_key, key, key_len);
1832 /* Setup Cipher Parameters */
1833 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1834 ut_params->cipher_xform.next = NULL;
1836 ut_params->cipher_xform.cipher.algo = algo;
1837 ut_params->cipher_xform.cipher.op = op;
1838 ut_params->cipher_xform.cipher.key.data = cipher_key;
1839 ut_params->cipher_xform.cipher.key.length = key_len;
1840 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1841 ut_params->cipher_xform.cipher.iv.length = iv_len;
1843 debug_hexdump(stdout, "key:", key, key_len);
1845 /* Create Crypto session */
1846 ut_params->sess = rte_cryptodev_sym_session_create(
1847 ts_params->session_mpool);
1849 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1850 &ut_params->cipher_xform,
1851 ts_params->session_priv_mpool);
1852 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1853 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1858 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1859 unsigned int cipher_len,
1860 unsigned int cipher_offset)
1862 struct crypto_testsuite_params *ts_params = &testsuite_params;
1863 struct crypto_unittest_params *ut_params = &unittest_params;
1865 /* Generate Crypto op data structure */
1866 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1867 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1868 TEST_ASSERT_NOT_NULL(ut_params->op,
1869 "Failed to allocate pktmbuf offload");
1871 /* Set crypto operation data parameters */
1872 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1874 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1876 /* set crypto operation source mbuf */
1877 sym_op->m_src = ut_params->ibuf;
1880 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1882 sym_op->cipher.data.length = cipher_len;
1883 sym_op->cipher.data.offset = cipher_offset;
1888 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1889 unsigned int cipher_len,
1890 unsigned int cipher_offset)
1892 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 struct crypto_unittest_params *ut_params = &unittest_params;
1895 /* Generate Crypto op data structure */
1896 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1897 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1898 TEST_ASSERT_NOT_NULL(ut_params->op,
1899 "Failed to allocate pktmbuf offload");
1901 /* Set crypto operation data parameters */
1902 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1904 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1906 /* set crypto operation source mbuf */
1907 sym_op->m_src = ut_params->ibuf;
1908 sym_op->m_dst = ut_params->obuf;
1911 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1913 sym_op->cipher.data.length = cipher_len;
1914 sym_op->cipher.data.offset = cipher_offset;
1919 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1920 enum rte_crypto_cipher_operation cipher_op,
1921 enum rte_crypto_auth_operation auth_op,
1922 enum rte_crypto_auth_algorithm auth_algo,
1923 enum rte_crypto_cipher_algorithm cipher_algo,
1924 const uint8_t *key, uint8_t key_len,
1925 uint8_t auth_iv_len, uint8_t auth_len,
1926 uint8_t cipher_iv_len)
1929 uint8_t cipher_auth_key[key_len];
1932 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 struct crypto_unittest_params *ut_params = &unittest_params;
1935 memcpy(cipher_auth_key, key, key_len);
1937 /* Setup Authentication Parameters */
1938 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1939 ut_params->auth_xform.next = NULL;
1941 ut_params->auth_xform.auth.op = auth_op;
1942 ut_params->auth_xform.auth.algo = auth_algo;
1943 ut_params->auth_xform.auth.key.length = key_len;
1944 /* Hash key = cipher key */
1945 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1946 ut_params->auth_xform.auth.digest_length = auth_len;
1947 /* Auth IV will be after cipher IV */
1948 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1949 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1951 /* Setup Cipher Parameters */
1952 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1953 ut_params->cipher_xform.next = &ut_params->auth_xform;
1955 ut_params->cipher_xform.cipher.algo = cipher_algo;
1956 ut_params->cipher_xform.cipher.op = cipher_op;
1957 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1958 ut_params->cipher_xform.cipher.key.length = key_len;
1959 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1960 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1962 debug_hexdump(stdout, "key:", key, key_len);
1964 /* Create Crypto session*/
1965 ut_params->sess = rte_cryptodev_sym_session_create(
1966 ts_params->session_mpool);
1967 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1969 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1970 &ut_params->cipher_xform,
1971 ts_params->session_priv_mpool);
1972 if (status == -ENOTSUP)
1975 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1980 create_wireless_cipher_auth_session(uint8_t dev_id,
1981 enum rte_crypto_cipher_operation cipher_op,
1982 enum rte_crypto_auth_operation auth_op,
1983 enum rte_crypto_auth_algorithm auth_algo,
1984 enum rte_crypto_cipher_algorithm cipher_algo,
1985 const struct wireless_test_data *tdata)
1987 const uint8_t key_len = tdata->key.len;
1988 uint8_t cipher_auth_key[key_len];
1991 struct crypto_testsuite_params *ts_params = &testsuite_params;
1992 struct crypto_unittest_params *ut_params = &unittest_params;
1993 const uint8_t *key = tdata->key.data;
1994 const uint8_t auth_len = tdata->digest.len;
1995 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1996 uint8_t auth_iv_len = tdata->auth_iv.len;
1998 memcpy(cipher_auth_key, key, key_len);
2000 /* Setup Authentication Parameters */
2001 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2002 ut_params->auth_xform.next = NULL;
2004 ut_params->auth_xform.auth.op = auth_op;
2005 ut_params->auth_xform.auth.algo = auth_algo;
2006 ut_params->auth_xform.auth.key.length = key_len;
2007 /* Hash key = cipher key */
2008 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2009 ut_params->auth_xform.auth.digest_length = auth_len;
2010 /* Auth IV will be after cipher IV */
2011 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2012 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2014 /* Setup Cipher Parameters */
2015 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2016 ut_params->cipher_xform.next = &ut_params->auth_xform;
2018 ut_params->cipher_xform.cipher.algo = cipher_algo;
2019 ut_params->cipher_xform.cipher.op = cipher_op;
2020 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2021 ut_params->cipher_xform.cipher.key.length = key_len;
2022 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2023 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2026 debug_hexdump(stdout, "key:", key, key_len);
2028 /* Create Crypto session*/
2029 ut_params->sess = rte_cryptodev_sym_session_create(
2030 ts_params->session_mpool);
2032 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2033 &ut_params->cipher_xform,
2034 ts_params->session_priv_mpool);
2035 if (status == -ENOTSUP)
2038 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2039 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2044 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2045 const struct wireless_test_data *tdata)
2047 return create_wireless_cipher_auth_session(dev_id,
2048 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2049 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2050 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2054 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2055 enum rte_crypto_cipher_operation cipher_op,
2056 enum rte_crypto_auth_operation auth_op,
2057 enum rte_crypto_auth_algorithm auth_algo,
2058 enum rte_crypto_cipher_algorithm cipher_algo,
2059 const uint8_t *key, const uint8_t key_len,
2060 uint8_t auth_iv_len, uint8_t auth_len,
2061 uint8_t cipher_iv_len)
2063 uint8_t auth_cipher_key[key_len];
2065 struct crypto_testsuite_params *ts_params = &testsuite_params;
2066 struct crypto_unittest_params *ut_params = &unittest_params;
2068 memcpy(auth_cipher_key, key, key_len);
2070 /* Setup Authentication Parameters */
2071 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2072 ut_params->auth_xform.auth.op = auth_op;
2073 ut_params->auth_xform.next = &ut_params->cipher_xform;
2074 ut_params->auth_xform.auth.algo = auth_algo;
2075 ut_params->auth_xform.auth.key.length = key_len;
2076 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2077 ut_params->auth_xform.auth.digest_length = auth_len;
2078 /* Auth IV will be after cipher IV */
2079 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2080 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2082 /* Setup Cipher Parameters */
2083 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2084 ut_params->cipher_xform.next = NULL;
2085 ut_params->cipher_xform.cipher.algo = cipher_algo;
2086 ut_params->cipher_xform.cipher.op = cipher_op;
2087 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2088 ut_params->cipher_xform.cipher.key.length = key_len;
2089 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2090 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2092 debug_hexdump(stdout, "key:", key, key_len);
2094 /* Create Crypto session*/
2095 ut_params->sess = rte_cryptodev_sym_session_create(
2096 ts_params->session_mpool);
2097 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2099 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2100 ut_params->auth_xform.next = NULL;
2101 ut_params->cipher_xform.next = &ut_params->auth_xform;
2102 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2103 &ut_params->cipher_xform,
2104 ts_params->session_priv_mpool);
2107 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2108 &ut_params->auth_xform,
2109 ts_params->session_priv_mpool);
2111 if (status == -ENOTSUP)
2114 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2120 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2121 unsigned int auth_tag_len,
2122 const uint8_t *iv, unsigned int iv_len,
2123 unsigned int data_pad_len,
2124 enum rte_crypto_auth_operation op,
2125 unsigned int auth_len, unsigned int auth_offset)
2127 struct crypto_testsuite_params *ts_params = &testsuite_params;
2129 struct crypto_unittest_params *ut_params = &unittest_params;
2131 /* Generate Crypto op data structure */
2132 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2133 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2134 TEST_ASSERT_NOT_NULL(ut_params->op,
2135 "Failed to allocate pktmbuf offload");
2137 /* Set crypto operation data parameters */
2138 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2140 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2142 /* set crypto operation source mbuf */
2143 sym_op->m_src = ut_params->ibuf;
2146 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2149 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2150 ut_params->ibuf, auth_tag_len);
2152 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2153 "no room to append auth tag");
2154 ut_params->digest = sym_op->auth.digest.data;
2155 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2156 ut_params->ibuf, data_pad_len);
2157 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2158 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2160 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2162 debug_hexdump(stdout, "digest:",
2163 sym_op->auth.digest.data,
2166 sym_op->auth.data.length = auth_len;
2167 sym_op->auth.data.offset = auth_offset;
2173 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2174 enum rte_crypto_auth_operation op)
2176 struct crypto_testsuite_params *ts_params = &testsuite_params;
2177 struct crypto_unittest_params *ut_params = &unittest_params;
2179 const uint8_t *auth_tag = tdata->digest.data;
2180 const unsigned int auth_tag_len = tdata->digest.len;
2181 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2182 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2184 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2185 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2186 const uint8_t *auth_iv = tdata->auth_iv.data;
2187 const uint8_t auth_iv_len = tdata->auth_iv.len;
2188 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2189 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2191 /* Generate Crypto op data structure */
2192 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2193 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2194 TEST_ASSERT_NOT_NULL(ut_params->op,
2195 "Failed to allocate pktmbuf offload");
2196 /* Set crypto operation data parameters */
2197 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2199 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2201 /* set crypto operation source mbuf */
2202 sym_op->m_src = ut_params->ibuf;
2205 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2206 ut_params->ibuf, auth_tag_len);
2208 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2209 "no room to append auth tag");
2210 ut_params->digest = sym_op->auth.digest.data;
2211 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2212 ut_params->ibuf, data_pad_len);
2213 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2214 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2216 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2218 debug_hexdump(stdout, "digest:",
2219 sym_op->auth.digest.data,
2222 /* Copy cipher and auth IVs at the end of the crypto operation */
2223 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2225 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2226 iv_ptr += cipher_iv_len;
2227 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2229 sym_op->cipher.data.length = cipher_len;
2230 sym_op->cipher.data.offset = 0;
2231 sym_op->auth.data.length = auth_len;
2232 sym_op->auth.data.offset = 0;
2238 create_zuc_cipher_hash_generate_operation(
2239 const struct wireless_test_data *tdata)
2241 return create_wireless_cipher_hash_operation(tdata,
2242 RTE_CRYPTO_AUTH_OP_GENERATE);
2246 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2247 const unsigned auth_tag_len,
2248 const uint8_t *auth_iv, uint8_t auth_iv_len,
2249 unsigned data_pad_len,
2250 enum rte_crypto_auth_operation op,
2251 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2252 const unsigned cipher_len, const unsigned cipher_offset,
2253 const unsigned auth_len, const unsigned auth_offset)
2255 struct crypto_testsuite_params *ts_params = &testsuite_params;
2256 struct crypto_unittest_params *ut_params = &unittest_params;
2258 enum rte_crypto_cipher_algorithm cipher_algo =
2259 ut_params->cipher_xform.cipher.algo;
2260 enum rte_crypto_auth_algorithm auth_algo =
2261 ut_params->auth_xform.auth.algo;
2263 /* Generate Crypto op data structure */
2264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2266 TEST_ASSERT_NOT_NULL(ut_params->op,
2267 "Failed to allocate pktmbuf offload");
2268 /* Set crypto operation data parameters */
2269 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2271 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2273 /* set crypto operation source mbuf */
2274 sym_op->m_src = ut_params->ibuf;
2277 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2278 ut_params->ibuf, auth_tag_len);
2280 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2281 "no room to append auth tag");
2282 ut_params->digest = sym_op->auth.digest.data;
2284 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2285 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2286 ut_params->ibuf, data_pad_len);
2288 struct rte_mbuf *m = ut_params->ibuf;
2289 unsigned int offset = data_pad_len;
2291 while (offset > m->data_len && m->next != NULL) {
2292 offset -= m->data_len;
2295 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2299 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2300 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2302 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2304 debug_hexdump(stdout, "digest:",
2305 sym_op->auth.digest.data,
2308 /* Copy cipher and auth IVs at the end of the crypto operation */
2309 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2311 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2312 iv_ptr += cipher_iv_len;
2313 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2315 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2316 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2317 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2318 sym_op->cipher.data.length = cipher_len;
2319 sym_op->cipher.data.offset = cipher_offset;
2321 sym_op->cipher.data.length = cipher_len >> 3;
2322 sym_op->cipher.data.offset = cipher_offset >> 3;
2325 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2326 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2327 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2328 sym_op->auth.data.length = auth_len;
2329 sym_op->auth.data.offset = auth_offset;
2331 sym_op->auth.data.length = auth_len >> 3;
2332 sym_op->auth.data.offset = auth_offset >> 3;
2339 create_wireless_algo_auth_cipher_operation(
2340 const uint8_t *auth_tag, unsigned int auth_tag_len,
2341 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2342 const uint8_t *auth_iv, uint8_t auth_iv_len,
2343 unsigned int data_pad_len,
2344 unsigned int cipher_len, unsigned int cipher_offset,
2345 unsigned int auth_len, unsigned int auth_offset,
2346 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2348 struct crypto_testsuite_params *ts_params = &testsuite_params;
2349 struct crypto_unittest_params *ut_params = &unittest_params;
2351 enum rte_crypto_cipher_algorithm cipher_algo =
2352 ut_params->cipher_xform.cipher.algo;
2353 enum rte_crypto_auth_algorithm auth_algo =
2354 ut_params->auth_xform.auth.algo;
2356 /* Generate Crypto op data structure */
2357 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2358 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2359 TEST_ASSERT_NOT_NULL(ut_params->op,
2360 "Failed to allocate pktmbuf offload");
2362 /* Set crypto operation data parameters */
2363 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2365 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2367 /* set crypto operation mbufs */
2368 sym_op->m_src = ut_params->ibuf;
2369 if (op_mode == OUT_OF_PLACE)
2370 sym_op->m_dst = ut_params->obuf;
2374 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2375 (op_mode == IN_PLACE ?
2376 ut_params->ibuf : ut_params->obuf),
2377 uint8_t *, data_pad_len);
2378 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2379 (op_mode == IN_PLACE ?
2380 ut_params->ibuf : ut_params->obuf),
2382 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2384 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2385 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2386 sym_op->m_src : sym_op->m_dst);
2387 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2388 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2389 sgl_buf = sgl_buf->next;
2391 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2392 uint8_t *, remaining_off);
2393 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2395 memset(sym_op->auth.digest.data, 0, remaining_off);
2396 while (sgl_buf->next != NULL) {
2397 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2398 0, rte_pktmbuf_data_len(sgl_buf));
2399 sgl_buf = sgl_buf->next;
2403 /* Copy digest for the verification */
2405 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2407 /* Copy cipher and auth IVs at the end of the crypto operation */
2408 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2409 ut_params->op, uint8_t *, IV_OFFSET);
2411 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2412 iv_ptr += cipher_iv_len;
2413 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2415 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2416 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2417 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2418 sym_op->cipher.data.length = cipher_len;
2419 sym_op->cipher.data.offset = cipher_offset;
2421 sym_op->cipher.data.length = cipher_len >> 3;
2422 sym_op->cipher.data.offset = cipher_offset >> 3;
2425 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2426 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2427 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2428 sym_op->auth.data.length = auth_len;
2429 sym_op->auth.data.offset = auth_offset;
2431 sym_op->auth.data.length = auth_len >> 3;
2432 sym_op->auth.data.offset = auth_offset >> 3;
2439 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2441 struct crypto_testsuite_params *ts_params = &testsuite_params;
2442 struct crypto_unittest_params *ut_params = &unittest_params;
2445 unsigned plaintext_pad_len;
2446 unsigned plaintext_len;
2448 struct rte_cryptodev_info dev_info;
2450 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2451 uint64_t feat_flags = dev_info.feature_flags;
2453 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2454 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2455 printf("Device doesn't support NON-Byte Aligned Data.\n");
2459 /* Verify the capabilities */
2460 struct rte_cryptodev_sym_capability_idx cap_idx;
2461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2462 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2467 /* Create SNOW 3G session */
2468 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2469 tdata->key.data, tdata->key.len,
2470 tdata->auth_iv.len, tdata->digest.len,
2471 RTE_CRYPTO_AUTH_OP_GENERATE,
2472 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2476 /* alloc mbuf and set payload */
2477 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2479 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2480 rte_pktmbuf_tailroom(ut_params->ibuf));
2482 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2483 /* Append data which is padded to a multiple of */
2484 /* the algorithms block size */
2485 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2486 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2488 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2490 /* Create SNOW 3G operation */
2491 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2492 tdata->auth_iv.data, tdata->auth_iv.len,
2493 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2494 tdata->validAuthLenInBits.len,
2499 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2501 ut_params->obuf = ut_params->op->sym->m_src;
2502 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2503 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2504 + plaintext_pad_len;
2507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2510 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2511 "SNOW 3G Generated auth tag not as expected");
2517 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2519 struct crypto_testsuite_params *ts_params = &testsuite_params;
2520 struct crypto_unittest_params *ut_params = &unittest_params;
2523 unsigned plaintext_pad_len;
2524 unsigned plaintext_len;
2526 struct rte_cryptodev_info dev_info;
2528 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2529 uint64_t feat_flags = dev_info.feature_flags;
2531 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2532 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2533 printf("Device doesn't support NON-Byte Aligned Data.\n");
2537 /* Verify the capabilities */
2538 struct rte_cryptodev_sym_capability_idx cap_idx;
2539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2540 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2541 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2545 /* Create SNOW 3G session */
2546 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2547 tdata->key.data, tdata->key.len,
2548 tdata->auth_iv.len, tdata->digest.len,
2549 RTE_CRYPTO_AUTH_OP_VERIFY,
2550 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2553 /* alloc mbuf and set payload */
2554 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2556 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2557 rte_pktmbuf_tailroom(ut_params->ibuf));
2559 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2560 /* Append data which is padded to a multiple of */
2561 /* the algorithms block size */
2562 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2563 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2565 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2567 /* Create SNOW 3G operation */
2568 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2570 tdata->auth_iv.data, tdata->auth_iv.len,
2572 RTE_CRYPTO_AUTH_OP_VERIFY,
2573 tdata->validAuthLenInBits.len,
2578 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2580 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2581 ut_params->obuf = ut_params->op->sym->m_src;
2582 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2583 + plaintext_pad_len;
2586 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2595 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2597 struct crypto_testsuite_params *ts_params = &testsuite_params;
2598 struct crypto_unittest_params *ut_params = &unittest_params;
2601 unsigned plaintext_pad_len;
2602 unsigned plaintext_len;
2605 /* Verify the capabilities */
2606 struct rte_cryptodev_sym_capability_idx cap_idx;
2607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2608 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2613 /* Create KASUMI session */
2614 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2615 tdata->key.data, tdata->key.len,
2616 0, tdata->digest.len,
2617 RTE_CRYPTO_AUTH_OP_GENERATE,
2618 RTE_CRYPTO_AUTH_KASUMI_F9);
2622 /* alloc mbuf and set payload */
2623 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2625 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2626 rte_pktmbuf_tailroom(ut_params->ibuf));
2628 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2629 /* Append data which is padded to a multiple of */
2630 /* the algorithms block size */
2631 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2632 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2634 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2636 /* Create KASUMI operation */
2637 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2639 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2640 tdata->plaintext.len,
2645 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2646 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2649 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2652 ut_params->obuf = ut_params->op->sym->m_src;
2653 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2654 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2655 + plaintext_pad_len;
2658 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2661 DIGEST_BYTE_LENGTH_KASUMI_F9,
2662 "KASUMI Generated auth tag not as expected");
2668 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2670 struct crypto_testsuite_params *ts_params = &testsuite_params;
2671 struct crypto_unittest_params *ut_params = &unittest_params;
2674 unsigned plaintext_pad_len;
2675 unsigned plaintext_len;
2678 /* Verify the capabilities */
2679 struct rte_cryptodev_sym_capability_idx cap_idx;
2680 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2681 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2682 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2686 /* Create KASUMI session */
2687 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2688 tdata->key.data, tdata->key.len,
2689 0, tdata->digest.len,
2690 RTE_CRYPTO_AUTH_OP_VERIFY,
2691 RTE_CRYPTO_AUTH_KASUMI_F9);
2694 /* alloc mbuf and set payload */
2695 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2698 rte_pktmbuf_tailroom(ut_params->ibuf));
2700 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2701 /* Append data which is padded to a multiple */
2702 /* of the algorithms block size */
2703 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2704 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2706 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2708 /* Create KASUMI operation */
2709 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2713 RTE_CRYPTO_AUTH_OP_VERIFY,
2714 tdata->plaintext.len,
2719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2721 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2722 ut_params->obuf = ut_params->op->sym->m_src;
2723 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2724 + plaintext_pad_len;
2727 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2736 test_snow3g_hash_generate_test_case_1(void)
2738 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2742 test_snow3g_hash_generate_test_case_2(void)
2744 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2748 test_snow3g_hash_generate_test_case_3(void)
2750 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2754 test_snow3g_hash_generate_test_case_4(void)
2756 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2760 test_snow3g_hash_generate_test_case_5(void)
2762 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2766 test_snow3g_hash_generate_test_case_6(void)
2768 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2772 test_snow3g_hash_verify_test_case_1(void)
2774 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2779 test_snow3g_hash_verify_test_case_2(void)
2781 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2785 test_snow3g_hash_verify_test_case_3(void)
2787 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2791 test_snow3g_hash_verify_test_case_4(void)
2793 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2797 test_snow3g_hash_verify_test_case_5(void)
2799 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2803 test_snow3g_hash_verify_test_case_6(void)
2805 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2809 test_kasumi_hash_generate_test_case_1(void)
2811 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2815 test_kasumi_hash_generate_test_case_2(void)
2817 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2821 test_kasumi_hash_generate_test_case_3(void)
2823 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2827 test_kasumi_hash_generate_test_case_4(void)
2829 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2833 test_kasumi_hash_generate_test_case_5(void)
2835 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2839 test_kasumi_hash_generate_test_case_6(void)
2841 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2845 test_kasumi_hash_verify_test_case_1(void)
2847 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2851 test_kasumi_hash_verify_test_case_2(void)
2853 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2857 test_kasumi_hash_verify_test_case_3(void)
2859 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2863 test_kasumi_hash_verify_test_case_4(void)
2865 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2869 test_kasumi_hash_verify_test_case_5(void)
2871 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2875 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2877 struct crypto_testsuite_params *ts_params = &testsuite_params;
2878 struct crypto_unittest_params *ut_params = &unittest_params;
2881 uint8_t *plaintext, *ciphertext;
2882 unsigned plaintext_pad_len;
2883 unsigned plaintext_len;
2885 /* Verify the capabilities */
2886 struct rte_cryptodev_sym_capability_idx cap_idx;
2887 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2888 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2889 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2893 /* Create KASUMI session */
2894 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2895 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2896 RTE_CRYPTO_CIPHER_KASUMI_F8,
2897 tdata->key.data, tdata->key.len,
2898 tdata->cipher_iv.len);
2902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2904 /* Clear mbuf payload */
2905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2906 rte_pktmbuf_tailroom(ut_params->ibuf));
2908 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2909 /* Append data which is padded to a multiple */
2910 /* of the algorithms block size */
2911 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2912 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2914 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2916 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2918 /* Create KASUMI operation */
2919 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2920 tdata->cipher_iv.len,
2921 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2922 tdata->validCipherOffsetInBits.len);
2926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2930 ut_params->obuf = ut_params->op->sym->m_dst;
2931 if (ut_params->obuf)
2932 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2934 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2936 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2938 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2939 (tdata->validCipherOffsetInBits.len >> 3);
2941 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2943 reference_ciphertext,
2944 tdata->validCipherLenInBits.len,
2945 "KASUMI Ciphertext data not as expected");
2950 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2952 struct crypto_testsuite_params *ts_params = &testsuite_params;
2953 struct crypto_unittest_params *ut_params = &unittest_params;
2957 unsigned int plaintext_pad_len;
2958 unsigned int plaintext_len;
2960 uint8_t buffer[10000];
2961 const uint8_t *ciphertext;
2963 struct rte_cryptodev_info dev_info;
2965 /* Verify the capabilities */
2966 struct rte_cryptodev_sym_capability_idx cap_idx;
2967 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2968 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2969 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2973 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2975 uint64_t feat_flags = dev_info.feature_flags;
2977 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2978 printf("Device doesn't support in-place scatter-gather. "
2983 /* Create KASUMI session */
2984 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2985 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2986 RTE_CRYPTO_CIPHER_KASUMI_F8,
2987 tdata->key.data, tdata->key.len,
2988 tdata->cipher_iv.len);
2992 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2995 /* Append data which is padded to a multiple */
2996 /* of the algorithms block size */
2997 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2999 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3000 plaintext_pad_len, 10, 0);
3002 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3004 /* Create KASUMI operation */
3005 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3006 tdata->cipher_iv.len,
3007 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3008 tdata->validCipherOffsetInBits.len);
3012 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3014 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3016 ut_params->obuf = ut_params->op->sym->m_dst;
3018 if (ut_params->obuf)
3019 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3020 plaintext_len, buffer);
3022 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3023 tdata->validCipherOffsetInBits.len >> 3,
3024 plaintext_len, buffer);
3027 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3029 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3030 (tdata->validCipherOffsetInBits.len >> 3);
3032 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3034 reference_ciphertext,
3035 tdata->validCipherLenInBits.len,
3036 "KASUMI Ciphertext data not as expected");
3041 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3043 struct crypto_testsuite_params *ts_params = &testsuite_params;
3044 struct crypto_unittest_params *ut_params = &unittest_params;
3047 uint8_t *plaintext, *ciphertext;
3048 unsigned plaintext_pad_len;
3049 unsigned plaintext_len;
3051 /* Verify the capabilities */
3052 struct rte_cryptodev_sym_capability_idx cap_idx;
3053 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3054 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3055 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3059 /* Create KASUMI session */
3060 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3061 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3062 RTE_CRYPTO_CIPHER_KASUMI_F8,
3063 tdata->key.data, tdata->key.len,
3064 tdata->cipher_iv.len);
3068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3069 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3071 /* Clear mbuf payload */
3072 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3073 rte_pktmbuf_tailroom(ut_params->ibuf));
3075 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3076 /* Append data which is padded to a multiple */
3077 /* of the algorithms block size */
3078 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3079 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3081 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3082 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3084 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3086 /* Create KASUMI operation */
3087 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3088 tdata->cipher_iv.len,
3089 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3090 tdata->validCipherOffsetInBits.len);
3094 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3096 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3098 ut_params->obuf = ut_params->op->sym->m_dst;
3099 if (ut_params->obuf)
3100 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3102 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3104 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3106 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3107 (tdata->validCipherOffsetInBits.len >> 3);
3109 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3111 reference_ciphertext,
3112 tdata->validCipherLenInBits.len,
3113 "KASUMI Ciphertext data not as expected");
3118 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3120 struct crypto_testsuite_params *ts_params = &testsuite_params;
3121 struct crypto_unittest_params *ut_params = &unittest_params;
3124 unsigned int plaintext_pad_len;
3125 unsigned int plaintext_len;
3127 const uint8_t *ciphertext;
3128 uint8_t buffer[2048];
3130 struct rte_cryptodev_info dev_info;
3132 /* Verify the capabilities */
3133 struct rte_cryptodev_sym_capability_idx cap_idx;
3134 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3135 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3136 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3142 uint64_t feat_flags = dev_info.feature_flags;
3143 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3144 printf("Device doesn't support out-of-place scatter-gather "
3145 "in both input and output mbufs. "
3150 /* Create KASUMI session */
3151 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3152 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3153 RTE_CRYPTO_CIPHER_KASUMI_F8,
3154 tdata->key.data, tdata->key.len,
3155 tdata->cipher_iv.len);
3159 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3160 /* Append data which is padded to a multiple */
3161 /* of the algorithms block size */
3162 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3164 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3165 plaintext_pad_len, 10, 0);
3166 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3167 plaintext_pad_len, 3, 0);
3169 /* Append data which is padded to a multiple */
3170 /* of the algorithms block size */
3171 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3173 /* Create KASUMI operation */
3174 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3175 tdata->cipher_iv.len,
3176 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3177 tdata->validCipherOffsetInBits.len);
3181 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3183 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3185 ut_params->obuf = ut_params->op->sym->m_dst;
3186 if (ut_params->obuf)
3187 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3188 plaintext_pad_len, buffer);
3190 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3191 tdata->validCipherOffsetInBits.len >> 3,
3192 plaintext_pad_len, buffer);
3194 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3195 (tdata->validCipherOffsetInBits.len >> 3);
3197 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3199 reference_ciphertext,
3200 tdata->validCipherLenInBits.len,
3201 "KASUMI Ciphertext data not as expected");
3207 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3209 struct crypto_testsuite_params *ts_params = &testsuite_params;
3210 struct crypto_unittest_params *ut_params = &unittest_params;
3213 uint8_t *ciphertext, *plaintext;
3214 unsigned ciphertext_pad_len;
3215 unsigned ciphertext_len;
3217 /* Verify the capabilities */
3218 struct rte_cryptodev_sym_capability_idx cap_idx;
3219 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3220 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3221 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3225 /* Create KASUMI session */
3226 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3227 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3228 RTE_CRYPTO_CIPHER_KASUMI_F8,
3229 tdata->key.data, tdata->key.len,
3230 tdata->cipher_iv.len);
3234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3235 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3237 /* Clear mbuf payload */
3238 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3239 rte_pktmbuf_tailroom(ut_params->ibuf));
3241 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3242 /* Append data which is padded to a multiple */
3243 /* of the algorithms block size */
3244 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3245 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3246 ciphertext_pad_len);
3247 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3248 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3250 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3252 /* Create KASUMI operation */
3253 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3254 tdata->cipher_iv.len,
3255 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3256 tdata->validCipherOffsetInBits.len);
3260 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3264 ut_params->obuf = ut_params->op->sym->m_dst;
3265 if (ut_params->obuf)
3266 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3268 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3270 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3272 const uint8_t *reference_plaintext = tdata->plaintext.data +
3273 (tdata->validCipherOffsetInBits.len >> 3);
3275 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3277 reference_plaintext,
3278 tdata->validCipherLenInBits.len,
3279 "KASUMI Plaintext data not as expected");
3284 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3286 struct crypto_testsuite_params *ts_params = &testsuite_params;
3287 struct crypto_unittest_params *ut_params = &unittest_params;
3290 uint8_t *ciphertext, *plaintext;
3291 unsigned ciphertext_pad_len;
3292 unsigned ciphertext_len;
3294 /* Verify the capabilities */
3295 struct rte_cryptodev_sym_capability_idx cap_idx;
3296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3297 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3302 /* Create KASUMI session */
3303 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3304 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3305 RTE_CRYPTO_CIPHER_KASUMI_F8,
3306 tdata->key.data, tdata->key.len,
3307 tdata->cipher_iv.len);
3311 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3313 /* Clear mbuf payload */
3314 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3315 rte_pktmbuf_tailroom(ut_params->ibuf));
3317 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3318 /* Append data which is padded to a multiple */
3319 /* of the algorithms block size */
3320 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3321 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3322 ciphertext_pad_len);
3323 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3325 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3327 /* Create KASUMI operation */
3328 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3329 tdata->cipher_iv.len,
3330 tdata->ciphertext.len,
3331 tdata->validCipherOffsetInBits.len);
3335 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3337 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3339 ut_params->obuf = ut_params->op->sym->m_dst;
3340 if (ut_params->obuf)
3341 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3343 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3345 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3347 const uint8_t *reference_plaintext = tdata->plaintext.data +
3348 (tdata->validCipherOffsetInBits.len >> 3);
3350 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3352 reference_plaintext,
3353 tdata->validCipherLenInBits.len,
3354 "KASUMI Plaintext data not as expected");
3359 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3361 struct crypto_testsuite_params *ts_params = &testsuite_params;
3362 struct crypto_unittest_params *ut_params = &unittest_params;
3365 uint8_t *plaintext, *ciphertext;
3366 unsigned plaintext_pad_len;
3367 unsigned plaintext_len;
3369 /* Verify the capabilities */
3370 struct rte_cryptodev_sym_capability_idx cap_idx;
3371 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3372 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3373 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3377 /* Create SNOW 3G session */
3378 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3379 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3380 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3381 tdata->key.data, tdata->key.len,
3382 tdata->cipher_iv.len);
3386 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3388 /* Clear mbuf payload */
3389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3390 rte_pktmbuf_tailroom(ut_params->ibuf));
3392 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3393 /* Append data which is padded to a multiple of */
3394 /* the algorithms block size */
3395 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3396 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3398 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3400 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3402 /* Create SNOW 3G operation */
3403 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3404 tdata->cipher_iv.len,
3405 tdata->validCipherLenInBits.len,
3410 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3412 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3414 ut_params->obuf = ut_params->op->sym->m_dst;
3415 if (ut_params->obuf)
3416 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3418 ciphertext = plaintext;
3420 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3423 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3425 tdata->ciphertext.data,
3426 tdata->validDataLenInBits.len,
3427 "SNOW 3G Ciphertext data not as expected");
3433 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3435 struct crypto_testsuite_params *ts_params = &testsuite_params;
3436 struct crypto_unittest_params *ut_params = &unittest_params;
3437 uint8_t *plaintext, *ciphertext;
3440 unsigned plaintext_pad_len;
3441 unsigned plaintext_len;
3443 /* Verify the capabilities */
3444 struct rte_cryptodev_sym_capability_idx cap_idx;
3445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3446 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3451 /* Create SNOW 3G session */
3452 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3453 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3454 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3455 tdata->key.data, tdata->key.len,
3456 tdata->cipher_iv.len);
3460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3461 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3463 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3464 "Failed to allocate input buffer in mempool");
3465 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3466 "Failed to allocate output buffer in mempool");
3468 /* Clear mbuf payload */
3469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3470 rte_pktmbuf_tailroom(ut_params->ibuf));
3472 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3473 /* Append data which is padded to a multiple of */
3474 /* the algorithms block size */
3475 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3476 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3478 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3479 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3481 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3483 /* Create SNOW 3G operation */
3484 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3485 tdata->cipher_iv.len,
3486 tdata->validCipherLenInBits.len,
3491 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3495 ut_params->obuf = ut_params->op->sym->m_dst;
3496 if (ut_params->obuf)
3497 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3499 ciphertext = plaintext;
3501 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3504 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3506 tdata->ciphertext.data,
3507 tdata->validDataLenInBits.len,
3508 "SNOW 3G Ciphertext data not as expected");
3513 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3515 struct crypto_testsuite_params *ts_params = &testsuite_params;
3516 struct crypto_unittest_params *ut_params = &unittest_params;
3519 unsigned int plaintext_pad_len;
3520 unsigned int plaintext_len;
3521 uint8_t buffer[10000];
3522 const uint8_t *ciphertext;
3524 struct rte_cryptodev_info dev_info;
3526 /* Verify the capabilities */
3527 struct rte_cryptodev_sym_capability_idx cap_idx;
3528 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3529 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3530 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3534 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3536 uint64_t feat_flags = dev_info.feature_flags;
3538 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3539 printf("Device doesn't support out-of-place scatter-gather "
3540 "in both input and output mbufs. "
3545 /* Create SNOW 3G session */
3546 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3547 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3548 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3549 tdata->key.data, tdata->key.len,
3550 tdata->cipher_iv.len);
3554 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3555 /* Append data which is padded to a multiple of */
3556 /* the algorithms block size */
3557 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3559 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3560 plaintext_pad_len, 10, 0);
3561 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3562 plaintext_pad_len, 3, 0);
3564 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3565 "Failed to allocate input buffer in mempool");
3566 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3567 "Failed to allocate output buffer in mempool");
3569 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3571 /* Create SNOW 3G operation */
3572 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3573 tdata->cipher_iv.len,
3574 tdata->validCipherLenInBits.len,
3579 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3581 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3583 ut_params->obuf = ut_params->op->sym->m_dst;
3584 if (ut_params->obuf)
3585 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3586 plaintext_len, buffer);
3588 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3589 plaintext_len, buffer);
3591 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3594 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3596 tdata->ciphertext.data,
3597 tdata->validDataLenInBits.len,
3598 "SNOW 3G Ciphertext data not as expected");
3603 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3605 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3607 uint8_t curr_byte, prev_byte;
3608 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3609 uint8_t lower_byte_mask = (1 << offset) - 1;
3612 prev_byte = buffer[0];
3613 buffer[0] >>= offset;
3615 for (i = 1; i < length_in_bytes; i++) {
3616 curr_byte = buffer[i];
3617 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3618 (curr_byte >> offset);
3619 prev_byte = curr_byte;
3624 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3626 struct crypto_testsuite_params *ts_params = &testsuite_params;
3627 struct crypto_unittest_params *ut_params = &unittest_params;
3628 uint8_t *plaintext, *ciphertext;
3630 uint32_t plaintext_len;
3631 uint32_t plaintext_pad_len;
3632 uint8_t extra_offset = 4;
3633 uint8_t *expected_ciphertext_shifted;
3634 struct rte_cryptodev_info dev_info;
3636 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3637 uint64_t feat_flags = dev_info.feature_flags;
3639 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3640 ((tdata->validDataLenInBits.len % 8) != 0)) {
3641 printf("Device doesn't support NON-Byte Aligned Data.\n");
3645 /* Verify the capabilities */
3646 struct rte_cryptodev_sym_capability_idx cap_idx;
3647 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3648 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3649 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3653 /* Create SNOW 3G session */
3654 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3655 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3656 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3657 tdata->key.data, tdata->key.len,
3658 tdata->cipher_iv.len);
3662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3663 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3665 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3666 "Failed to allocate input buffer in mempool");
3667 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3668 "Failed to allocate output buffer in mempool");
3670 /* Clear mbuf payload */
3671 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3672 rte_pktmbuf_tailroom(ut_params->ibuf));
3674 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3676 * Append data which is padded to a
3677 * multiple of the algorithms block size
3679 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3681 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3684 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3686 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3687 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3689 #ifdef RTE_APP_TEST_DEBUG
3690 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3692 /* Create SNOW 3G operation */
3693 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3694 tdata->cipher_iv.len,
3695 tdata->validCipherLenInBits.len,
3700 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3702 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3704 ut_params->obuf = ut_params->op->sym->m_dst;
3705 if (ut_params->obuf)
3706 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3708 ciphertext = plaintext;
3710 #ifdef RTE_APP_TEST_DEBUG
3711 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3714 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3716 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3717 "failed to reserve memory for ciphertext shifted\n");
3719 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3720 ceil_byte_length(tdata->ciphertext.len));
3721 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3726 expected_ciphertext_shifted,
3727 tdata->validDataLenInBits.len,
3729 "SNOW 3G Ciphertext data not as expected");
3733 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3735 struct crypto_testsuite_params *ts_params = &testsuite_params;
3736 struct crypto_unittest_params *ut_params = &unittest_params;
3740 uint8_t *plaintext, *ciphertext;
3741 unsigned ciphertext_pad_len;
3742 unsigned ciphertext_len;
3744 /* Verify the capabilities */
3745 struct rte_cryptodev_sym_capability_idx cap_idx;
3746 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3747 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3748 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3752 /* Create SNOW 3G session */
3753 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3754 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3755 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3756 tdata->key.data, tdata->key.len,
3757 tdata->cipher_iv.len);
3761 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3763 /* Clear mbuf payload */
3764 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3765 rte_pktmbuf_tailroom(ut_params->ibuf));
3767 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3768 /* Append data which is padded to a multiple of */
3769 /* the algorithms block size */
3770 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3771 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3772 ciphertext_pad_len);
3773 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3775 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3777 /* Create SNOW 3G operation */
3778 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3779 tdata->cipher_iv.len,
3780 tdata->validCipherLenInBits.len,
3781 tdata->cipher.offset_bits);
3785 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3787 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3788 ut_params->obuf = ut_params->op->sym->m_dst;
3789 if (ut_params->obuf)
3790 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3792 plaintext = ciphertext;
3794 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3797 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3798 tdata->plaintext.data,
3799 tdata->validDataLenInBits.len,
3800 "SNOW 3G Plaintext data not as expected");
3804 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3806 struct crypto_testsuite_params *ts_params = &testsuite_params;
3807 struct crypto_unittest_params *ut_params = &unittest_params;
3811 uint8_t *plaintext, *ciphertext;
3812 unsigned ciphertext_pad_len;
3813 unsigned ciphertext_len;
3815 /* Verify the capabilities */
3816 struct rte_cryptodev_sym_capability_idx cap_idx;
3817 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3818 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3819 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3823 /* Create SNOW 3G session */
3824 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3825 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3826 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3827 tdata->key.data, tdata->key.len,
3828 tdata->cipher_iv.len);
3832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3833 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3835 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3836 "Failed to allocate input buffer");
3837 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3838 "Failed to allocate output buffer");
3840 /* Clear mbuf payload */
3841 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3842 rte_pktmbuf_tailroom(ut_params->ibuf));
3844 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3845 rte_pktmbuf_tailroom(ut_params->obuf));
3847 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3848 /* Append data which is padded to a multiple of */
3849 /* the algorithms block size */
3850 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3851 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3852 ciphertext_pad_len);
3853 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3854 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3856 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3858 /* Create SNOW 3G operation */
3859 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3860 tdata->cipher_iv.len,
3861 tdata->validCipherLenInBits.len,
3866 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3868 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3869 ut_params->obuf = ut_params->op->sym->m_dst;
3870 if (ut_params->obuf)
3871 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3873 plaintext = ciphertext;
3875 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3878 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3879 tdata->plaintext.data,
3880 tdata->validDataLenInBits.len,
3881 "SNOW 3G Plaintext data not as expected");
3886 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3888 struct crypto_testsuite_params *ts_params = &testsuite_params;
3889 struct crypto_unittest_params *ut_params = &unittest_params;
3893 uint8_t *plaintext, *ciphertext;
3894 unsigned int plaintext_pad_len;
3895 unsigned int plaintext_len;
3897 struct rte_cryptodev_info dev_info;
3898 struct rte_cryptodev_sym_capability_idx cap_idx;
3900 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3901 uint64_t feat_flags = dev_info.feature_flags;
3903 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3904 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3905 (tdata->validDataLenInBits.len % 8 != 0))) {
3906 printf("Device doesn't support NON-Byte Aligned Data.\n");
3910 /* Check if device supports ZUC EEA3 */
3911 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3912 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3914 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3918 /* Check if device supports ZUC EIA3 */
3919 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3920 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3926 /* Create ZUC session */
3927 retval = create_zuc_cipher_auth_encrypt_generate_session(
3928 ts_params->valid_devs[0],
3932 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3934 /* clear mbuf payload */
3935 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3936 rte_pktmbuf_tailroom(ut_params->ibuf));
3938 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3939 /* Append data which is padded to a multiple of */
3940 /* the algorithms block size */
3941 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3942 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3944 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3946 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3948 /* Create ZUC operation */
3949 retval = create_zuc_cipher_hash_generate_operation(tdata);
3953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3956 ut_params->obuf = ut_params->op->sym->m_src;
3957 if (ut_params->obuf)
3958 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3960 ciphertext = plaintext;
3962 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3964 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3966 tdata->ciphertext.data,
3967 tdata->validDataLenInBits.len,
3968 "ZUC Ciphertext data not as expected");
3970 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3971 + plaintext_pad_len;
3974 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3978 "ZUC Generated auth tag not as expected");
3983 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3985 struct crypto_testsuite_params *ts_params = &testsuite_params;
3986 struct crypto_unittest_params *ut_params = &unittest_params;
3990 uint8_t *plaintext, *ciphertext;
3991 unsigned plaintext_pad_len;
3992 unsigned plaintext_len;
3994 /* Verify the capabilities */
3995 struct rte_cryptodev_sym_capability_idx cap_idx;
3996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3997 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3998 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4001 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4002 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4003 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4007 /* Create SNOW 3G session */
4008 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4009 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4010 RTE_CRYPTO_AUTH_OP_GENERATE,
4011 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4012 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4013 tdata->key.data, tdata->key.len,
4014 tdata->auth_iv.len, tdata->digest.len,
4015 tdata->cipher_iv.len);
4018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4020 /* clear mbuf payload */
4021 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022 rte_pktmbuf_tailroom(ut_params->ibuf));
4024 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4025 /* Append data which is padded to a multiple of */
4026 /* the algorithms block size */
4027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4028 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4030 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4032 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4034 /* Create SNOW 3G operation */
4035 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4036 tdata->digest.len, tdata->auth_iv.data,
4038 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4039 tdata->cipher_iv.data, tdata->cipher_iv.len,
4040 tdata->validCipherLenInBits.len,
4042 tdata->validAuthLenInBits.len,
4048 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4050 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4051 ut_params->obuf = ut_params->op->sym->m_src;
4052 if (ut_params->obuf)
4053 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4055 ciphertext = plaintext;
4057 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4059 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4061 tdata->ciphertext.data,
4062 tdata->validDataLenInBits.len,
4063 "SNOW 3G Ciphertext data not as expected");
4065 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4066 + plaintext_pad_len;
4069 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4072 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4073 "SNOW 3G Generated auth tag not as expected");
4078 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4079 uint8_t op_mode, uint8_t verify)
4081 struct crypto_testsuite_params *ts_params = &testsuite_params;
4082 struct crypto_unittest_params *ut_params = &unittest_params;
4086 uint8_t *plaintext = NULL, *ciphertext = NULL;
4087 unsigned int plaintext_pad_len;
4088 unsigned int plaintext_len;
4089 unsigned int ciphertext_pad_len;
4090 unsigned int ciphertext_len;
4092 struct rte_cryptodev_info dev_info;
4094 /* Verify the capabilities */
4095 struct rte_cryptodev_sym_capability_idx cap_idx;
4096 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4097 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4098 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4101 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4102 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4103 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4107 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4109 uint64_t feat_flags = dev_info.feature_flags;
4111 if (op_mode == OUT_OF_PLACE) {
4112 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4113 printf("Device doesn't support digest encrypted.\n");
4118 /* Create SNOW 3G session */
4119 retval = create_wireless_algo_auth_cipher_session(
4120 ts_params->valid_devs[0],
4121 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4122 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4123 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4124 : RTE_CRYPTO_AUTH_OP_GENERATE),
4125 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4126 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4127 tdata->key.data, tdata->key.len,
4128 tdata->auth_iv.len, tdata->digest.len,
4129 tdata->cipher_iv.len);
4134 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4135 if (op_mode == OUT_OF_PLACE)
4136 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4138 /* clear mbuf payload */
4139 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4140 rte_pktmbuf_tailroom(ut_params->ibuf));
4141 if (op_mode == OUT_OF_PLACE)
4142 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4143 rte_pktmbuf_tailroom(ut_params->obuf));
4145 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4146 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4147 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4148 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4151 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4152 ciphertext_pad_len);
4153 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4154 if (op_mode == OUT_OF_PLACE)
4155 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4156 debug_hexdump(stdout, "ciphertext:", ciphertext,
4159 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4161 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4162 if (op_mode == OUT_OF_PLACE)
4163 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4164 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4167 /* Create SNOW 3G operation */
4168 retval = create_wireless_algo_auth_cipher_operation(
4169 tdata->digest.data, tdata->digest.len,
4170 tdata->cipher_iv.data, tdata->cipher_iv.len,
4171 tdata->auth_iv.data, tdata->auth_iv.len,
4172 (tdata->digest.offset_bytes == 0 ?
4173 (verify ? ciphertext_pad_len : plaintext_pad_len)
4174 : tdata->digest.offset_bytes),
4175 tdata->validCipherLenInBits.len,
4176 tdata->cipher.offset_bits,
4177 tdata->validAuthLenInBits.len,
4178 tdata->auth.offset_bits,
4179 op_mode, 0, verify);
4184 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4189 ut_params->obuf = (op_mode == IN_PLACE ?
4190 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4193 if (ut_params->obuf)
4194 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4197 plaintext = ciphertext +
4198 (tdata->cipher.offset_bits >> 3);
4200 debug_hexdump(stdout, "plaintext:", plaintext,
4201 (tdata->plaintext.len >> 3) - tdata->digest.len);
4202 debug_hexdump(stdout, "plaintext expected:",
4203 tdata->plaintext.data,
4204 (tdata->plaintext.len >> 3) - tdata->digest.len);
4206 if (ut_params->obuf)
4207 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4210 ciphertext = plaintext;
4212 debug_hexdump(stdout, "ciphertext:", ciphertext,
4214 debug_hexdump(stdout, "ciphertext expected:",
4215 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4217 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4218 + (tdata->digest.offset_bytes == 0 ?
4219 plaintext_pad_len : tdata->digest.offset_bytes);
4221 debug_hexdump(stdout, "digest:", ut_params->digest,
4223 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4229 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4231 tdata->plaintext.data,
4232 tdata->plaintext.len >> 3,
4233 "SNOW 3G Plaintext data not as expected");
4235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4237 tdata->ciphertext.data,
4238 tdata->validDataLenInBits.len,
4239 "SNOW 3G Ciphertext data not as expected");
4241 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4244 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4245 "SNOW 3G Generated auth tag not as expected");
4251 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4252 uint8_t op_mode, uint8_t verify)
4254 struct crypto_testsuite_params *ts_params = &testsuite_params;
4255 struct crypto_unittest_params *ut_params = &unittest_params;
4259 const uint8_t *plaintext = NULL;
4260 const uint8_t *ciphertext = NULL;
4261 const uint8_t *digest = NULL;
4262 unsigned int plaintext_pad_len;
4263 unsigned int plaintext_len;
4264 unsigned int ciphertext_pad_len;
4265 unsigned int ciphertext_len;
4266 uint8_t buffer[10000];
4267 uint8_t digest_buffer[10000];
4269 struct rte_cryptodev_info dev_info;
4271 /* Verify the capabilities */
4272 struct rte_cryptodev_sym_capability_idx cap_idx;
4273 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4274 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4275 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4279 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4280 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4284 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4286 uint64_t feat_flags = dev_info.feature_flags;
4288 if (op_mode == IN_PLACE) {
4289 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4290 printf("Device doesn't support in-place scatter-gather "
4291 "in both input and output mbufs.\n");
4295 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4296 printf("Device doesn't support out-of-place scatter-gather "
4297 "in both input and output mbufs.\n");
4300 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4301 printf("Device doesn't support digest encrypted.\n");
4306 /* Create SNOW 3G session */
4307 retval = create_wireless_algo_auth_cipher_session(
4308 ts_params->valid_devs[0],
4309 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4310 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4311 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4312 : RTE_CRYPTO_AUTH_OP_GENERATE),
4313 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4314 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4315 tdata->key.data, tdata->key.len,
4316 tdata->auth_iv.len, tdata->digest.len,
4317 tdata->cipher_iv.len);
4322 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4323 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4324 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4325 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4327 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4328 plaintext_pad_len, 15, 0);
4329 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4330 "Failed to allocate input buffer in mempool");
4332 if (op_mode == OUT_OF_PLACE) {
4333 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4334 plaintext_pad_len, 15, 0);
4335 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4336 "Failed to allocate output buffer in mempool");
4340 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4341 tdata->ciphertext.data);
4342 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4343 ciphertext_len, buffer);
4344 debug_hexdump(stdout, "ciphertext:", ciphertext,
4347 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4348 tdata->plaintext.data);
4349 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4350 plaintext_len, buffer);
4351 debug_hexdump(stdout, "plaintext:", plaintext,
4354 memset(buffer, 0, sizeof(buffer));
4356 /* Create SNOW 3G operation */
4357 retval = create_wireless_algo_auth_cipher_operation(
4358 tdata->digest.data, tdata->digest.len,
4359 tdata->cipher_iv.data, tdata->cipher_iv.len,
4360 tdata->auth_iv.data, tdata->auth_iv.len,
4361 (tdata->digest.offset_bytes == 0 ?
4362 (verify ? ciphertext_pad_len : plaintext_pad_len)
4363 : tdata->digest.offset_bytes),
4364 tdata->validCipherLenInBits.len,
4365 tdata->cipher.offset_bits,
4366 tdata->validAuthLenInBits.len,
4367 tdata->auth.offset_bits,
4368 op_mode, 1, verify);
4373 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4376 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4378 ut_params->obuf = (op_mode == IN_PLACE ?
4379 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4382 if (ut_params->obuf)
4383 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4384 plaintext_len, buffer);
4386 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4387 plaintext_len, buffer);
4389 debug_hexdump(stdout, "plaintext:", plaintext,
4390 (tdata->plaintext.len >> 3) - tdata->digest.len);
4391 debug_hexdump(stdout, "plaintext expected:",
4392 tdata->plaintext.data,
4393 (tdata->plaintext.len >> 3) - tdata->digest.len);
4395 if (ut_params->obuf)
4396 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4397 ciphertext_len, buffer);
4399 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4400 ciphertext_len, buffer);
4402 debug_hexdump(stdout, "ciphertext:", ciphertext,
4404 debug_hexdump(stdout, "ciphertext expected:",
4405 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4407 if (ut_params->obuf)
4408 digest = rte_pktmbuf_read(ut_params->obuf,
4409 (tdata->digest.offset_bytes == 0 ?
4410 plaintext_pad_len : tdata->digest.offset_bytes),
4411 tdata->digest.len, digest_buffer);
4413 digest = rte_pktmbuf_read(ut_params->ibuf,
4414 (tdata->digest.offset_bytes == 0 ?
4415 plaintext_pad_len : tdata->digest.offset_bytes),
4416 tdata->digest.len, digest_buffer);
4418 debug_hexdump(stdout, "digest:", digest,
4420 debug_hexdump(stdout, "digest expected:",
4421 tdata->digest.data, tdata->digest.len);
4426 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4428 tdata->plaintext.data,
4429 tdata->plaintext.len >> 3,
4430 "SNOW 3G Plaintext data not as expected");
4432 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4434 tdata->ciphertext.data,
4435 tdata->validDataLenInBits.len,
4436 "SNOW 3G Ciphertext data not as expected");
4438 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4441 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4442 "SNOW 3G Generated auth tag not as expected");
4448 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4449 uint8_t op_mode, uint8_t verify)
4451 struct crypto_testsuite_params *ts_params = &testsuite_params;
4452 struct crypto_unittest_params *ut_params = &unittest_params;
4456 uint8_t *plaintext = NULL, *ciphertext = NULL;
4457 unsigned int plaintext_pad_len;
4458 unsigned int plaintext_len;
4459 unsigned int ciphertext_pad_len;
4460 unsigned int ciphertext_len;
4462 struct rte_cryptodev_info dev_info;
4464 /* Verify the capabilities */
4465 struct rte_cryptodev_sym_capability_idx cap_idx;
4466 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4467 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4468 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4472 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4477 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4479 uint64_t feat_flags = dev_info.feature_flags;
4481 if (op_mode == OUT_OF_PLACE) {
4482 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4483 printf("Device doesn't support digest encrypted.\n");
4488 /* Create KASUMI session */
4489 retval = create_wireless_algo_auth_cipher_session(
4490 ts_params->valid_devs[0],
4491 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4492 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4493 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4494 : RTE_CRYPTO_AUTH_OP_GENERATE),
4495 RTE_CRYPTO_AUTH_KASUMI_F9,
4496 RTE_CRYPTO_CIPHER_KASUMI_F8,
4497 tdata->key.data, tdata->key.len,
4498 0, tdata->digest.len,
4499 tdata->cipher_iv.len);
4504 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4505 if (op_mode == OUT_OF_PLACE)
4506 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4508 /* clear mbuf payload */
4509 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4510 rte_pktmbuf_tailroom(ut_params->ibuf));
4511 if (op_mode == OUT_OF_PLACE)
4512 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4513 rte_pktmbuf_tailroom(ut_params->obuf));
4515 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4516 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4517 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4518 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4521 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4522 ciphertext_pad_len);
4523 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4524 if (op_mode == OUT_OF_PLACE)
4525 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4526 debug_hexdump(stdout, "ciphertext:", ciphertext,
4529 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4531 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4532 if (op_mode == OUT_OF_PLACE)
4533 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4534 debug_hexdump(stdout, "plaintext:", plaintext,
4538 /* Create KASUMI operation */
4539 retval = create_wireless_algo_auth_cipher_operation(
4540 tdata->digest.data, tdata->digest.len,
4541 tdata->cipher_iv.data, tdata->cipher_iv.len,
4543 (tdata->digest.offset_bytes == 0 ?
4544 (verify ? ciphertext_pad_len : plaintext_pad_len)
4545 : tdata->digest.offset_bytes),
4546 tdata->validCipherLenInBits.len,
4547 tdata->validCipherOffsetInBits.len,
4548 tdata->validAuthLenInBits.len,
4550 op_mode, 0, verify);
4555 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4558 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4560 ut_params->obuf = (op_mode == IN_PLACE ?
4561 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4565 if (ut_params->obuf)
4566 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4569 plaintext = ciphertext;
4571 debug_hexdump(stdout, "plaintext:", plaintext,
4572 (tdata->plaintext.len >> 3) - tdata->digest.len);
4573 debug_hexdump(stdout, "plaintext expected:",
4574 tdata->plaintext.data,
4575 (tdata->plaintext.len >> 3) - tdata->digest.len);
4577 if (ut_params->obuf)
4578 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4581 ciphertext = plaintext;
4583 debug_hexdump(stdout, "ciphertext:", ciphertext,
4585 debug_hexdump(stdout, "ciphertext expected:",
4586 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4588 ut_params->digest = rte_pktmbuf_mtod(
4589 ut_params->obuf, uint8_t *) +
4590 (tdata->digest.offset_bytes == 0 ?
4591 plaintext_pad_len : tdata->digest.offset_bytes);
4593 debug_hexdump(stdout, "digest:", ut_params->digest,
4595 debug_hexdump(stdout, "digest expected:",
4596 tdata->digest.data, tdata->digest.len);
4601 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4603 tdata->plaintext.data,
4604 tdata->plaintext.len >> 3,
4605 "KASUMI Plaintext data not as expected");
4607 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4609 tdata->ciphertext.data,
4610 tdata->ciphertext.len >> 3,
4611 "KASUMI Ciphertext data not as expected");
4613 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4616 DIGEST_BYTE_LENGTH_KASUMI_F9,
4617 "KASUMI Generated auth tag not as expected");
4623 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4624 uint8_t op_mode, uint8_t verify)
4626 struct crypto_testsuite_params *ts_params = &testsuite_params;
4627 struct crypto_unittest_params *ut_params = &unittest_params;
4631 const uint8_t *plaintext = NULL;
4632 const uint8_t *ciphertext = NULL;
4633 const uint8_t *digest = NULL;
4634 unsigned int plaintext_pad_len;
4635 unsigned int plaintext_len;
4636 unsigned int ciphertext_pad_len;
4637 unsigned int ciphertext_len;
4638 uint8_t buffer[10000];
4639 uint8_t digest_buffer[10000];
4641 struct rte_cryptodev_info dev_info;
4643 /* Verify the capabilities */
4644 struct rte_cryptodev_sym_capability_idx cap_idx;
4645 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4646 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4647 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4650 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4651 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4652 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4656 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4658 uint64_t feat_flags = dev_info.feature_flags;
4660 if (op_mode == IN_PLACE) {
4661 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4662 printf("Device doesn't support in-place scatter-gather "
4663 "in both input and output mbufs.\n");
4667 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4668 printf("Device doesn't support out-of-place scatter-gather "
4669 "in both input and output mbufs.\n");
4672 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4673 printf("Device doesn't support digest encrypted.\n");
4678 /* Create KASUMI session */
4679 retval = create_wireless_algo_auth_cipher_session(
4680 ts_params->valid_devs[0],
4681 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4682 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4683 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4684 : RTE_CRYPTO_AUTH_OP_GENERATE),
4685 RTE_CRYPTO_AUTH_KASUMI_F9,
4686 RTE_CRYPTO_CIPHER_KASUMI_F8,
4687 tdata->key.data, tdata->key.len,
4688 0, tdata->digest.len,
4689 tdata->cipher_iv.len);
4694 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4695 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4696 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4697 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4699 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4700 plaintext_pad_len, 15, 0);
4701 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4702 "Failed to allocate input buffer in mempool");
4704 if (op_mode == OUT_OF_PLACE) {
4705 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4706 plaintext_pad_len, 15, 0);
4707 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4708 "Failed to allocate output buffer in mempool");
4712 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4713 tdata->ciphertext.data);
4714 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4715 ciphertext_len, buffer);
4716 debug_hexdump(stdout, "ciphertext:", ciphertext,
4719 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4720 tdata->plaintext.data);
4721 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4722 plaintext_len, buffer);
4723 debug_hexdump(stdout, "plaintext:", plaintext,
4726 memset(buffer, 0, sizeof(buffer));
4728 /* Create KASUMI operation */
4729 retval = create_wireless_algo_auth_cipher_operation(
4730 tdata->digest.data, tdata->digest.len,
4731 tdata->cipher_iv.data, tdata->cipher_iv.len,
4733 (tdata->digest.offset_bytes == 0 ?
4734 (verify ? ciphertext_pad_len : plaintext_pad_len)
4735 : tdata->digest.offset_bytes),
4736 tdata->validCipherLenInBits.len,
4737 tdata->validCipherOffsetInBits.len,
4738 tdata->validAuthLenInBits.len,
4740 op_mode, 1, verify);
4745 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4748 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4750 ut_params->obuf = (op_mode == IN_PLACE ?
4751 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4754 if (ut_params->obuf)
4755 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4756 plaintext_len, buffer);
4758 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4759 plaintext_len, buffer);
4761 debug_hexdump(stdout, "plaintext:", plaintext,
4762 (tdata->plaintext.len >> 3) - tdata->digest.len);
4763 debug_hexdump(stdout, "plaintext expected:",
4764 tdata->plaintext.data,
4765 (tdata->plaintext.len >> 3) - tdata->digest.len);
4767 if (ut_params->obuf)
4768 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4769 ciphertext_len, buffer);
4771 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4772 ciphertext_len, buffer);
4774 debug_hexdump(stdout, "ciphertext:", ciphertext,
4776 debug_hexdump(stdout, "ciphertext expected:",
4777 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4779 if (ut_params->obuf)
4780 digest = rte_pktmbuf_read(ut_params->obuf,
4781 (tdata->digest.offset_bytes == 0 ?
4782 plaintext_pad_len : tdata->digest.offset_bytes),
4783 tdata->digest.len, digest_buffer);
4785 digest = rte_pktmbuf_read(ut_params->ibuf,
4786 (tdata->digest.offset_bytes == 0 ?
4787 plaintext_pad_len : tdata->digest.offset_bytes),
4788 tdata->digest.len, digest_buffer);
4790 debug_hexdump(stdout, "digest:", digest,
4792 debug_hexdump(stdout, "digest expected:",
4793 tdata->digest.data, tdata->digest.len);
4798 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4800 tdata->plaintext.data,
4801 tdata->plaintext.len >> 3,
4802 "KASUMI Plaintext data not as expected");
4804 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4806 tdata->ciphertext.data,
4807 tdata->validDataLenInBits.len,
4808 "KASUMI Ciphertext data not as expected");
4810 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4813 DIGEST_BYTE_LENGTH_KASUMI_F9,
4814 "KASUMI Generated auth tag not as expected");
4820 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4822 struct crypto_testsuite_params *ts_params = &testsuite_params;
4823 struct crypto_unittest_params *ut_params = &unittest_params;
4827 uint8_t *plaintext, *ciphertext;
4828 unsigned plaintext_pad_len;
4829 unsigned plaintext_len;
4831 /* Verify the capabilities */
4832 struct rte_cryptodev_sym_capability_idx cap_idx;
4833 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4834 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4838 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4839 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4840 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4844 /* Create KASUMI session */
4845 retval = create_wireless_algo_cipher_auth_session(
4846 ts_params->valid_devs[0],
4847 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4848 RTE_CRYPTO_AUTH_OP_GENERATE,
4849 RTE_CRYPTO_AUTH_KASUMI_F9,
4850 RTE_CRYPTO_CIPHER_KASUMI_F8,
4851 tdata->key.data, tdata->key.len,
4852 0, tdata->digest.len,
4853 tdata->cipher_iv.len);
4857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4859 /* clear mbuf payload */
4860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4861 rte_pktmbuf_tailroom(ut_params->ibuf));
4863 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4864 /* Append data which is padded to a multiple of */
4865 /* the algorithms block size */
4866 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4867 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4869 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4871 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4873 /* Create KASUMI operation */
4874 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4875 tdata->digest.len, NULL, 0,
4876 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4877 tdata->cipher_iv.data, tdata->cipher_iv.len,
4878 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4879 tdata->validCipherOffsetInBits.len,
4880 tdata->validAuthLenInBits.len,
4886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4888 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4890 if (ut_params->op->sym->m_dst)
4891 ut_params->obuf = ut_params->op->sym->m_dst;
4893 ut_params->obuf = ut_params->op->sym->m_src;
4895 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4896 tdata->validCipherOffsetInBits.len >> 3);
4898 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4899 + plaintext_pad_len;
4901 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4902 (tdata->validCipherOffsetInBits.len >> 3);
4904 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4906 reference_ciphertext,
4907 tdata->validCipherLenInBits.len,
4908 "KASUMI Ciphertext data not as expected");
4911 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4914 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4915 "KASUMI Generated auth tag not as expected");
4920 test_zuc_encryption(const struct wireless_test_data *tdata)
4922 struct crypto_testsuite_params *ts_params = &testsuite_params;
4923 struct crypto_unittest_params *ut_params = &unittest_params;
4926 uint8_t *plaintext, *ciphertext;
4927 unsigned plaintext_pad_len;
4928 unsigned plaintext_len;
4930 struct rte_cryptodev_sym_capability_idx cap_idx;
4932 /* Check if device supports ZUC EEA3 */
4933 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4934 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4936 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4940 /* Create ZUC session */
4941 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4942 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4943 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4944 tdata->key.data, tdata->key.len,
4945 tdata->cipher_iv.len);
4949 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4951 /* Clear mbuf payload */
4952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4953 rte_pktmbuf_tailroom(ut_params->ibuf));
4955 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4956 /* Append data which is padded to a multiple */
4957 /* of the algorithms block size */
4958 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4959 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4961 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4963 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4965 /* Create ZUC operation */
4966 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4967 tdata->cipher_iv.len,
4968 tdata->plaintext.len,
4973 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4975 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4977 ut_params->obuf = ut_params->op->sym->m_dst;
4978 if (ut_params->obuf)
4979 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4981 ciphertext = plaintext;
4983 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4986 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4988 tdata->ciphertext.data,
4989 tdata->validCipherLenInBits.len,
4990 "ZUC Ciphertext data not as expected");
4995 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4997 struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 struct crypto_unittest_params *ut_params = &unittest_params;
5002 unsigned int plaintext_pad_len;
5003 unsigned int plaintext_len;
5004 const uint8_t *ciphertext;
5005 uint8_t ciphertext_buffer[2048];
5006 struct rte_cryptodev_info dev_info;
5008 struct rte_cryptodev_sym_capability_idx cap_idx;
5010 /* Check if device supports ZUC EEA3 */
5011 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5012 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5014 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5018 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5020 uint64_t feat_flags = dev_info.feature_flags;
5022 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5023 printf("Device doesn't support in-place scatter-gather. "
5028 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5030 /* Append data which is padded to a multiple */
5031 /* of the algorithms block size */
5032 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5034 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5035 plaintext_pad_len, 10, 0);
5037 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5038 tdata->plaintext.data);
5040 /* Create ZUC session */
5041 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5042 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5043 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5044 tdata->key.data, tdata->key.len,
5045 tdata->cipher_iv.len);
5049 /* Clear mbuf payload */
5051 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5053 /* Create ZUC operation */
5054 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5055 tdata->cipher_iv.len, tdata->plaintext.len,
5060 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5062 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5064 ut_params->obuf = ut_params->op->sym->m_dst;
5065 if (ut_params->obuf)
5066 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5067 0, plaintext_len, ciphertext_buffer);
5069 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5070 0, plaintext_len, ciphertext_buffer);
5073 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5076 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5078 tdata->ciphertext.data,
5079 tdata->validCipherLenInBits.len,
5080 "ZUC Ciphertext data not as expected");
5086 test_zuc_authentication(const struct wireless_test_data *tdata)
5088 struct crypto_testsuite_params *ts_params = &testsuite_params;
5089 struct crypto_unittest_params *ut_params = &unittest_params;
5092 unsigned plaintext_pad_len;
5093 unsigned plaintext_len;
5096 struct rte_cryptodev_sym_capability_idx cap_idx;
5097 struct rte_cryptodev_info dev_info;
5099 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5100 uint64_t feat_flags = dev_info.feature_flags;
5102 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5103 (tdata->validAuthLenInBits.len % 8 != 0)) {
5104 printf("Device doesn't support NON-Byte Aligned Data.\n");
5108 /* Check if device supports ZUC EIA3 */
5109 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5110 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5112 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5116 /* Create ZUC session */
5117 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5118 tdata->key.data, tdata->key.len,
5119 tdata->auth_iv.len, tdata->digest.len,
5120 RTE_CRYPTO_AUTH_OP_GENERATE,
5121 RTE_CRYPTO_AUTH_ZUC_EIA3);
5125 /* alloc mbuf and set payload */
5126 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5128 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5129 rte_pktmbuf_tailroom(ut_params->ibuf));
5131 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5132 /* Append data which is padded to a multiple of */
5133 /* the algorithms block size */
5134 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5135 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5137 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5139 /* Create ZUC operation */
5140 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5141 tdata->auth_iv.data, tdata->auth_iv.len,
5142 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5143 tdata->validAuthLenInBits.len,
5148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5150 ut_params->obuf = ut_params->op->sym->m_src;
5151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5152 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5153 + plaintext_pad_len;
5156 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5160 "ZUC Generated auth tag not as expected");
5166 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5167 uint8_t op_mode, uint8_t verify)
5169 struct crypto_testsuite_params *ts_params = &testsuite_params;
5170 struct crypto_unittest_params *ut_params = &unittest_params;
5174 uint8_t *plaintext = NULL, *ciphertext = NULL;
5175 unsigned int plaintext_pad_len;
5176 unsigned int plaintext_len;
5177 unsigned int ciphertext_pad_len;
5178 unsigned int ciphertext_len;
5180 struct rte_cryptodev_info dev_info;
5181 struct rte_cryptodev_sym_capability_idx cap_idx;
5183 /* Check if device supports ZUC EIA3 */
5184 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5185 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5187 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5191 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5193 uint64_t feat_flags = dev_info.feature_flags;
5195 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5196 printf("Device doesn't support digest encrypted.\n");
5199 if (op_mode == IN_PLACE) {
5200 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5201 printf("Device doesn't support in-place scatter-gather "
5202 "in both input and output mbufs.\n");
5206 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5207 printf("Device doesn't support out-of-place scatter-gather "
5208 "in both input and output mbufs.\n");
5213 /* Create ZUC session */
5214 retval = create_wireless_algo_auth_cipher_session(
5215 ts_params->valid_devs[0],
5216 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5217 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5218 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5219 : RTE_CRYPTO_AUTH_OP_GENERATE),
5220 RTE_CRYPTO_AUTH_ZUC_EIA3,
5221 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5222 tdata->key.data, tdata->key.len,
5223 tdata->auth_iv.len, tdata->digest.len,
5224 tdata->cipher_iv.len);
5229 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5230 if (op_mode == OUT_OF_PLACE)
5231 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5233 /* clear mbuf payload */
5234 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5235 rte_pktmbuf_tailroom(ut_params->ibuf));
5236 if (op_mode == OUT_OF_PLACE)
5237 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5238 rte_pktmbuf_tailroom(ut_params->obuf));
5240 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5241 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5242 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5243 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5246 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5247 ciphertext_pad_len);
5248 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5249 if (op_mode == OUT_OF_PLACE)
5250 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5251 debug_hexdump(stdout, "ciphertext:", ciphertext,
5254 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5256 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5257 if (op_mode == OUT_OF_PLACE)
5258 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5259 debug_hexdump(stdout, "plaintext:", plaintext,
5263 /* Create ZUC operation */
5264 retval = create_wireless_algo_auth_cipher_operation(
5265 tdata->digest.data, tdata->digest.len,
5266 tdata->cipher_iv.data, tdata->cipher_iv.len,
5267 tdata->auth_iv.data, tdata->auth_iv.len,
5268 (tdata->digest.offset_bytes == 0 ?
5269 (verify ? ciphertext_pad_len : plaintext_pad_len)
5270 : tdata->digest.offset_bytes),
5271 tdata->validCipherLenInBits.len,
5272 tdata->validCipherOffsetInBits.len,
5273 tdata->validAuthLenInBits.len,
5275 op_mode, 0, verify);
5280 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5283 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5285 ut_params->obuf = (op_mode == IN_PLACE ?
5286 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5290 if (ut_params->obuf)
5291 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5294 plaintext = ciphertext;
5296 debug_hexdump(stdout, "plaintext:", plaintext,
5297 (tdata->plaintext.len >> 3) - tdata->digest.len);
5298 debug_hexdump(stdout, "plaintext expected:",
5299 tdata->plaintext.data,
5300 (tdata->plaintext.len >> 3) - tdata->digest.len);
5302 if (ut_params->obuf)
5303 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5306 ciphertext = plaintext;
5308 debug_hexdump(stdout, "ciphertext:", ciphertext,
5310 debug_hexdump(stdout, "ciphertext expected:",
5311 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5313 ut_params->digest = rte_pktmbuf_mtod(
5314 ut_params->obuf, uint8_t *) +
5315 (tdata->digest.offset_bytes == 0 ?
5316 plaintext_pad_len : tdata->digest.offset_bytes);
5318 debug_hexdump(stdout, "digest:", ut_params->digest,
5320 debug_hexdump(stdout, "digest expected:",
5321 tdata->digest.data, tdata->digest.len);
5326 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5328 tdata->plaintext.data,
5329 tdata->plaintext.len >> 3,
5330 "ZUC Plaintext data not as expected");
5332 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5334 tdata->ciphertext.data,
5335 tdata->ciphertext.len >> 3,
5336 "ZUC Ciphertext data not as expected");
5338 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5341 DIGEST_BYTE_LENGTH_KASUMI_F9,
5342 "ZUC Generated auth tag not as expected");
5348 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5349 uint8_t op_mode, uint8_t verify)
5351 struct crypto_testsuite_params *ts_params = &testsuite_params;
5352 struct crypto_unittest_params *ut_params = &unittest_params;
5356 const uint8_t *plaintext = NULL;
5357 const uint8_t *ciphertext = NULL;
5358 const uint8_t *digest = NULL;
5359 unsigned int plaintext_pad_len;
5360 unsigned int plaintext_len;
5361 unsigned int ciphertext_pad_len;
5362 unsigned int ciphertext_len;
5363 uint8_t buffer[10000];
5364 uint8_t digest_buffer[10000];
5366 struct rte_cryptodev_info dev_info;
5367 struct rte_cryptodev_sym_capability_idx cap_idx;
5369 /* Check if device supports ZUC EIA3 */
5370 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5371 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5373 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5377 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5379 uint64_t feat_flags = dev_info.feature_flags;
5381 if (op_mode == IN_PLACE) {
5382 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5383 printf("Device doesn't support in-place scatter-gather "
5384 "in both input and output mbufs.\n");
5388 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5389 printf("Device doesn't support out-of-place scatter-gather "
5390 "in both input and output mbufs.\n");
5393 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5394 printf("Device doesn't support digest encrypted.\n");
5399 /* Create ZUC session */
5400 retval = create_wireless_algo_auth_cipher_session(
5401 ts_params->valid_devs[0],
5402 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5403 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5404 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5405 : RTE_CRYPTO_AUTH_OP_GENERATE),
5406 RTE_CRYPTO_AUTH_ZUC_EIA3,
5407 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5408 tdata->key.data, tdata->key.len,
5409 tdata->auth_iv.len, tdata->digest.len,
5410 tdata->cipher_iv.len);
5415 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5416 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5417 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5418 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5420 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5421 plaintext_pad_len, 15, 0);
5422 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5423 "Failed to allocate input buffer in mempool");
5425 if (op_mode == OUT_OF_PLACE) {
5426 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5427 plaintext_pad_len, 15, 0);
5428 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5429 "Failed to allocate output buffer in mempool");
5433 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5434 tdata->ciphertext.data);
5435 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5436 ciphertext_len, buffer);
5437 debug_hexdump(stdout, "ciphertext:", ciphertext,
5440 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5441 tdata->plaintext.data);
5442 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5443 plaintext_len, buffer);
5444 debug_hexdump(stdout, "plaintext:", plaintext,
5447 memset(buffer, 0, sizeof(buffer));
5449 /* Create ZUC operation */
5450 retval = create_wireless_algo_auth_cipher_operation(
5451 tdata->digest.data, tdata->digest.len,
5452 tdata->cipher_iv.data, tdata->cipher_iv.len,
5454 (tdata->digest.offset_bytes == 0 ?
5455 (verify ? ciphertext_pad_len : plaintext_pad_len)
5456 : tdata->digest.offset_bytes),
5457 tdata->validCipherLenInBits.len,
5458 tdata->validCipherOffsetInBits.len,
5459 tdata->validAuthLenInBits.len,
5461 op_mode, 1, verify);
5466 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5469 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5471 ut_params->obuf = (op_mode == IN_PLACE ?
5472 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5475 if (ut_params->obuf)
5476 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5477 plaintext_len, buffer);
5479 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5480 plaintext_len, buffer);
5482 debug_hexdump(stdout, "plaintext:", plaintext,
5483 (tdata->plaintext.len >> 3) - tdata->digest.len);
5484 debug_hexdump(stdout, "plaintext expected:",
5485 tdata->plaintext.data,
5486 (tdata->plaintext.len >> 3) - tdata->digest.len);
5488 if (ut_params->obuf)
5489 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5490 ciphertext_len, buffer);
5492 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5493 ciphertext_len, buffer);
5495 debug_hexdump(stdout, "ciphertext:", ciphertext,
5497 debug_hexdump(stdout, "ciphertext expected:",
5498 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5500 if (ut_params->obuf)
5501 digest = rte_pktmbuf_read(ut_params->obuf,
5502 (tdata->digest.offset_bytes == 0 ?
5503 plaintext_pad_len : tdata->digest.offset_bytes),
5504 tdata->digest.len, digest_buffer);
5506 digest = rte_pktmbuf_read(ut_params->ibuf,
5507 (tdata->digest.offset_bytes == 0 ?
5508 plaintext_pad_len : tdata->digest.offset_bytes),
5509 tdata->digest.len, digest_buffer);
5511 debug_hexdump(stdout, "digest:", digest,
5513 debug_hexdump(stdout, "digest expected:",
5514 tdata->digest.data, tdata->digest.len);
5519 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5521 tdata->plaintext.data,
5522 tdata->plaintext.len >> 3,
5523 "ZUC Plaintext data not as expected");
5525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5527 tdata->ciphertext.data,
5528 tdata->validDataLenInBits.len,
5529 "ZUC Ciphertext data not as expected");
5531 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5534 DIGEST_BYTE_LENGTH_KASUMI_F9,
5535 "ZUC Generated auth tag not as expected");
5541 test_kasumi_encryption_test_case_1(void)
5543 return test_kasumi_encryption(&kasumi_test_case_1);
5547 test_kasumi_encryption_test_case_1_sgl(void)
5549 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5553 test_kasumi_encryption_test_case_1_oop(void)
5555 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5559 test_kasumi_encryption_test_case_1_oop_sgl(void)
5561 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5565 test_kasumi_encryption_test_case_2(void)
5567 return test_kasumi_encryption(&kasumi_test_case_2);
5571 test_kasumi_encryption_test_case_3(void)
5573 return test_kasumi_encryption(&kasumi_test_case_3);
5577 test_kasumi_encryption_test_case_4(void)
5579 return test_kasumi_encryption(&kasumi_test_case_4);
5583 test_kasumi_encryption_test_case_5(void)
5585 return test_kasumi_encryption(&kasumi_test_case_5);
5589 test_kasumi_decryption_test_case_1(void)
5591 return test_kasumi_decryption(&kasumi_test_case_1);
5595 test_kasumi_decryption_test_case_1_oop(void)
5597 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5601 test_kasumi_decryption_test_case_2(void)
5603 return test_kasumi_decryption(&kasumi_test_case_2);
5607 test_kasumi_decryption_test_case_3(void)
5609 return test_kasumi_decryption(&kasumi_test_case_3);
5613 test_kasumi_decryption_test_case_4(void)
5615 return test_kasumi_decryption(&kasumi_test_case_4);
5619 test_kasumi_decryption_test_case_5(void)
5621 return test_kasumi_decryption(&kasumi_test_case_5);
5624 test_snow3g_encryption_test_case_1(void)
5626 return test_snow3g_encryption(&snow3g_test_case_1);
5630 test_snow3g_encryption_test_case_1_oop(void)
5632 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5636 test_snow3g_encryption_test_case_1_oop_sgl(void)
5638 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5643 test_snow3g_encryption_test_case_1_offset_oop(void)
5645 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5649 test_snow3g_encryption_test_case_2(void)
5651 return test_snow3g_encryption(&snow3g_test_case_2);
5655 test_snow3g_encryption_test_case_3(void)
5657 return test_snow3g_encryption(&snow3g_test_case_3);
5661 test_snow3g_encryption_test_case_4(void)
5663 return test_snow3g_encryption(&snow3g_test_case_4);
5667 test_snow3g_encryption_test_case_5(void)
5669 return test_snow3g_encryption(&snow3g_test_case_5);
5673 test_snow3g_decryption_test_case_1(void)
5675 return test_snow3g_decryption(&snow3g_test_case_1);
5679 test_snow3g_decryption_test_case_1_oop(void)
5681 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5685 test_snow3g_decryption_test_case_2(void)
5687 return test_snow3g_decryption(&snow3g_test_case_2);
5691 test_snow3g_decryption_test_case_3(void)
5693 return test_snow3g_decryption(&snow3g_test_case_3);
5697 test_snow3g_decryption_test_case_4(void)
5699 return test_snow3g_decryption(&snow3g_test_case_4);
5703 test_snow3g_decryption_test_case_5(void)
5705 return test_snow3g_decryption(&snow3g_test_case_5);
5709 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5710 * Pattern digest from snow3g_test_data must be allocated as
5711 * 4 last bytes in plaintext.
5714 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5715 struct snow3g_hash_test_data *output)
5717 if ((pattern != NULL) && (output != NULL)) {
5718 output->key.len = pattern->key.len;
5720 memcpy(output->key.data,
5721 pattern->key.data, pattern->key.len);
5723 output->auth_iv.len = pattern->auth_iv.len;
5725 memcpy(output->auth_iv.data,
5726 pattern->auth_iv.data, pattern->auth_iv.len);
5728 output->plaintext.len = pattern->plaintext.len;
5730 memcpy(output->plaintext.data,
5731 pattern->plaintext.data, pattern->plaintext.len >> 3);
5733 output->digest.len = pattern->digest.len;
5735 memcpy(output->digest.data,
5736 &pattern->plaintext.data[pattern->digest.offset_bytes],
5737 pattern->digest.len);
5739 output->validAuthLenInBits.len =
5740 pattern->validAuthLenInBits.len;
5745 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5748 test_snow3g_decryption_with_digest_test_case_1(void)
5750 struct snow3g_hash_test_data snow3g_hash_data;
5753 * Function prepare data for hash veryfication test case.
5754 * Digest is allocated in 4 last bytes in plaintext, pattern.
5756 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5758 return test_snow3g_decryption(&snow3g_test_case_7) &
5759 test_snow3g_authentication_verify(&snow3g_hash_data);
5763 test_snow3g_cipher_auth_test_case_1(void)
5765 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5769 test_snow3g_auth_cipher_test_case_1(void)
5771 return test_snow3g_auth_cipher(
5772 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5776 test_snow3g_auth_cipher_test_case_2(void)
5778 return test_snow3g_auth_cipher(
5779 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5783 test_snow3g_auth_cipher_test_case_2_oop(void)
5785 return test_snow3g_auth_cipher(
5786 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5790 test_snow3g_auth_cipher_part_digest_enc(void)
5792 return test_snow3g_auth_cipher(
5793 &snow3g_auth_cipher_partial_digest_encryption,
5798 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5800 return test_snow3g_auth_cipher(
5801 &snow3g_auth_cipher_partial_digest_encryption,
5806 test_snow3g_auth_cipher_test_case_3_sgl(void)
5808 return test_snow3g_auth_cipher_sgl(
5809 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5813 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5815 return test_snow3g_auth_cipher_sgl(
5816 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5820 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5822 return test_snow3g_auth_cipher_sgl(
5823 &snow3g_auth_cipher_partial_digest_encryption,
5828 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5830 return test_snow3g_auth_cipher_sgl(
5831 &snow3g_auth_cipher_partial_digest_encryption,
5836 test_snow3g_auth_cipher_verify_test_case_1(void)
5838 return test_snow3g_auth_cipher(
5839 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5843 test_snow3g_auth_cipher_verify_test_case_2(void)
5845 return test_snow3g_auth_cipher(
5846 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5850 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5852 return test_snow3g_auth_cipher(
5853 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5857 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5859 return test_snow3g_auth_cipher(
5860 &snow3g_auth_cipher_partial_digest_encryption,
5865 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5867 return test_snow3g_auth_cipher(
5868 &snow3g_auth_cipher_partial_digest_encryption,
5873 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5875 return test_snow3g_auth_cipher_sgl(
5876 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5880 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5882 return test_snow3g_auth_cipher_sgl(
5883 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5887 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5889 return test_snow3g_auth_cipher_sgl(
5890 &snow3g_auth_cipher_partial_digest_encryption,
5895 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5897 return test_snow3g_auth_cipher_sgl(
5898 &snow3g_auth_cipher_partial_digest_encryption,
5903 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5905 return test_snow3g_auth_cipher(
5906 &snow3g_test_case_7, IN_PLACE, 0);
5910 test_kasumi_auth_cipher_test_case_1(void)
5912 return test_kasumi_auth_cipher(
5913 &kasumi_test_case_3, IN_PLACE, 0);
5917 test_kasumi_auth_cipher_test_case_2(void)
5919 return test_kasumi_auth_cipher(
5920 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5924 test_kasumi_auth_cipher_test_case_2_oop(void)
5926 return test_kasumi_auth_cipher(
5927 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5931 test_kasumi_auth_cipher_test_case_2_sgl(void)
5933 return test_kasumi_auth_cipher_sgl(
5934 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5938 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5940 return test_kasumi_auth_cipher_sgl(
5941 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5945 test_kasumi_auth_cipher_verify_test_case_1(void)
5947 return test_kasumi_auth_cipher(
5948 &kasumi_test_case_3, IN_PLACE, 1);
5952 test_kasumi_auth_cipher_verify_test_case_2(void)
5954 return test_kasumi_auth_cipher(
5955 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5959 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5961 return test_kasumi_auth_cipher(
5962 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5966 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5968 return test_kasumi_auth_cipher_sgl(
5969 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5973 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5975 return test_kasumi_auth_cipher_sgl(
5976 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5980 test_kasumi_cipher_auth_test_case_1(void)
5982 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5986 test_zuc_encryption_test_case_1(void)
5988 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5992 test_zuc_encryption_test_case_2(void)
5994 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5998 test_zuc_encryption_test_case_3(void)
6000 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6004 test_zuc_encryption_test_case_4(void)
6006 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6010 test_zuc_encryption_test_case_5(void)
6012 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6016 test_zuc_encryption_test_case_6_sgl(void)
6018 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6022 test_zuc_hash_generate_test_case_1(void)
6024 return test_zuc_authentication(&zuc_test_case_auth_1b);
6028 test_zuc_hash_generate_test_case_2(void)
6030 return test_zuc_authentication(&zuc_test_case_auth_90b);
6034 test_zuc_hash_generate_test_case_3(void)
6036 return test_zuc_authentication(&zuc_test_case_auth_577b);
6040 test_zuc_hash_generate_test_case_4(void)
6042 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6046 test_zuc_hash_generate_test_case_5(void)
6048 return test_zuc_authentication(&zuc_test_auth_5670b);
6052 test_zuc_hash_generate_test_case_6(void)
6054 return test_zuc_authentication(&zuc_test_case_auth_128b);
6058 test_zuc_hash_generate_test_case_7(void)
6060 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6064 test_zuc_hash_generate_test_case_8(void)
6066 return test_zuc_authentication(&zuc_test_case_auth_584b);
6070 test_zuc_cipher_auth_test_case_1(void)
6072 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6076 test_zuc_cipher_auth_test_case_2(void)
6078 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6082 test_zuc_auth_cipher_test_case_1(void)
6084 return test_zuc_auth_cipher(
6085 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6089 test_zuc_auth_cipher_test_case_1_oop(void)
6091 return test_zuc_auth_cipher(
6092 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6096 test_zuc_auth_cipher_test_case_1_sgl(void)
6098 return test_zuc_auth_cipher_sgl(
6099 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6103 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6105 return test_zuc_auth_cipher_sgl(
6106 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6110 test_zuc_auth_cipher_verify_test_case_1(void)
6112 return test_zuc_auth_cipher(
6113 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6117 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6119 return test_zuc_auth_cipher(
6120 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6124 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6126 return test_zuc_auth_cipher_sgl(
6127 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6131 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6133 return test_zuc_auth_cipher_sgl(
6134 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6138 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6140 uint8_t dev_id = testsuite_params.valid_devs[0];
6142 struct rte_cryptodev_sym_capability_idx cap_idx;
6144 /* Check if device supports particular cipher algorithm */
6145 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6146 cap_idx.algo.cipher = tdata->cipher_algo;
6147 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6150 /* Check if device supports particular hash algorithm */
6151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6152 cap_idx.algo.auth = tdata->auth_algo;
6153 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6160 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6161 uint8_t op_mode, uint8_t verify)
6163 struct crypto_testsuite_params *ts_params = &testsuite_params;
6164 struct crypto_unittest_params *ut_params = &unittest_params;
6168 uint8_t *plaintext = NULL, *ciphertext = NULL;
6169 unsigned int plaintext_pad_len;
6170 unsigned int plaintext_len;
6171 unsigned int ciphertext_pad_len;
6172 unsigned int ciphertext_len;
6174 struct rte_cryptodev_info dev_info;
6175 struct rte_crypto_op *op;
6177 /* Check if device supports particular algorithms separately */
6178 if (test_mixed_check_if_unsupported(tdata))
6181 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6183 uint64_t feat_flags = dev_info.feature_flags;
6185 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6186 printf("Device doesn't support digest encrypted.\n");
6190 /* Create the session */
6192 retval = create_wireless_algo_cipher_auth_session(
6193 ts_params->valid_devs[0],
6194 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6195 RTE_CRYPTO_AUTH_OP_VERIFY,
6198 tdata->auth_key.data, tdata->auth_key.len,
6199 tdata->auth_iv.len, tdata->digest_enc.len,
6200 tdata->cipher_iv.len);
6202 retval = create_wireless_algo_auth_cipher_session(
6203 ts_params->valid_devs[0],
6204 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6205 RTE_CRYPTO_AUTH_OP_GENERATE,
6208 tdata->auth_key.data, tdata->auth_key.len,
6209 tdata->auth_iv.len, tdata->digest_enc.len,
6210 tdata->cipher_iv.len);
6214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6215 if (op_mode == OUT_OF_PLACE)
6216 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6218 /* clear mbuf payload */
6219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6220 rte_pktmbuf_tailroom(ut_params->ibuf));
6221 if (op_mode == OUT_OF_PLACE)
6222 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6223 rte_pktmbuf_tailroom(ut_params->obuf));
6225 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6226 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6227 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6228 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6231 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6232 ciphertext_pad_len);
6233 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6234 if (op_mode == OUT_OF_PLACE)
6235 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6236 debug_hexdump(stdout, "ciphertext:", ciphertext,
6239 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6241 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6242 if (op_mode == OUT_OF_PLACE)
6243 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6244 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6247 /* Create the operation */
6248 retval = create_wireless_algo_auth_cipher_operation(
6249 tdata->digest_enc.data, tdata->digest_enc.len,
6250 tdata->cipher_iv.data, tdata->cipher_iv.len,
6251 tdata->auth_iv.data, tdata->auth_iv.len,
6252 (tdata->digest_enc.offset == 0 ?
6254 : tdata->digest_enc.offset),
6255 tdata->validCipherLen.len_bits,
6256 tdata->cipher.offset_bits,
6257 tdata->validAuthLen.len_bits,
6258 tdata->auth.offset_bits,
6259 op_mode, 0, verify);
6264 op = process_crypto_request(ts_params->valid_devs[0],
6267 /* Check if the op failed because the device doesn't */
6268 /* support this particular combination of algorithms */
6269 if (op == NULL && ut_params->op->status ==
6270 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6271 printf("Device doesn't support this mixed combination. "
6277 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6279 ut_params->obuf = (op_mode == IN_PLACE ?
6280 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6283 if (ut_params->obuf)
6284 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6287 plaintext = ciphertext +
6288 (tdata->cipher.offset_bits >> 3);
6290 debug_hexdump(stdout, "plaintext:", plaintext,
6291 tdata->plaintext.len_bits >> 3);
6292 debug_hexdump(stdout, "plaintext expected:",
6293 tdata->plaintext.data,
6294 tdata->plaintext.len_bits >> 3);
6296 if (ut_params->obuf)
6297 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6300 ciphertext = plaintext;
6302 debug_hexdump(stdout, "ciphertext:", ciphertext,
6304 debug_hexdump(stdout, "ciphertext expected:",
6305 tdata->ciphertext.data,
6306 tdata->ciphertext.len_bits >> 3);
6308 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6309 + (tdata->digest_enc.offset == 0 ?
6310 plaintext_pad_len : tdata->digest_enc.offset);
6312 debug_hexdump(stdout, "digest:", ut_params->digest,
6313 tdata->digest_enc.len);
6314 debug_hexdump(stdout, "digest expected:",
6315 tdata->digest_enc.data,
6316 tdata->digest_enc.len);
6321 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6323 tdata->plaintext.data,
6324 tdata->plaintext.len_bits >> 3,
6325 "Plaintext data not as expected");
6327 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6329 tdata->ciphertext.data,
6330 tdata->validDataLen.len_bits,
6331 "Ciphertext data not as expected");
6333 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6335 tdata->digest_enc.data,
6336 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6337 "Generated auth tag not as expected");
6340 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6341 "crypto op processing failed");
6347 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6348 uint8_t op_mode, uint8_t verify)
6350 struct crypto_testsuite_params *ts_params = &testsuite_params;
6351 struct crypto_unittest_params *ut_params = &unittest_params;
6355 const uint8_t *plaintext = NULL;
6356 const uint8_t *ciphertext = NULL;
6357 const uint8_t *digest = NULL;
6358 unsigned int plaintext_pad_len;
6359 unsigned int plaintext_len;
6360 unsigned int ciphertext_pad_len;
6361 unsigned int ciphertext_len;
6362 uint8_t buffer[10000];
6363 uint8_t digest_buffer[10000];
6365 struct rte_cryptodev_info dev_info;
6366 struct rte_crypto_op *op;
6368 /* Check if device supports particular algorithms */
6369 if (test_mixed_check_if_unsupported(tdata))
6372 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6374 uint64_t feat_flags = dev_info.feature_flags;
6376 if (op_mode == IN_PLACE) {
6377 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6378 printf("Device doesn't support in-place scatter-gather "
6379 "in both input and output mbufs.\n");
6383 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6384 printf("Device doesn't support out-of-place scatter-gather "
6385 "in both input and output mbufs.\n");
6388 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6389 printf("Device doesn't support digest encrypted.\n");
6394 /* Create the session */
6396 retval = create_wireless_algo_cipher_auth_session(
6397 ts_params->valid_devs[0],
6398 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6399 RTE_CRYPTO_AUTH_OP_VERIFY,
6402 tdata->auth_key.data, tdata->auth_key.len,
6403 tdata->auth_iv.len, tdata->digest_enc.len,
6404 tdata->cipher_iv.len);
6406 retval = create_wireless_algo_auth_cipher_session(
6407 ts_params->valid_devs[0],
6408 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6409 RTE_CRYPTO_AUTH_OP_GENERATE,
6412 tdata->auth_key.data, tdata->auth_key.len,
6413 tdata->auth_iv.len, tdata->digest_enc.len,
6414 tdata->cipher_iv.len);
6418 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6419 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6420 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6421 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6423 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6424 ciphertext_pad_len, 15, 0);
6425 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6426 "Failed to allocate input buffer in mempool");
6428 if (op_mode == OUT_OF_PLACE) {
6429 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6430 plaintext_pad_len, 15, 0);
6431 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6432 "Failed to allocate output buffer in mempool");
6436 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6437 tdata->ciphertext.data);
6438 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6439 ciphertext_len, buffer);
6440 debug_hexdump(stdout, "ciphertext:", ciphertext,
6443 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6444 tdata->plaintext.data);
6445 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6446 plaintext_len, buffer);
6447 debug_hexdump(stdout, "plaintext:", plaintext,
6450 memset(buffer, 0, sizeof(buffer));
6452 /* Create the operation */
6453 retval = create_wireless_algo_auth_cipher_operation(
6454 tdata->digest_enc.data, tdata->digest_enc.len,
6455 tdata->cipher_iv.data, tdata->cipher_iv.len,
6456 tdata->auth_iv.data, tdata->auth_iv.len,
6457 (tdata->digest_enc.offset == 0 ?
6459 : tdata->digest_enc.offset),
6460 tdata->validCipherLen.len_bits,
6461 tdata->cipher.offset_bits,
6462 tdata->validAuthLen.len_bits,
6463 tdata->auth.offset_bits,
6464 op_mode, 1, verify);
6469 op = process_crypto_request(ts_params->valid_devs[0],
6472 /* Check if the op failed because the device doesn't */
6473 /* support this particular combination of algorithms */
6474 if (op == NULL && ut_params->op->status ==
6475 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6476 printf("Device doesn't support this mixed combination. "
6483 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6485 ut_params->obuf = (op_mode == IN_PLACE ?
6486 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6489 if (ut_params->obuf)
6490 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6491 plaintext_len, buffer);
6493 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6494 plaintext_len, buffer);
6496 debug_hexdump(stdout, "plaintext:", plaintext,
6497 (tdata->plaintext.len_bits >> 3) -
6498 tdata->digest_enc.len);
6499 debug_hexdump(stdout, "plaintext expected:",
6500 tdata->plaintext.data,
6501 (tdata->plaintext.len_bits >> 3) -
6502 tdata->digest_enc.len);
6504 if (ut_params->obuf)
6505 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6506 ciphertext_len, buffer);
6508 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6509 ciphertext_len, buffer);
6511 debug_hexdump(stdout, "ciphertext:", ciphertext,
6513 debug_hexdump(stdout, "ciphertext expected:",
6514 tdata->ciphertext.data,
6515 tdata->ciphertext.len_bits >> 3);
6517 if (ut_params->obuf)
6518 digest = rte_pktmbuf_read(ut_params->obuf,
6519 (tdata->digest_enc.offset == 0 ?
6521 tdata->digest_enc.offset),
6522 tdata->digest_enc.len, digest_buffer);
6524 digest = rte_pktmbuf_read(ut_params->ibuf,
6525 (tdata->digest_enc.offset == 0 ?
6527 tdata->digest_enc.offset),
6528 tdata->digest_enc.len, digest_buffer);
6530 debug_hexdump(stdout, "digest:", digest,
6531 tdata->digest_enc.len);
6532 debug_hexdump(stdout, "digest expected:",
6533 tdata->digest_enc.data, tdata->digest_enc.len);
6538 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6540 tdata->plaintext.data,
6541 tdata->plaintext.len_bits >> 3,
6542 "Plaintext data not as expected");
6544 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6546 tdata->ciphertext.data,
6547 tdata->validDataLen.len_bits,
6548 "Ciphertext data not as expected");
6549 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6551 tdata->digest_enc.data,
6552 tdata->digest_enc.len,
6553 "Generated auth tag not as expected");
6556 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6557 "crypto op processing failed");
6562 /** AUTH AES CMAC + CIPHER AES CTR */
6565 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6567 return test_mixed_auth_cipher(
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(void)
6574 return test_mixed_auth_cipher(
6575 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6579 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6581 return test_mixed_auth_cipher_sgl(
6582 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6586 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6588 return test_mixed_auth_cipher_sgl(
6589 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6593 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6595 return test_mixed_auth_cipher(
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(void)
6602 return test_mixed_auth_cipher(
6603 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6607 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6609 return test_mixed_auth_cipher_sgl(
6610 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6614 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6616 return test_mixed_auth_cipher_sgl(
6617 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6620 /** MIXED AUTH + CIPHER */
6623 test_auth_zuc_cipher_snow_test_case_1(void)
6625 return test_mixed_auth_cipher(
6626 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6630 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6632 return test_mixed_auth_cipher(
6633 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6637 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6639 return test_mixed_auth_cipher(
6640 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6644 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6646 return test_mixed_auth_cipher(
6647 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6651 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6653 return test_mixed_auth_cipher(
6654 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6658 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6660 return test_mixed_auth_cipher(
6661 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6665 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6667 return test_mixed_auth_cipher(
6668 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6672 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6674 return test_mixed_auth_cipher(
6675 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6679 test_auth_snow_cipher_zuc_test_case_1(void)
6681 return test_mixed_auth_cipher(
6682 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6686 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6688 return test_mixed_auth_cipher(
6689 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6693 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6695 return test_mixed_auth_cipher(
6696 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6700 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6702 return test_mixed_auth_cipher(
6703 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6707 test_auth_null_cipher_snow_test_case_1(void)
6709 return test_mixed_auth_cipher(
6710 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6714 test_verify_auth_null_cipher_snow_test_case_1(void)
6716 return test_mixed_auth_cipher(
6717 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6721 test_auth_null_cipher_zuc_test_case_1(void)
6723 return test_mixed_auth_cipher(
6724 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6728 test_verify_auth_null_cipher_zuc_test_case_1(void)
6730 return test_mixed_auth_cipher(
6731 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6735 test_auth_snow_cipher_null_test_case_1(void)
6737 return test_mixed_auth_cipher(
6738 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6742 test_verify_auth_snow_cipher_null_test_case_1(void)
6744 return test_mixed_auth_cipher(
6745 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6749 test_auth_zuc_cipher_null_test_case_1(void)
6751 return test_mixed_auth_cipher(
6752 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6756 test_verify_auth_zuc_cipher_null_test_case_1(void)
6758 return test_mixed_auth_cipher(
6759 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6763 test_auth_null_cipher_aes_ctr_test_case_1(void)
6765 return test_mixed_auth_cipher(
6766 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6770 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6772 return test_mixed_auth_cipher(
6773 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6777 test_auth_aes_cmac_cipher_null_test_case_1(void)
6779 return test_mixed_auth_cipher(
6780 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6784 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6786 return test_mixed_auth_cipher(
6787 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6790 /* ***** AEAD algorithm Tests ***** */
6793 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6794 enum rte_crypto_aead_operation op,
6795 const uint8_t *key, const uint8_t key_len,
6796 const uint16_t aad_len, const uint8_t auth_len,
6799 uint8_t aead_key[key_len];
6801 struct crypto_testsuite_params *ts_params = &testsuite_params;
6802 struct crypto_unittest_params *ut_params = &unittest_params;
6804 memcpy(aead_key, key, key_len);
6806 /* Setup AEAD Parameters */
6807 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6808 ut_params->aead_xform.next = NULL;
6809 ut_params->aead_xform.aead.algo = algo;
6810 ut_params->aead_xform.aead.op = op;
6811 ut_params->aead_xform.aead.key.data = aead_key;
6812 ut_params->aead_xform.aead.key.length = key_len;
6813 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6814 ut_params->aead_xform.aead.iv.length = iv_len;
6815 ut_params->aead_xform.aead.digest_length = auth_len;
6816 ut_params->aead_xform.aead.aad_length = aad_len;
6818 debug_hexdump(stdout, "key:", key, key_len);
6820 /* Create Crypto session*/
6821 ut_params->sess = rte_cryptodev_sym_session_create(
6822 ts_params->session_mpool);
6824 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6825 &ut_params->aead_xform,
6826 ts_params->session_priv_mpool);
6828 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6834 create_aead_xform(struct rte_crypto_op *op,
6835 enum rte_crypto_aead_algorithm algo,
6836 enum rte_crypto_aead_operation aead_op,
6837 uint8_t *key, const uint8_t key_len,
6838 const uint8_t aad_len, const uint8_t auth_len,
6841 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6842 "failed to allocate space for crypto transform");
6844 struct rte_crypto_sym_op *sym_op = op->sym;
6846 /* Setup AEAD Parameters */
6847 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6848 sym_op->xform->next = NULL;
6849 sym_op->xform->aead.algo = algo;
6850 sym_op->xform->aead.op = aead_op;
6851 sym_op->xform->aead.key.data = key;
6852 sym_op->xform->aead.key.length = key_len;
6853 sym_op->xform->aead.iv.offset = IV_OFFSET;
6854 sym_op->xform->aead.iv.length = iv_len;
6855 sym_op->xform->aead.digest_length = auth_len;
6856 sym_op->xform->aead.aad_length = aad_len;
6858 debug_hexdump(stdout, "key:", key, key_len);
6864 create_aead_operation(enum rte_crypto_aead_operation op,
6865 const struct aead_test_data *tdata)
6867 struct crypto_testsuite_params *ts_params = &testsuite_params;
6868 struct crypto_unittest_params *ut_params = &unittest_params;
6870 uint8_t *plaintext, *ciphertext;
6871 unsigned int aad_pad_len, plaintext_pad_len;
6873 /* Generate Crypto op data structure */
6874 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6875 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6876 TEST_ASSERT_NOT_NULL(ut_params->op,
6877 "Failed to allocate symmetric crypto operation struct");
6879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6881 /* Append aad data */
6882 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6883 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6884 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6886 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6887 "no room to append aad");
6889 sym_op->aead.aad.phys_addr =
6890 rte_pktmbuf_iova(ut_params->ibuf);
6891 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6892 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6893 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6896 /* Append IV at the end of the crypto operation*/
6897 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6898 uint8_t *, IV_OFFSET);
6900 /* Copy IV 1 byte after the IV pointer, according to the API */
6901 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6902 debug_hexdump(stdout, "iv:", iv_ptr,
6905 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6906 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6908 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6909 "no room to append aad");
6911 sym_op->aead.aad.phys_addr =
6912 rte_pktmbuf_iova(ut_params->ibuf);
6913 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6914 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6917 /* Append IV at the end of the crypto operation*/
6918 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6919 uint8_t *, IV_OFFSET);
6921 if (tdata->iv.len == 0) {
6922 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6923 debug_hexdump(stdout, "iv:", iv_ptr,
6926 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6927 debug_hexdump(stdout, "iv:", iv_ptr,
6932 /* Append plaintext/ciphertext */
6933 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6934 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6935 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6937 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6939 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6940 debug_hexdump(stdout, "plaintext:", plaintext,
6941 tdata->plaintext.len);
6943 if (ut_params->obuf) {
6944 ciphertext = (uint8_t *)rte_pktmbuf_append(
6946 plaintext_pad_len + aad_pad_len);
6947 TEST_ASSERT_NOT_NULL(ciphertext,
6948 "no room to append ciphertext");
6950 memset(ciphertext + aad_pad_len, 0,
6951 tdata->ciphertext.len);
6954 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6955 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6957 TEST_ASSERT_NOT_NULL(ciphertext,
6958 "no room to append ciphertext");
6960 memcpy(ciphertext, tdata->ciphertext.data,
6961 tdata->ciphertext.len);
6962 debug_hexdump(stdout, "ciphertext:", ciphertext,
6963 tdata->ciphertext.len);
6965 if (ut_params->obuf) {
6966 plaintext = (uint8_t *)rte_pktmbuf_append(
6968 plaintext_pad_len + aad_pad_len);
6969 TEST_ASSERT_NOT_NULL(plaintext,
6970 "no room to append plaintext");
6972 memset(plaintext + aad_pad_len, 0,
6973 tdata->plaintext.len);
6977 /* Append digest data */
6978 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6979 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6980 ut_params->obuf ? ut_params->obuf :
6982 tdata->auth_tag.len);
6983 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6984 "no room to append digest");
6985 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6986 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6987 ut_params->obuf ? ut_params->obuf :
6992 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6993 ut_params->ibuf, tdata->auth_tag.len);
6994 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6995 "no room to append digest");
6996 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6998 plaintext_pad_len + aad_pad_len);
7000 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7001 tdata->auth_tag.len);
7002 debug_hexdump(stdout, "digest:",
7003 sym_op->aead.digest.data,
7004 tdata->auth_tag.len);
7007 sym_op->aead.data.length = tdata->plaintext.len;
7008 sym_op->aead.data.offset = aad_pad_len;
7014 test_authenticated_encryption(const struct aead_test_data *tdata)
7016 struct crypto_testsuite_params *ts_params = &testsuite_params;
7017 struct crypto_unittest_params *ut_params = &unittest_params;
7020 uint8_t *ciphertext, *auth_tag;
7021 uint16_t plaintext_pad_len;
7024 /* Verify the capabilities */
7025 struct rte_cryptodev_sym_capability_idx cap_idx;
7026 const struct rte_cryptodev_symmetric_capability *capability;
7027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7028 cap_idx.algo.aead = tdata->algo;
7029 capability = rte_cryptodev_sym_capability_get(
7030 ts_params->valid_devs[0], &cap_idx);
7031 if (capability == NULL)
7033 if (rte_cryptodev_sym_capability_check_aead(
7034 capability, tdata->key.len, tdata->auth_tag.len,
7035 tdata->aad.len, tdata->iv.len))
7038 /* Create AEAD session */
7039 retval = create_aead_session(ts_params->valid_devs[0],
7041 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7042 tdata->key.data, tdata->key.len,
7043 tdata->aad.len, tdata->auth_tag.len,
7048 if (tdata->aad.len > MBUF_SIZE) {
7049 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7050 /* Populate full size of add data */
7051 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7052 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7054 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7056 /* clear mbuf payload */
7057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7058 rte_pktmbuf_tailroom(ut_params->ibuf));
7060 /* Create AEAD operation */
7061 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7065 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7067 ut_params->op->sym->m_src = ut_params->ibuf;
7069 /* Process crypto operation */
7070 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7071 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7073 TEST_ASSERT_NOT_NULL(
7074 process_crypto_request(ts_params->valid_devs[0],
7075 ut_params->op), "failed to process sym crypto op");
7077 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7078 "crypto op processing failed");
7080 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7082 if (ut_params->op->sym->m_dst) {
7083 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7085 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7086 uint8_t *, plaintext_pad_len);
7088 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7090 ut_params->op->sym->cipher.data.offset);
7091 auth_tag = ciphertext + plaintext_pad_len;
7094 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7095 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7098 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7100 tdata->ciphertext.data,
7101 tdata->ciphertext.len,
7102 "Ciphertext data not as expected");
7104 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7106 tdata->auth_tag.data,
7107 tdata->auth_tag.len,
7108 "Generated auth tag not as expected");
7114 #ifdef RTE_LIBRTE_SECURITY
7115 /* Basic algorithm run function for async inplace mode.
7116 * Creates a session from input parameters and runs one operation
7117 * on input_vec. Checks the output of the crypto operation against
7121 test_pdcp_proto(int i, int oop,
7122 enum rte_crypto_cipher_operation opc,
7123 enum rte_crypto_auth_operation opa,
7125 unsigned int input_vec_len,
7126 uint8_t *output_vec,
7127 unsigned int output_vec_len)
7129 struct crypto_testsuite_params *ts_params = &testsuite_params;
7130 struct crypto_unittest_params *ut_params = &unittest_params;
7132 int ret = TEST_SUCCESS;
7133 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7134 rte_cryptodev_get_sec_ctx(
7135 ts_params->valid_devs[0]);
7137 /* Verify the capabilities */
7138 struct rte_security_capability_idx sec_cap_idx;
7140 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7141 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7142 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7143 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7146 /* Generate test mbuf data */
7147 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7149 /* clear mbuf payload */
7150 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7151 rte_pktmbuf_tailroom(ut_params->ibuf));
7153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7155 memcpy(plaintext, input_vec, input_vec_len);
7157 /* Out of place support */
7160 * For out-op-place we need to alloc another mbuf
7162 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7163 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7166 /* Set crypto type as IPSEC */
7167 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7169 /* Setup Cipher Parameters */
7170 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7171 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7172 ut_params->cipher_xform.cipher.op = opc;
7173 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7174 ut_params->cipher_xform.cipher.key.length =
7175 pdcp_test_params[i].cipher_key_len;
7176 ut_params->cipher_xform.cipher.iv.length = 0;
7178 /* Setup HMAC Parameters if ICV header is required */
7179 if (pdcp_test_params[i].auth_alg != 0) {
7180 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7181 ut_params->auth_xform.next = NULL;
7182 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7183 ut_params->auth_xform.auth.op = opa;
7184 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7185 ut_params->auth_xform.auth.key.length =
7186 pdcp_test_params[i].auth_key_len;
7188 ut_params->cipher_xform.next = &ut_params->auth_xform;
7190 ut_params->cipher_xform.next = NULL;
7193 struct rte_security_session_conf sess_conf = {
7194 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7195 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7197 .bearer = pdcp_test_bearer[i],
7198 .domain = pdcp_test_params[i].domain,
7199 .pkt_dir = pdcp_test_packet_direction[i],
7200 .sn_size = pdcp_test_data_sn_size[i],
7201 .hfn = pdcp_test_hfn[i],
7202 .hfn_threshold = pdcp_test_hfn_threshold[i],
7204 .crypto_xform = &ut_params->cipher_xform
7207 /* Create security session */
7208 ut_params->sec_session = rte_security_session_create(ctx,
7209 &sess_conf, ts_params->session_priv_mpool);
7211 if (!ut_params->sec_session) {
7212 printf("TestCase %s()-%d line %d failed %s: ",
7213 __func__, i, __LINE__, "Failed to allocate session");
7218 /* Generate crypto op data structure */
7219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7221 if (!ut_params->op) {
7222 printf("TestCase %s()-%d line %d failed %s: ",
7223 __func__, i, __LINE__,
7224 "Failed to allocate symmetric crypto operation struct");
7229 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7231 /* set crypto operation source mbuf */
7232 ut_params->op->sym->m_src = ut_params->ibuf;
7234 ut_params->op->sym->m_dst = ut_params->obuf;
7236 /* Process crypto operation */
7237 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7239 printf("TestCase %s()-%d line %d failed %s: ",
7240 __func__, i, __LINE__,
7241 "failed to process sym crypto op");
7246 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7247 printf("TestCase %s()-%d line %d failed %s: ",
7248 __func__, i, __LINE__, "crypto op processing failed");
7254 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7257 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7261 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7262 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7263 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7264 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7270 rte_crypto_op_free(ut_params->op);
7271 ut_params->op = NULL;
7273 if (ut_params->sec_session)
7274 rte_security_session_destroy(ctx, ut_params->sec_session);
7275 ut_params->sec_session = NULL;
7277 rte_pktmbuf_free(ut_params->ibuf);
7278 ut_params->ibuf = NULL;
7280 rte_pktmbuf_free(ut_params->obuf);
7281 ut_params->obuf = NULL;
7288 test_pdcp_proto_SGL(int i, int oop,
7289 enum rte_crypto_cipher_operation opc,
7290 enum rte_crypto_auth_operation opa,
7292 unsigned int input_vec_len,
7293 uint8_t *output_vec,
7294 unsigned int output_vec_len,
7296 uint32_t fragsz_oop)
7298 struct crypto_testsuite_params *ts_params = &testsuite_params;
7299 struct crypto_unittest_params *ut_params = &unittest_params;
7301 struct rte_mbuf *buf, *buf_oop = NULL;
7302 int ret = TEST_SUCCESS;
7306 unsigned int trn_data = 0;
7307 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7308 rte_cryptodev_get_sec_ctx(
7309 ts_params->valid_devs[0]);
7311 /* Verify the capabilities */
7312 struct rte_security_capability_idx sec_cap_idx;
7314 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7315 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7316 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7317 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7320 if (fragsz > input_vec_len)
7321 fragsz = input_vec_len;
7323 uint16_t plaintext_len = fragsz;
7324 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7326 if (fragsz_oop > output_vec_len)
7327 frag_size_oop = output_vec_len;
7330 if (input_vec_len % fragsz != 0) {
7331 if (input_vec_len / fragsz + 1 > 16)
7333 } else if (input_vec_len / fragsz > 16)
7336 /* Out of place support */
7339 * For out-op-place we need to alloc another mbuf
7341 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7342 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7343 buf_oop = ut_params->obuf;
7346 /* Generate test mbuf data */
7347 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7349 /* clear mbuf payload */
7350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7351 rte_pktmbuf_tailroom(ut_params->ibuf));
7353 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7355 memcpy(plaintext, input_vec, plaintext_len);
7356 trn_data += plaintext_len;
7358 buf = ut_params->ibuf;
7361 * Loop until no more fragments
7364 while (trn_data < input_vec_len) {
7366 to_trn = (input_vec_len - trn_data < fragsz) ?
7367 (input_vec_len - trn_data) : fragsz;
7369 to_trn_tbl[ecx++] = to_trn;
7371 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7374 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7375 rte_pktmbuf_tailroom(buf));
7378 if (oop && !fragsz_oop) {
7380 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7381 buf_oop = buf_oop->next;
7382 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7383 0, rte_pktmbuf_tailroom(buf_oop));
7384 rte_pktmbuf_append(buf_oop, to_trn);
7387 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7390 memcpy(plaintext, input_vec + trn_data, to_trn);
7394 ut_params->ibuf->nb_segs = segs;
7397 if (fragsz_oop && oop) {
7401 trn_data = frag_size_oop;
7402 while (trn_data < output_vec_len) {
7405 (output_vec_len - trn_data <
7407 (output_vec_len - trn_data) :
7410 to_trn_tbl[ecx++] = to_trn;
7413 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7414 buf_oop = buf_oop->next;
7415 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7416 0, rte_pktmbuf_tailroom(buf_oop));
7417 rte_pktmbuf_append(buf_oop, to_trn);
7421 ut_params->obuf->nb_segs = segs;
7424 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7426 /* Setup Cipher Parameters */
7427 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7428 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7429 ut_params->cipher_xform.cipher.op = opc;
7430 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7431 ut_params->cipher_xform.cipher.key.length =
7432 pdcp_test_params[i].cipher_key_len;
7433 ut_params->cipher_xform.cipher.iv.length = 0;
7435 /* Setup HMAC Parameters if ICV header is required */
7436 if (pdcp_test_params[i].auth_alg != 0) {
7437 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7438 ut_params->auth_xform.next = NULL;
7439 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7440 ut_params->auth_xform.auth.op = opa;
7441 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7442 ut_params->auth_xform.auth.key.length =
7443 pdcp_test_params[i].auth_key_len;
7445 ut_params->cipher_xform.next = &ut_params->auth_xform;
7447 ut_params->cipher_xform.next = NULL;
7450 struct rte_security_session_conf sess_conf = {
7451 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7452 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7454 .bearer = pdcp_test_bearer[i],
7455 .domain = pdcp_test_params[i].domain,
7456 .pkt_dir = pdcp_test_packet_direction[i],
7457 .sn_size = pdcp_test_data_sn_size[i],
7458 .hfn = pdcp_test_hfn[i],
7459 .hfn_threshold = pdcp_test_hfn_threshold[i],
7461 .crypto_xform = &ut_params->cipher_xform
7464 /* Create security session */
7465 ut_params->sec_session = rte_security_session_create(ctx,
7466 &sess_conf, ts_params->session_priv_mpool);
7468 if (!ut_params->sec_session) {
7469 printf("TestCase %s()-%d line %d failed %s: ",
7470 __func__, i, __LINE__, "Failed to allocate session");
7475 /* Generate crypto op data structure */
7476 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7477 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7478 if (!ut_params->op) {
7479 printf("TestCase %s()-%d line %d failed %s: ",
7480 __func__, i, __LINE__,
7481 "Failed to allocate symmetric crypto operation struct");
7486 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7488 /* set crypto operation source mbuf */
7489 ut_params->op->sym->m_src = ut_params->ibuf;
7491 ut_params->op->sym->m_dst = ut_params->obuf;
7493 /* Process crypto operation */
7494 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7496 printf("TestCase %s()-%d line %d failed %s: ",
7497 __func__, i, __LINE__,
7498 "failed to process sym crypto op");
7503 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7504 printf("TestCase %s()-%d line %d failed %s: ",
7505 __func__, i, __LINE__, "crypto op processing failed");
7511 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7514 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7518 fragsz = frag_size_oop;
7519 if (memcmp(ciphertext, output_vec, fragsz)) {
7520 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7521 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7522 rte_hexdump(stdout, "reference", output_vec, fragsz);
7527 buf = ut_params->op->sym->m_src->next;
7529 buf = ut_params->op->sym->m_dst->next;
7531 unsigned int off = fragsz;
7535 ciphertext = rte_pktmbuf_mtod(buf,
7537 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7538 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7539 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7540 rte_hexdump(stdout, "reference", output_vec + off,
7545 off += to_trn_tbl[ecx++];
7549 rte_crypto_op_free(ut_params->op);
7550 ut_params->op = NULL;
7552 if (ut_params->sec_session)
7553 rte_security_session_destroy(ctx, ut_params->sec_session);
7554 ut_params->sec_session = NULL;
7556 rte_pktmbuf_free(ut_params->ibuf);
7557 ut_params->ibuf = NULL;
7559 rte_pktmbuf_free(ut_params->obuf);
7560 ut_params->obuf = NULL;
7567 test_pdcp_proto_cplane_encap(int i)
7569 return test_pdcp_proto(i, 0,
7570 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7571 RTE_CRYPTO_AUTH_OP_GENERATE,
7572 pdcp_test_data_in[i],
7573 pdcp_test_data_in_len[i],
7574 pdcp_test_data_out[i],
7575 pdcp_test_data_in_len[i]+4);
7579 test_pdcp_proto_uplane_encap(int i)
7581 return test_pdcp_proto(i, 0,
7582 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7583 RTE_CRYPTO_AUTH_OP_GENERATE,
7584 pdcp_test_data_in[i],
7585 pdcp_test_data_in_len[i],
7586 pdcp_test_data_out[i],
7587 pdcp_test_data_in_len[i]);
7592 test_pdcp_proto_uplane_encap_with_int(int i)
7594 return test_pdcp_proto(i, 0,
7595 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7596 RTE_CRYPTO_AUTH_OP_GENERATE,
7597 pdcp_test_data_in[i],
7598 pdcp_test_data_in_len[i],
7599 pdcp_test_data_out[i],
7600 pdcp_test_data_in_len[i] + 4);
7604 test_pdcp_proto_cplane_decap(int i)
7606 return test_pdcp_proto(i, 0,
7607 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7608 RTE_CRYPTO_AUTH_OP_VERIFY,
7609 pdcp_test_data_out[i],
7610 pdcp_test_data_in_len[i] + 4,
7611 pdcp_test_data_in[i],
7612 pdcp_test_data_in_len[i]);
7616 test_pdcp_proto_uplane_decap(int i)
7618 return test_pdcp_proto(i, 0,
7619 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7620 RTE_CRYPTO_AUTH_OP_VERIFY,
7621 pdcp_test_data_out[i],
7622 pdcp_test_data_in_len[i],
7623 pdcp_test_data_in[i],
7624 pdcp_test_data_in_len[i]);
7628 test_pdcp_proto_uplane_decap_with_int(int i)
7630 return test_pdcp_proto(i, 0,
7631 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7632 RTE_CRYPTO_AUTH_OP_VERIFY,
7633 pdcp_test_data_out[i],
7634 pdcp_test_data_in_len[i] + 4,
7635 pdcp_test_data_in[i],
7636 pdcp_test_data_in_len[i]);
7640 test_PDCP_PROTO_SGL_in_place_32B(void)
7642 /* i can be used for running any PDCP case
7643 * In this case it is uplane 12-bit AES-SNOW DL encap
7645 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7646 return test_pdcp_proto_SGL(i, IN_PLACE,
7647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7648 RTE_CRYPTO_AUTH_OP_GENERATE,
7649 pdcp_test_data_in[i],
7650 pdcp_test_data_in_len[i],
7651 pdcp_test_data_out[i],
7652 pdcp_test_data_in_len[i]+4,
7656 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7658 /* i can be used for running any PDCP case
7659 * In this case it is uplane 18-bit NULL-NULL DL encap
7661 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7662 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 RTE_CRYPTO_AUTH_OP_GENERATE,
7665 pdcp_test_data_in[i],
7666 pdcp_test_data_in_len[i],
7667 pdcp_test_data_out[i],
7668 pdcp_test_data_in_len[i]+4,
7672 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7674 /* i can be used for running any PDCP case
7675 * In this case it is uplane 18-bit AES DL encap
7677 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7679 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7680 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7681 RTE_CRYPTO_AUTH_OP_GENERATE,
7682 pdcp_test_data_in[i],
7683 pdcp_test_data_in_len[i],
7684 pdcp_test_data_out[i],
7685 pdcp_test_data_in_len[i],
7689 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7691 /* i can be used for running any PDCP case
7692 * In this case it is cplane 12-bit AES-ZUC DL encap
7694 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7695 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7697 RTE_CRYPTO_AUTH_OP_GENERATE,
7698 pdcp_test_data_in[i],
7699 pdcp_test_data_in_len[i],
7700 pdcp_test_data_out[i],
7701 pdcp_test_data_in_len[i]+4,
7706 test_PDCP_PROTO_all(void)
7708 struct crypto_testsuite_params *ts_params = &testsuite_params;
7709 struct rte_cryptodev_info dev_info;
7712 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7713 uint64_t feat_flags = dev_info.feature_flags;
7715 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7718 status = test_PDCP_PROTO_cplane_encap_all();
7719 status += test_PDCP_PROTO_cplane_decap_all();
7720 status += test_PDCP_PROTO_uplane_encap_all();
7721 status += test_PDCP_PROTO_uplane_decap_all();
7722 status += test_PDCP_PROTO_SGL_in_place_32B();
7723 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7724 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7725 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7730 return TEST_SUCCESS;
7735 test_AES_GCM_authenticated_encryption_test_case_1(void)
7737 return test_authenticated_encryption(&gcm_test_case_1);
7741 test_AES_GCM_authenticated_encryption_test_case_2(void)
7743 return test_authenticated_encryption(&gcm_test_case_2);
7747 test_AES_GCM_authenticated_encryption_test_case_3(void)
7749 return test_authenticated_encryption(&gcm_test_case_3);
7753 test_AES_GCM_authenticated_encryption_test_case_4(void)
7755 return test_authenticated_encryption(&gcm_test_case_4);
7759 test_AES_GCM_authenticated_encryption_test_case_5(void)
7761 return test_authenticated_encryption(&gcm_test_case_5);
7765 test_AES_GCM_authenticated_encryption_test_case_6(void)
7767 return test_authenticated_encryption(&gcm_test_case_6);
7771 test_AES_GCM_authenticated_encryption_test_case_7(void)
7773 return test_authenticated_encryption(&gcm_test_case_7);
7777 test_AES_GCM_authenticated_encryption_test_case_8(void)
7779 return test_authenticated_encryption(&gcm_test_case_8);
7783 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7785 return test_authenticated_encryption(&gcm_J0_test_case_1);
7789 test_AES_GCM_auth_encryption_test_case_192_1(void)
7791 return test_authenticated_encryption(&gcm_test_case_192_1);
7795 test_AES_GCM_auth_encryption_test_case_192_2(void)
7797 return test_authenticated_encryption(&gcm_test_case_192_2);
7801 test_AES_GCM_auth_encryption_test_case_192_3(void)
7803 return test_authenticated_encryption(&gcm_test_case_192_3);
7807 test_AES_GCM_auth_encryption_test_case_192_4(void)
7809 return test_authenticated_encryption(&gcm_test_case_192_4);
7813 test_AES_GCM_auth_encryption_test_case_192_5(void)
7815 return test_authenticated_encryption(&gcm_test_case_192_5);
7819 test_AES_GCM_auth_encryption_test_case_192_6(void)
7821 return test_authenticated_encryption(&gcm_test_case_192_6);
7825 test_AES_GCM_auth_encryption_test_case_192_7(void)
7827 return test_authenticated_encryption(&gcm_test_case_192_7);
7831 test_AES_GCM_auth_encryption_test_case_256_1(void)
7833 return test_authenticated_encryption(&gcm_test_case_256_1);
7837 test_AES_GCM_auth_encryption_test_case_256_2(void)
7839 return test_authenticated_encryption(&gcm_test_case_256_2);
7843 test_AES_GCM_auth_encryption_test_case_256_3(void)
7845 return test_authenticated_encryption(&gcm_test_case_256_3);
7849 test_AES_GCM_auth_encryption_test_case_256_4(void)
7851 return test_authenticated_encryption(&gcm_test_case_256_4);
7855 test_AES_GCM_auth_encryption_test_case_256_5(void)
7857 return test_authenticated_encryption(&gcm_test_case_256_5);
7861 test_AES_GCM_auth_encryption_test_case_256_6(void)
7863 return test_authenticated_encryption(&gcm_test_case_256_6);
7867 test_AES_GCM_auth_encryption_test_case_256_7(void)
7869 return test_authenticated_encryption(&gcm_test_case_256_7);
7873 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7875 return test_authenticated_encryption(&gcm_test_case_aad_1);
7879 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7881 return test_authenticated_encryption(&gcm_test_case_aad_2);
7885 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7887 struct aead_test_data tdata;
7890 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7891 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7892 tdata.iv.data[0] += 1;
7893 res = test_authenticated_encryption(&tdata);
7894 if (res == -ENOTSUP)
7896 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7897 return TEST_SUCCESS;
7901 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7903 struct aead_test_data tdata;
7906 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7907 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7908 tdata.plaintext.data[0] += 1;
7909 res = test_authenticated_encryption(&tdata);
7910 if (res == -ENOTSUP)
7912 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7913 return TEST_SUCCESS;
7917 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7919 struct aead_test_data tdata;
7922 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7923 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7924 tdata.ciphertext.data[0] += 1;
7925 res = test_authenticated_encryption(&tdata);
7926 if (res == -ENOTSUP)
7928 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7929 return TEST_SUCCESS;
7933 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7935 struct aead_test_data tdata;
7938 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7939 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7941 res = test_authenticated_encryption(&tdata);
7942 if (res == -ENOTSUP)
7944 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7945 return TEST_SUCCESS;
7949 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7951 struct aead_test_data tdata;
7952 uint8_t aad[gcm_test_case_7.aad.len];
7955 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7956 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7957 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7959 tdata.aad.data = aad;
7960 res = test_authenticated_encryption(&tdata);
7961 if (res == -ENOTSUP)
7963 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7964 return TEST_SUCCESS;
7968 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7970 struct aead_test_data tdata;
7973 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7974 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7975 tdata.auth_tag.data[0] += 1;
7976 res = test_authenticated_encryption(&tdata);
7977 if (res == -ENOTSUP)
7979 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7980 return TEST_SUCCESS;
7984 test_authenticated_decryption(const struct aead_test_data *tdata)
7986 struct crypto_testsuite_params *ts_params = &testsuite_params;
7987 struct crypto_unittest_params *ut_params = &unittest_params;
7993 /* Verify the capabilities */
7994 struct rte_cryptodev_sym_capability_idx cap_idx;
7995 const struct rte_cryptodev_symmetric_capability *capability;
7996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7997 cap_idx.algo.aead = tdata->algo;
7998 capability = rte_cryptodev_sym_capability_get(
7999 ts_params->valid_devs[0], &cap_idx);
8000 if (capability == NULL)
8002 if (rte_cryptodev_sym_capability_check_aead(
8003 capability, tdata->key.len, tdata->auth_tag.len,
8004 tdata->aad.len, tdata->iv.len))
8007 /* Create AEAD session */
8008 retval = create_aead_session(ts_params->valid_devs[0],
8010 RTE_CRYPTO_AEAD_OP_DECRYPT,
8011 tdata->key.data, tdata->key.len,
8012 tdata->aad.len, tdata->auth_tag.len,
8017 /* alloc mbuf and set payload */
8018 if (tdata->aad.len > MBUF_SIZE) {
8019 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8020 /* Populate full size of add data */
8021 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8022 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8024 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8026 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8027 rte_pktmbuf_tailroom(ut_params->ibuf));
8029 /* Create AEAD operation */
8030 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8034 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8036 ut_params->op->sym->m_src = ut_params->ibuf;
8038 /* Process crypto operation */
8039 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8040 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8042 TEST_ASSERT_NOT_NULL(
8043 process_crypto_request(ts_params->valid_devs[0],
8044 ut_params->op), "failed to process sym crypto op");
8046 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8047 "crypto op processing failed");
8049 if (ut_params->op->sym->m_dst)
8050 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8053 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8055 ut_params->op->sym->cipher.data.offset);
8057 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8060 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8062 tdata->plaintext.data,
8063 tdata->plaintext.len,
8064 "Plaintext data not as expected");
8066 TEST_ASSERT_EQUAL(ut_params->op->status,
8067 RTE_CRYPTO_OP_STATUS_SUCCESS,
8068 "Authentication failed");
8074 test_AES_GCM_authenticated_decryption_test_case_1(void)
8076 return test_authenticated_decryption(&gcm_test_case_1);
8080 test_AES_GCM_authenticated_decryption_test_case_2(void)
8082 return test_authenticated_decryption(&gcm_test_case_2);
8086 test_AES_GCM_authenticated_decryption_test_case_3(void)
8088 return test_authenticated_decryption(&gcm_test_case_3);
8092 test_AES_GCM_authenticated_decryption_test_case_4(void)
8094 return test_authenticated_decryption(&gcm_test_case_4);
8098 test_AES_GCM_authenticated_decryption_test_case_5(void)
8100 return test_authenticated_decryption(&gcm_test_case_5);
8104 test_AES_GCM_authenticated_decryption_test_case_6(void)
8106 return test_authenticated_decryption(&gcm_test_case_6);
8110 test_AES_GCM_authenticated_decryption_test_case_7(void)
8112 return test_authenticated_decryption(&gcm_test_case_7);
8116 test_AES_GCM_authenticated_decryption_test_case_8(void)
8118 return test_authenticated_decryption(&gcm_test_case_8);
8122 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8124 return test_authenticated_decryption(&gcm_J0_test_case_1);
8128 test_AES_GCM_auth_decryption_test_case_192_1(void)
8130 return test_authenticated_decryption(&gcm_test_case_192_1);
8134 test_AES_GCM_auth_decryption_test_case_192_2(void)
8136 return test_authenticated_decryption(&gcm_test_case_192_2);
8140 test_AES_GCM_auth_decryption_test_case_192_3(void)
8142 return test_authenticated_decryption(&gcm_test_case_192_3);
8146 test_AES_GCM_auth_decryption_test_case_192_4(void)
8148 return test_authenticated_decryption(&gcm_test_case_192_4);
8152 test_AES_GCM_auth_decryption_test_case_192_5(void)
8154 return test_authenticated_decryption(&gcm_test_case_192_5);
8158 test_AES_GCM_auth_decryption_test_case_192_6(void)
8160 return test_authenticated_decryption(&gcm_test_case_192_6);
8164 test_AES_GCM_auth_decryption_test_case_192_7(void)
8166 return test_authenticated_decryption(&gcm_test_case_192_7);
8170 test_AES_GCM_auth_decryption_test_case_256_1(void)
8172 return test_authenticated_decryption(&gcm_test_case_256_1);
8176 test_AES_GCM_auth_decryption_test_case_256_2(void)
8178 return test_authenticated_decryption(&gcm_test_case_256_2);
8182 test_AES_GCM_auth_decryption_test_case_256_3(void)
8184 return test_authenticated_decryption(&gcm_test_case_256_3);
8188 test_AES_GCM_auth_decryption_test_case_256_4(void)
8190 return test_authenticated_decryption(&gcm_test_case_256_4);
8194 test_AES_GCM_auth_decryption_test_case_256_5(void)
8196 return test_authenticated_decryption(&gcm_test_case_256_5);
8200 test_AES_GCM_auth_decryption_test_case_256_6(void)
8202 return test_authenticated_decryption(&gcm_test_case_256_6);
8206 test_AES_GCM_auth_decryption_test_case_256_7(void)
8208 return test_authenticated_decryption(&gcm_test_case_256_7);
8212 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8214 return test_authenticated_decryption(&gcm_test_case_aad_1);
8218 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8220 return test_authenticated_decryption(&gcm_test_case_aad_2);
8224 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8226 struct aead_test_data tdata;
8229 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8230 tdata.iv.data[0] += 1;
8231 res = test_authenticated_decryption(&tdata);
8232 if (res == -ENOTSUP)
8234 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8235 return TEST_SUCCESS;
8239 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8241 struct aead_test_data tdata;
8244 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8245 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8246 tdata.plaintext.data[0] += 1;
8247 res = test_authenticated_decryption(&tdata);
8248 if (res == -ENOTSUP)
8250 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8251 return TEST_SUCCESS;
8255 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8257 struct aead_test_data tdata;
8260 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8261 tdata.ciphertext.data[0] += 1;
8262 res = test_authenticated_decryption(&tdata);
8263 if (res == -ENOTSUP)
8265 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8266 return TEST_SUCCESS;
8270 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8272 struct aead_test_data tdata;
8275 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8277 res = test_authenticated_decryption(&tdata);
8278 if (res == -ENOTSUP)
8280 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8281 return TEST_SUCCESS;
8285 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8287 struct aead_test_data tdata;
8288 uint8_t aad[gcm_test_case_7.aad.len];
8291 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8292 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8294 tdata.aad.data = aad;
8295 res = test_authenticated_decryption(&tdata);
8296 if (res == -ENOTSUP)
8298 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8299 return TEST_SUCCESS;
8303 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8305 struct aead_test_data tdata;
8308 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8309 tdata.auth_tag.data[0] += 1;
8310 res = test_authenticated_decryption(&tdata);
8311 if (res == -ENOTSUP)
8313 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8314 return TEST_SUCCESS;
8318 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8320 struct crypto_testsuite_params *ts_params = &testsuite_params;
8321 struct crypto_unittest_params *ut_params = &unittest_params;
8324 uint8_t *ciphertext, *auth_tag;
8325 uint16_t plaintext_pad_len;
8327 /* Verify the capabilities */
8328 struct rte_cryptodev_sym_capability_idx cap_idx;
8329 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8330 cap_idx.algo.aead = tdata->algo;
8331 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8335 /* not supported with CPU crypto */
8336 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8339 /* Create AEAD session */
8340 retval = create_aead_session(ts_params->valid_devs[0],
8342 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8343 tdata->key.data, tdata->key.len,
8344 tdata->aad.len, tdata->auth_tag.len,
8349 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8350 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8352 /* clear mbuf payload */
8353 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8354 rte_pktmbuf_tailroom(ut_params->ibuf));
8355 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8356 rte_pktmbuf_tailroom(ut_params->obuf));
8358 /* Create AEAD operation */
8359 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8363 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8365 ut_params->op->sym->m_src = ut_params->ibuf;
8366 ut_params->op->sym->m_dst = ut_params->obuf;
8368 /* Process crypto operation */
8369 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8370 ut_params->op), "failed to process sym crypto op");
8372 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8373 "crypto op processing failed");
8375 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8377 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8378 ut_params->op->sym->cipher.data.offset);
8379 auth_tag = ciphertext + plaintext_pad_len;
8381 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8382 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8385 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8387 tdata->ciphertext.data,
8388 tdata->ciphertext.len,
8389 "Ciphertext data not as expected");
8391 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8393 tdata->auth_tag.data,
8394 tdata->auth_tag.len,
8395 "Generated auth tag not as expected");
8402 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8404 return test_authenticated_encryption_oop(&gcm_test_case_5);
8408 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8410 struct crypto_testsuite_params *ts_params = &testsuite_params;
8411 struct crypto_unittest_params *ut_params = &unittest_params;
8416 /* Verify the capabilities */
8417 struct rte_cryptodev_sym_capability_idx cap_idx;
8418 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8419 cap_idx.algo.aead = tdata->algo;
8420 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8424 /* not supported with CPU crypto */
8425 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8428 /* Create AEAD session */
8429 retval = create_aead_session(ts_params->valid_devs[0],
8431 RTE_CRYPTO_AEAD_OP_DECRYPT,
8432 tdata->key.data, tdata->key.len,
8433 tdata->aad.len, tdata->auth_tag.len,
8438 /* alloc mbuf and set payload */
8439 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8440 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8442 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8443 rte_pktmbuf_tailroom(ut_params->ibuf));
8444 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8445 rte_pktmbuf_tailroom(ut_params->obuf));
8447 /* Create AEAD operation */
8448 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8452 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8454 ut_params->op->sym->m_src = ut_params->ibuf;
8455 ut_params->op->sym->m_dst = ut_params->obuf;
8457 /* Process crypto operation */
8458 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8459 ut_params->op), "failed to process sym crypto op");
8461 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8462 "crypto op processing failed");
8464 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8465 ut_params->op->sym->cipher.data.offset);
8467 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8470 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8472 tdata->plaintext.data,
8473 tdata->plaintext.len,
8474 "Plaintext data not as expected");
8476 TEST_ASSERT_EQUAL(ut_params->op->status,
8477 RTE_CRYPTO_OP_STATUS_SUCCESS,
8478 "Authentication failed");
8483 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8485 return test_authenticated_decryption_oop(&gcm_test_case_5);
8489 test_authenticated_encryption_sessionless(
8490 const struct aead_test_data *tdata)
8492 struct crypto_testsuite_params *ts_params = &testsuite_params;
8493 struct crypto_unittest_params *ut_params = &unittest_params;
8496 uint8_t *ciphertext, *auth_tag;
8497 uint16_t plaintext_pad_len;
8498 uint8_t key[tdata->key.len + 1];
8499 struct rte_cryptodev_info dev_info;
8501 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8502 uint64_t feat_flags = dev_info.feature_flags;
8504 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8505 printf("Device doesn't support Sessionless ops.\n");
8509 /* not supported with CPU crypto */
8510 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8513 /* Verify the capabilities */
8514 struct rte_cryptodev_sym_capability_idx cap_idx;
8515 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8516 cap_idx.algo.aead = tdata->algo;
8517 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8523 /* clear mbuf payload */
8524 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8525 rte_pktmbuf_tailroom(ut_params->ibuf));
8527 /* Create AEAD operation */
8528 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8532 /* Create GCM xform */
8533 memcpy(key, tdata->key.data, tdata->key.len);
8534 retval = create_aead_xform(ut_params->op,
8536 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8537 key, tdata->key.len,
8538 tdata->aad.len, tdata->auth_tag.len,
8543 ut_params->op->sym->m_src = ut_params->ibuf;
8545 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8546 RTE_CRYPTO_OP_SESSIONLESS,
8547 "crypto op session type not sessionless");
8549 /* Process crypto operation */
8550 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8551 ut_params->op), "failed to process sym crypto op");
8553 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8555 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8556 "crypto op status not success");
8558 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8560 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8561 ut_params->op->sym->cipher.data.offset);
8562 auth_tag = ciphertext + plaintext_pad_len;
8564 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8565 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8568 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8570 tdata->ciphertext.data,
8571 tdata->ciphertext.len,
8572 "Ciphertext data not as expected");
8574 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8576 tdata->auth_tag.data,
8577 tdata->auth_tag.len,
8578 "Generated auth tag not as expected");
8585 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8587 return test_authenticated_encryption_sessionless(
8592 test_authenticated_decryption_sessionless(
8593 const struct aead_test_data *tdata)
8595 struct crypto_testsuite_params *ts_params = &testsuite_params;
8596 struct crypto_unittest_params *ut_params = &unittest_params;
8600 uint8_t key[tdata->key.len + 1];
8601 struct rte_cryptodev_info dev_info;
8603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8604 uint64_t feat_flags = dev_info.feature_flags;
8606 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8607 printf("Device doesn't support Sessionless ops.\n");
8611 /* not supported with CPU crypto */
8612 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8615 /* Verify the capabilities */
8616 struct rte_cryptodev_sym_capability_idx cap_idx;
8617 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8618 cap_idx.algo.aead = tdata->algo;
8619 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8623 /* alloc mbuf and set payload */
8624 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8626 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8627 rte_pktmbuf_tailroom(ut_params->ibuf));
8629 /* Create AEAD operation */
8630 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8634 /* Create AEAD xform */
8635 memcpy(key, tdata->key.data, tdata->key.len);
8636 retval = create_aead_xform(ut_params->op,
8638 RTE_CRYPTO_AEAD_OP_DECRYPT,
8639 key, tdata->key.len,
8640 tdata->aad.len, tdata->auth_tag.len,
8645 ut_params->op->sym->m_src = ut_params->ibuf;
8647 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8648 RTE_CRYPTO_OP_SESSIONLESS,
8649 "crypto op session type not sessionless");
8651 /* Process crypto operation */
8652 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8653 ut_params->op), "failed to process sym crypto op");
8655 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8657 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8658 "crypto op status not success");
8660 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8661 ut_params->op->sym->cipher.data.offset);
8663 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8666 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8668 tdata->plaintext.data,
8669 tdata->plaintext.len,
8670 "Plaintext data not as expected");
8672 TEST_ASSERT_EQUAL(ut_params->op->status,
8673 RTE_CRYPTO_OP_STATUS_SUCCESS,
8674 "Authentication failed");
8679 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8681 return test_authenticated_decryption_sessionless(
8686 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8688 return test_authenticated_encryption(&ccm_test_case_128_1);
8692 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8694 return test_authenticated_encryption(&ccm_test_case_128_2);
8698 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8700 return test_authenticated_encryption(&ccm_test_case_128_3);
8704 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8706 return test_authenticated_decryption(&ccm_test_case_128_1);
8710 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8712 return test_authenticated_decryption(&ccm_test_case_128_2);
8716 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8718 return test_authenticated_decryption(&ccm_test_case_128_3);
8722 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8724 return test_authenticated_encryption(&ccm_test_case_192_1);
8728 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8730 return test_authenticated_encryption(&ccm_test_case_192_2);
8734 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8736 return test_authenticated_encryption(&ccm_test_case_192_3);
8740 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8742 return test_authenticated_decryption(&ccm_test_case_192_1);
8746 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8748 return test_authenticated_decryption(&ccm_test_case_192_2);
8752 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8754 return test_authenticated_decryption(&ccm_test_case_192_3);
8758 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8760 return test_authenticated_encryption(&ccm_test_case_256_1);
8764 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8766 return test_authenticated_encryption(&ccm_test_case_256_2);
8770 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8772 return test_authenticated_encryption(&ccm_test_case_256_3);
8776 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8778 return test_authenticated_decryption(&ccm_test_case_256_1);
8782 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8784 return test_authenticated_decryption(&ccm_test_case_256_2);
8788 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8790 return test_authenticated_decryption(&ccm_test_case_256_3);
8796 struct crypto_testsuite_params *ts_params = &testsuite_params;
8797 struct rte_cryptodev_stats stats;
8798 struct rte_cryptodev *dev;
8799 cryptodev_stats_get_t temp_pfn;
8801 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8804 /* Verify the capabilities */
8805 struct rte_cryptodev_sym_capability_idx cap_idx;
8806 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8807 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8808 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8811 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8812 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8813 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8817 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8818 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8819 &stats) == -ENODEV),
8820 "rte_cryptodev_stats_get invalid dev failed");
8821 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8822 "rte_cryptodev_stats_get invalid Param failed");
8823 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8824 temp_pfn = dev->dev_ops->stats_get;
8825 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8826 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8828 "rte_cryptodev_stats_get invalid Param failed");
8829 dev->dev_ops->stats_get = temp_pfn;
8831 /* Test expected values */
8833 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8835 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8837 "rte_cryptodev_stats_get failed");
8838 TEST_ASSERT((stats.enqueued_count == 1),
8839 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8840 TEST_ASSERT((stats.dequeued_count == 1),
8841 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8842 TEST_ASSERT((stats.enqueue_err_count == 0),
8843 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8844 TEST_ASSERT((stats.dequeue_err_count == 0),
8845 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8847 /* invalid device but should ignore and not reset device stats*/
8848 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8849 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8851 "rte_cryptodev_stats_get failed");
8852 TEST_ASSERT((stats.enqueued_count == 1),
8853 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8855 /* check that a valid reset clears stats */
8856 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8857 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8859 "rte_cryptodev_stats_get failed");
8860 TEST_ASSERT((stats.enqueued_count == 0),
8861 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8862 TEST_ASSERT((stats.dequeued_count == 0),
8863 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8865 return TEST_SUCCESS;
8868 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8869 struct crypto_unittest_params *ut_params,
8870 enum rte_crypto_auth_operation op,
8871 const struct HMAC_MD5_vector *test_case)
8875 memcpy(key, test_case->key.data, test_case->key.len);
8877 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8878 ut_params->auth_xform.next = NULL;
8879 ut_params->auth_xform.auth.op = op;
8881 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8883 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8884 ut_params->auth_xform.auth.key.length = test_case->key.len;
8885 ut_params->auth_xform.auth.key.data = key;
8887 ut_params->sess = rte_cryptodev_sym_session_create(
8888 ts_params->session_mpool);
8890 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8891 ut_params->sess, &ut_params->auth_xform,
8892 ts_params->session_priv_mpool);
8894 if (ut_params->sess == NULL)
8897 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8899 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8900 rte_pktmbuf_tailroom(ut_params->ibuf));
8905 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8906 const struct HMAC_MD5_vector *test_case,
8907 uint8_t **plaintext)
8909 uint16_t plaintext_pad_len;
8911 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8913 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8916 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8918 memcpy(*plaintext, test_case->plaintext.data,
8919 test_case->plaintext.len);
8921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8922 ut_params->ibuf, MD5_DIGEST_LEN);
8923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8924 "no room to append digest");
8925 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8926 ut_params->ibuf, plaintext_pad_len);
8928 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8929 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8930 test_case->auth_tag.len);
8933 sym_op->auth.data.offset = 0;
8934 sym_op->auth.data.length = test_case->plaintext.len;
8936 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8937 ut_params->op->sym->m_src = ut_params->ibuf;
8943 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8945 uint16_t plaintext_pad_len;
8946 uint8_t *plaintext, *auth_tag;
8948 struct crypto_testsuite_params *ts_params = &testsuite_params;
8949 struct crypto_unittest_params *ut_params = &unittest_params;
8951 /* Verify the capabilities */
8952 struct rte_cryptodev_sym_capability_idx cap_idx;
8953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8954 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8955 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8959 if (MD5_HMAC_create_session(ts_params, ut_params,
8960 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8963 /* Generate Crypto op data structure */
8964 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8965 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8966 TEST_ASSERT_NOT_NULL(ut_params->op,
8967 "Failed to allocate symmetric crypto operation struct");
8969 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8972 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8975 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8976 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8979 TEST_ASSERT_NOT_NULL(
8980 process_crypto_request(ts_params->valid_devs[0],
8982 "failed to process sym crypto op");
8984 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8985 "crypto op processing failed");
8987 if (ut_params->op->sym->m_dst) {
8988 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8989 uint8_t *, plaintext_pad_len);
8991 auth_tag = plaintext + plaintext_pad_len;
8994 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8996 test_case->auth_tag.data,
8997 test_case->auth_tag.len,
8998 "HMAC_MD5 generated tag not as expected");
9000 return TEST_SUCCESS;
9004 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9008 struct crypto_testsuite_params *ts_params = &testsuite_params;
9009 struct crypto_unittest_params *ut_params = &unittest_params;
9011 /* Verify the capabilities */
9012 struct rte_cryptodev_sym_capability_idx cap_idx;
9013 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9014 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9015 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9019 if (MD5_HMAC_create_session(ts_params, ut_params,
9020 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9024 /* Generate Crypto op data structure */
9025 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9026 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9027 TEST_ASSERT_NOT_NULL(ut_params->op,
9028 "Failed to allocate symmetric crypto operation struct");
9030 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9033 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9034 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9037 TEST_ASSERT_NOT_NULL(
9038 process_crypto_request(ts_params->valid_devs[0],
9040 "failed to process sym crypto op");
9042 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9043 "HMAC_MD5 crypto op processing failed");
9045 return TEST_SUCCESS;
9049 test_MD5_HMAC_generate_case_1(void)
9051 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9055 test_MD5_HMAC_verify_case_1(void)
9057 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9061 test_MD5_HMAC_generate_case_2(void)
9063 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9067 test_MD5_HMAC_verify_case_2(void)
9069 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9073 test_multi_session(void)
9075 struct crypto_testsuite_params *ts_params = &testsuite_params;
9076 struct crypto_unittest_params *ut_params = &unittest_params;
9078 struct rte_cryptodev_info dev_info;
9079 struct rte_cryptodev_sym_session **sessions;
9083 /* Verify the capabilities */
9084 struct rte_cryptodev_sym_capability_idx cap_idx;
9085 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9086 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9087 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9090 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9091 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9092 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9096 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9097 aes_cbc_key, hmac_sha512_key);
9100 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9102 sessions = rte_malloc(NULL,
9103 (sizeof(struct rte_cryptodev_sym_session *) *
9104 MAX_NB_SESSIONS) + 1, 0);
9106 /* Create multiple crypto sessions*/
9107 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9109 sessions[i] = rte_cryptodev_sym_session_create(
9110 ts_params->session_mpool);
9112 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9113 sessions[i], &ut_params->auth_xform,
9114 ts_params->session_priv_mpool);
9115 TEST_ASSERT_NOT_NULL(sessions[i],
9116 "Session creation failed at session number %u",
9119 /* Attempt to send a request on each session */
9120 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9124 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9125 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9127 "Failed to perform decrypt on request number %u.", i);
9128 /* free crypto operation structure */
9130 rte_crypto_op_free(ut_params->op);
9133 * free mbuf - both obuf and ibuf are usually the same,
9134 * so check if they point at the same address is necessary,
9135 * to avoid freeing the mbuf twice.
9137 if (ut_params->obuf) {
9138 rte_pktmbuf_free(ut_params->obuf);
9139 if (ut_params->ibuf == ut_params->obuf)
9140 ut_params->ibuf = 0;
9141 ut_params->obuf = 0;
9143 if (ut_params->ibuf) {
9144 rte_pktmbuf_free(ut_params->ibuf);
9145 ut_params->ibuf = 0;
9149 /* Next session create should fail */
9150 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9151 sessions[i], &ut_params->auth_xform,
9152 ts_params->session_priv_mpool);
9153 TEST_ASSERT_NULL(sessions[i],
9154 "Session creation succeeded unexpectedly!");
9156 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9157 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9159 rte_cryptodev_sym_session_free(sessions[i]);
9164 return TEST_SUCCESS;
9167 struct multi_session_params {
9168 struct crypto_unittest_params ut_params;
9169 uint8_t *cipher_key;
9171 const uint8_t *cipher;
9172 const uint8_t *digest;
9176 #define MB_SESSION_NUMBER 3
9179 test_multi_session_random_usage(void)
9181 struct crypto_testsuite_params *ts_params = &testsuite_params;
9182 struct rte_cryptodev_info dev_info;
9183 struct rte_cryptodev_sym_session **sessions;
9185 struct multi_session_params ut_paramz[] = {
9188 .cipher_key = ms_aes_cbc_key0,
9189 .hmac_key = ms_hmac_key0,
9190 .cipher = ms_aes_cbc_cipher0,
9191 .digest = ms_hmac_digest0,
9192 .iv = ms_aes_cbc_iv0
9195 .cipher_key = ms_aes_cbc_key1,
9196 .hmac_key = ms_hmac_key1,
9197 .cipher = ms_aes_cbc_cipher1,
9198 .digest = ms_hmac_digest1,
9199 .iv = ms_aes_cbc_iv1
9202 .cipher_key = ms_aes_cbc_key2,
9203 .hmac_key = ms_hmac_key2,
9204 .cipher = ms_aes_cbc_cipher2,
9205 .digest = ms_hmac_digest2,
9206 .iv = ms_aes_cbc_iv2
9211 /* Verify the capabilities */
9212 struct rte_cryptodev_sym_capability_idx cap_idx;
9213 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9214 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9215 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9218 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9219 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9220 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9224 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9226 sessions = rte_malloc(NULL,
9227 (sizeof(struct rte_cryptodev_sym_session *)
9228 * MAX_NB_SESSIONS) + 1, 0);
9230 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9231 sessions[i] = rte_cryptodev_sym_session_create(
9232 ts_params->session_mpool);
9234 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9235 sizeof(struct crypto_unittest_params));
9237 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9238 &ut_paramz[i].ut_params,
9239 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9241 /* Create multiple crypto sessions*/
9242 rte_cryptodev_sym_session_init(
9243 ts_params->valid_devs[0],
9245 &ut_paramz[i].ut_params.auth_xform,
9246 ts_params->session_priv_mpool);
9248 TEST_ASSERT_NOT_NULL(sessions[i],
9249 "Session creation failed at session number %u",
9255 for (i = 0; i < 40000; i++) {
9257 j = rand() % MB_SESSION_NUMBER;
9259 TEST_ASSERT_SUCCESS(
9260 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9262 &ut_paramz[j].ut_params,
9263 ts_params, ut_paramz[j].cipher,
9264 ut_paramz[j].digest,
9266 "Failed to perform decrypt on request number %u.", i);
9268 if (ut_paramz[j].ut_params.op)
9269 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9272 * free mbuf - both obuf and ibuf are usually the same,
9273 * so check if they point at the same address is necessary,
9274 * to avoid freeing the mbuf twice.
9276 if (ut_paramz[j].ut_params.obuf) {
9277 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9278 if (ut_paramz[j].ut_params.ibuf
9279 == ut_paramz[j].ut_params.obuf)
9280 ut_paramz[j].ut_params.ibuf = 0;
9281 ut_paramz[j].ut_params.obuf = 0;
9283 if (ut_paramz[j].ut_params.ibuf) {
9284 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9285 ut_paramz[j].ut_params.ibuf = 0;
9289 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9290 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9292 rte_cryptodev_sym_session_free(sessions[i]);
9297 return TEST_SUCCESS;
9301 test_null_cipher_only_operation(void)
9303 struct crypto_testsuite_params *ts_params = &testsuite_params;
9304 struct crypto_unittest_params *ut_params = &unittest_params;
9306 /* Verify the capabilities */
9307 struct rte_cryptodev_sym_capability_idx cap_idx;
9308 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9309 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9310 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9314 /* Generate test mbuf data and space for digest */
9315 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9316 catch_22_quote, QUOTE_512_BYTES, 0);
9318 /* Setup Cipher Parameters */
9319 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9320 ut_params->cipher_xform.next = NULL;
9322 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9323 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9325 ut_params->sess = rte_cryptodev_sym_session_create(
9326 ts_params->session_mpool);
9328 /* Create Crypto session*/
9329 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9331 &ut_params->cipher_xform,
9332 ts_params->session_priv_mpool);
9333 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9335 /* Generate Crypto op data structure */
9336 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9337 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9338 TEST_ASSERT_NOT_NULL(ut_params->op,
9339 "Failed to allocate symmetric crypto operation struct");
9341 /* Set crypto operation data parameters */
9342 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9344 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9346 /* set crypto operation source mbuf */
9347 sym_op->m_src = ut_params->ibuf;
9349 sym_op->cipher.data.offset = 0;
9350 sym_op->cipher.data.length = QUOTE_512_BYTES;
9352 /* Process crypto operation */
9353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9355 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9357 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9358 "crypto operation processing failed");
9361 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9362 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9365 "Ciphertext data not as expected");
9367 return TEST_SUCCESS;
9369 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9370 0xab, 0xab, 0xab, 0xab,
9371 0xab, 0xab, 0xab, 0xab,
9372 0xab, 0xab, 0xab, 0xab};
9374 test_null_auth_only_operation(void)
9376 struct crypto_testsuite_params *ts_params = &testsuite_params;
9377 struct crypto_unittest_params *ut_params = &unittest_params;
9380 /* Verify the capabilities */
9381 struct rte_cryptodev_sym_capability_idx cap_idx;
9382 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9383 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9384 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9388 /* Generate test mbuf data and space for digest */
9389 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9390 catch_22_quote, QUOTE_512_BYTES, 0);
9392 /* create a pointer for digest, but don't expect anything to be written
9393 * here in a NULL auth algo so no mbuf append done.
9395 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9397 /* prefill the memory pointed to by digest */
9398 memcpy(digest, orig_data, sizeof(orig_data));
9400 /* Setup HMAC Parameters */
9401 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9402 ut_params->auth_xform.next = NULL;
9404 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9405 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9407 ut_params->sess = rte_cryptodev_sym_session_create(
9408 ts_params->session_mpool);
9410 /* Create Crypto session*/
9411 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9412 ut_params->sess, &ut_params->auth_xform,
9413 ts_params->session_priv_mpool);
9414 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9416 /* Generate Crypto op data structure */
9417 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9418 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9419 TEST_ASSERT_NOT_NULL(ut_params->op,
9420 "Failed to allocate symmetric crypto operation struct");
9422 /* Set crypto operation data parameters */
9423 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9425 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9427 sym_op->m_src = ut_params->ibuf;
9429 sym_op->auth.data.offset = 0;
9430 sym_op->auth.data.length = QUOTE_512_BYTES;
9431 sym_op->auth.digest.data = digest;
9432 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9435 /* Process crypto operation */
9436 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9438 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9440 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9441 "crypto operation processing failed");
9442 /* Make sure memory pointed to by digest hasn't been overwritten */
9443 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9447 "Memory at digest ptr overwritten unexpectedly");
9449 return TEST_SUCCESS;
9454 test_null_cipher_auth_operation(void)
9456 struct crypto_testsuite_params *ts_params = &testsuite_params;
9457 struct crypto_unittest_params *ut_params = &unittest_params;
9460 /* Verify the capabilities */
9461 struct rte_cryptodev_sym_capability_idx cap_idx;
9462 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9463 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9464 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9467 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9468 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9469 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9473 /* Generate test mbuf data and space for digest */
9474 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9475 catch_22_quote, QUOTE_512_BYTES, 0);
9477 /* create a pointer for digest, but don't expect anything to be written
9478 * here in a NULL auth algo so no mbuf append done.
9480 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9482 /* prefill the memory pointed to by digest */
9483 memcpy(digest, orig_data, sizeof(orig_data));
9485 /* Setup Cipher Parameters */
9486 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9487 ut_params->cipher_xform.next = &ut_params->auth_xform;
9489 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9490 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9492 /* Setup HMAC Parameters */
9493 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9494 ut_params->auth_xform.next = NULL;
9496 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9497 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9499 ut_params->sess = rte_cryptodev_sym_session_create(
9500 ts_params->session_mpool);
9502 /* Create Crypto session*/
9503 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9504 ut_params->sess, &ut_params->cipher_xform,
9505 ts_params->session_priv_mpool);
9506 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9508 /* Generate Crypto op data structure */
9509 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9510 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9511 TEST_ASSERT_NOT_NULL(ut_params->op,
9512 "Failed to allocate symmetric crypto operation struct");
9514 /* Set crypto operation data parameters */
9515 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9517 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9519 sym_op->m_src = ut_params->ibuf;
9521 sym_op->cipher.data.offset = 0;
9522 sym_op->cipher.data.length = QUOTE_512_BYTES;
9524 sym_op->auth.data.offset = 0;
9525 sym_op->auth.data.length = QUOTE_512_BYTES;
9526 sym_op->auth.digest.data = digest;
9527 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9530 /* Process crypto operation */
9531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9533 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9535 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9536 "crypto operation processing failed");
9539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9540 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9543 "Ciphertext data not as expected");
9544 /* Make sure memory pointed to by digest hasn't been overwritten */
9545 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9549 "Memory at digest ptr overwritten unexpectedly");
9551 return TEST_SUCCESS;
9555 test_null_auth_cipher_operation(void)
9557 struct crypto_testsuite_params *ts_params = &testsuite_params;
9558 struct crypto_unittest_params *ut_params = &unittest_params;
9561 /* Verify the capabilities */
9562 struct rte_cryptodev_sym_capability_idx cap_idx;
9563 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9564 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9565 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9568 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9569 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9570 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9574 /* Generate test mbuf data */
9575 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9576 catch_22_quote, QUOTE_512_BYTES, 0);
9578 /* create a pointer for digest, but don't expect anything to be written
9579 * here in a NULL auth algo so no mbuf append done.
9581 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9583 /* prefill the memory pointed to by digest */
9584 memcpy(digest, orig_data, sizeof(orig_data));
9586 /* Setup Cipher Parameters */
9587 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9588 ut_params->cipher_xform.next = NULL;
9590 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9591 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9593 /* Setup HMAC Parameters */
9594 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9595 ut_params->auth_xform.next = &ut_params->cipher_xform;
9597 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9598 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9600 ut_params->sess = rte_cryptodev_sym_session_create(
9601 ts_params->session_mpool);
9603 /* Create Crypto session*/
9604 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9605 ut_params->sess, &ut_params->cipher_xform,
9606 ts_params->session_priv_mpool);
9607 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9609 /* Generate Crypto op data structure */
9610 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9611 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9612 TEST_ASSERT_NOT_NULL(ut_params->op,
9613 "Failed to allocate symmetric crypto operation struct");
9615 /* Set crypto operation data parameters */
9616 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9618 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9620 sym_op->m_src = ut_params->ibuf;
9622 sym_op->cipher.data.offset = 0;
9623 sym_op->cipher.data.length = QUOTE_512_BYTES;
9625 sym_op->auth.data.offset = 0;
9626 sym_op->auth.data.length = QUOTE_512_BYTES;
9627 sym_op->auth.digest.data = digest;
9628 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9631 /* Process crypto operation */
9632 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9634 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9636 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9637 "crypto operation processing failed");
9640 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9641 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9644 "Ciphertext data not as expected");
9645 /* Make sure memory pointed to by digest hasn't been overwritten */
9646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9650 "Memory at digest ptr overwritten unexpectedly");
9652 return TEST_SUCCESS;
9657 test_null_invalid_operation(void)
9659 struct crypto_testsuite_params *ts_params = &testsuite_params;
9660 struct crypto_unittest_params *ut_params = &unittest_params;
9663 /* This test is for NULL PMD only */
9664 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9665 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9668 /* Setup Cipher Parameters */
9669 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9670 ut_params->cipher_xform.next = NULL;
9672 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9673 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9675 ut_params->sess = rte_cryptodev_sym_session_create(
9676 ts_params->session_mpool);
9678 /* Create Crypto session*/
9679 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9680 ut_params->sess, &ut_params->cipher_xform,
9681 ts_params->session_priv_mpool);
9682 TEST_ASSERT(ret < 0,
9683 "Session creation succeeded unexpectedly");
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_SHA1_HMAC;
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 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9698 ut_params->sess, &ut_params->auth_xform,
9699 ts_params->session_priv_mpool);
9700 TEST_ASSERT(ret < 0,
9701 "Session creation succeeded unexpectedly");
9703 return TEST_SUCCESS;
9707 #define NULL_BURST_LENGTH (32)
9710 test_null_burst_operation(void)
9712 struct crypto_testsuite_params *ts_params = &testsuite_params;
9713 struct crypto_unittest_params *ut_params = &unittest_params;
9715 unsigned i, burst_len = NULL_BURST_LENGTH;
9717 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9718 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9720 /* This test is for NULL PMD only */
9721 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9722 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9725 /* Setup Cipher Parameters */
9726 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9727 ut_params->cipher_xform.next = &ut_params->auth_xform;
9729 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9730 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9732 /* Setup HMAC Parameters */
9733 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9734 ut_params->auth_xform.next = NULL;
9736 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9737 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9739 ut_params->sess = rte_cryptodev_sym_session_create(
9740 ts_params->session_mpool);
9742 /* Create Crypto session*/
9743 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9744 ut_params->sess, &ut_params->cipher_xform,
9745 ts_params->session_priv_mpool);
9746 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9748 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9749 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9750 burst_len, "failed to generate burst of crypto ops");
9752 /* Generate an operation for each mbuf in burst */
9753 for (i = 0; i < burst_len; i++) {
9754 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9756 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9758 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9762 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9764 burst[i]->sym->m_src = m;
9767 /* Process crypto operation */
9768 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9769 0, burst, burst_len),
9771 "Error enqueuing burst");
9773 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9774 0, burst_dequeued, burst_len),
9776 "Error dequeuing burst");
9779 for (i = 0; i < burst_len; i++) {
9781 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9782 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9784 "data not as expected");
9786 rte_pktmbuf_free(burst[i]->sym->m_src);
9787 rte_crypto_op_free(burst[i]);
9790 return TEST_SUCCESS;
9794 generate_gmac_large_plaintext(uint8_t *data)
9798 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9799 memcpy(&data[i], &data[0], 32);
9803 create_gmac_operation(enum rte_crypto_auth_operation op,
9804 const struct gmac_test_data *tdata)
9806 struct crypto_testsuite_params *ts_params = &testsuite_params;
9807 struct crypto_unittest_params *ut_params = &unittest_params;
9808 struct rte_crypto_sym_op *sym_op;
9810 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9812 /* Generate Crypto op data structure */
9813 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9814 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9815 TEST_ASSERT_NOT_NULL(ut_params->op,
9816 "Failed to allocate symmetric crypto operation struct");
9818 sym_op = ut_params->op->sym;
9820 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9821 ut_params->ibuf, tdata->gmac_tag.len);
9822 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9823 "no room to append digest");
9825 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9826 ut_params->ibuf, plaintext_pad_len);
9828 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9829 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9830 tdata->gmac_tag.len);
9831 debug_hexdump(stdout, "digest:",
9832 sym_op->auth.digest.data,
9833 tdata->gmac_tag.len);
9836 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9837 uint8_t *, IV_OFFSET);
9839 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9841 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9843 sym_op->cipher.data.length = 0;
9844 sym_op->cipher.data.offset = 0;
9846 sym_op->auth.data.offset = 0;
9847 sym_op->auth.data.length = tdata->plaintext.len;
9852 static int create_gmac_session(uint8_t dev_id,
9853 const struct gmac_test_data *tdata,
9854 enum rte_crypto_auth_operation auth_op)
9856 uint8_t auth_key[tdata->key.len];
9858 struct crypto_testsuite_params *ts_params = &testsuite_params;
9859 struct crypto_unittest_params *ut_params = &unittest_params;
9861 memcpy(auth_key, tdata->key.data, tdata->key.len);
9863 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9864 ut_params->auth_xform.next = NULL;
9866 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9867 ut_params->auth_xform.auth.op = auth_op;
9868 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9869 ut_params->auth_xform.auth.key.length = tdata->key.len;
9870 ut_params->auth_xform.auth.key.data = auth_key;
9871 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9872 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9875 ut_params->sess = rte_cryptodev_sym_session_create(
9876 ts_params->session_mpool);
9878 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9879 &ut_params->auth_xform,
9880 ts_params->session_priv_mpool);
9882 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9888 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9890 struct crypto_testsuite_params *ts_params = &testsuite_params;
9891 struct crypto_unittest_params *ut_params = &unittest_params;
9895 uint8_t *auth_tag, *plaintext;
9896 uint16_t plaintext_pad_len;
9898 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9899 "No GMAC length in the source data");
9901 /* Verify the capabilities */
9902 struct rte_cryptodev_sym_capability_idx cap_idx;
9903 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9904 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9905 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9909 retval = create_gmac_session(ts_params->valid_devs[0],
9910 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9915 if (tdata->plaintext.len > MBUF_SIZE)
9916 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9918 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9919 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9920 "Failed to allocate input buffer in mempool");
9922 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9923 rte_pktmbuf_tailroom(ut_params->ibuf));
9925 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9927 * Runtime generate the large plain text instead of use hard code
9928 * plain text vector. It is done to avoid create huge source file
9929 * with the test vector.
9931 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9932 generate_gmac_large_plaintext(tdata->plaintext.data);
9934 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9936 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9938 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9939 debug_hexdump(stdout, "plaintext:", plaintext,
9940 tdata->plaintext.len);
9942 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9948 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9950 ut_params->op->sym->m_src = ut_params->ibuf;
9952 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9953 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9956 TEST_ASSERT_NOT_NULL(
9957 process_crypto_request(ts_params->valid_devs[0],
9958 ut_params->op), "failed to process sym crypto op");
9960 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9961 "crypto op processing failed");
9963 if (ut_params->op->sym->m_dst) {
9964 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9965 uint8_t *, plaintext_pad_len);
9967 auth_tag = plaintext + plaintext_pad_len;
9970 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9972 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9974 tdata->gmac_tag.data,
9975 tdata->gmac_tag.len,
9976 "GMAC Generated auth tag not as expected");
9982 test_AES_GMAC_authentication_test_case_1(void)
9984 return test_AES_GMAC_authentication(&gmac_test_case_1);
9988 test_AES_GMAC_authentication_test_case_2(void)
9990 return test_AES_GMAC_authentication(&gmac_test_case_2);
9994 test_AES_GMAC_authentication_test_case_3(void)
9996 return test_AES_GMAC_authentication(&gmac_test_case_3);
10000 test_AES_GMAC_authentication_test_case_4(void)
10002 return test_AES_GMAC_authentication(&gmac_test_case_4);
10006 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10008 struct crypto_testsuite_params *ts_params = &testsuite_params;
10009 struct crypto_unittest_params *ut_params = &unittest_params;
10011 uint32_t plaintext_pad_len;
10012 uint8_t *plaintext;
10014 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10015 "No GMAC length in the source data");
10017 /* Verify the capabilities */
10018 struct rte_cryptodev_sym_capability_idx cap_idx;
10019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10020 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10025 retval = create_gmac_session(ts_params->valid_devs[0],
10026 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10031 if (tdata->plaintext.len > MBUF_SIZE)
10032 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10035 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10036 "Failed to allocate input buffer in mempool");
10038 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10039 rte_pktmbuf_tailroom(ut_params->ibuf));
10041 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10044 * Runtime generate the large plain text instead of use hard code
10045 * plain text vector. It is done to avoid create huge source file
10046 * with the test vector.
10048 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10049 generate_gmac_large_plaintext(tdata->plaintext.data);
10051 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10052 plaintext_pad_len);
10053 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10055 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10056 debug_hexdump(stdout, "plaintext:", plaintext,
10057 tdata->plaintext.len);
10059 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10065 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10067 ut_params->op->sym->m_src = ut_params->ibuf;
10069 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10070 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10073 TEST_ASSERT_NOT_NULL(
10074 process_crypto_request(ts_params->valid_devs[0],
10075 ut_params->op), "failed to process sym crypto op");
10077 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10078 "crypto op processing failed");
10085 test_AES_GMAC_authentication_verify_test_case_1(void)
10087 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10091 test_AES_GMAC_authentication_verify_test_case_2(void)
10093 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10097 test_AES_GMAC_authentication_verify_test_case_3(void)
10099 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10103 test_AES_GMAC_authentication_verify_test_case_4(void)
10105 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10108 struct test_crypto_vector {
10109 enum rte_crypto_cipher_algorithm crypto_algo;
10110 unsigned int cipher_offset;
10111 unsigned int cipher_len;
10124 const uint8_t *data;
10129 const uint8_t *data;
10133 enum rte_crypto_auth_algorithm auth_algo;
10134 unsigned int auth_offset;
10142 const uint8_t *data;
10152 static const struct test_crypto_vector
10153 hmac_sha1_test_crypto_vector = {
10154 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10156 .data = plaintext_hash,
10161 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10162 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10163 0xDE, 0xF4, 0xDE, 0xAD
10169 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10170 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10171 0x3F, 0x91, 0x64, 0x59
10177 static const struct test_crypto_vector
10178 aes128_gmac_test_vector = {
10179 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10181 .data = plaintext_hash,
10186 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10187 0x08, 0x09, 0x0A, 0x0B
10193 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10194 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10200 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10201 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10207 static const struct test_crypto_vector
10208 aes128cbc_hmac_sha1_test_vector = {
10209 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10210 .cipher_offset = 0,
10214 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10215 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10221 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10222 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10227 .data = plaintext_hash,
10231 .data = ciphertext512_aes128cbc,
10234 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10238 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10239 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10240 0xDE, 0xF4, 0xDE, 0xAD
10246 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10247 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10248 0x18, 0x8C, 0x1D, 0x32
10254 static const struct test_crypto_vector
10255 aes128cbc_hmac_sha1_aad_test_vector = {
10256 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10257 .cipher_offset = 12,
10261 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10262 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10268 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10269 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10274 .data = plaintext_hash,
10278 .data = ciphertext512_aes128cbc_aad,
10281 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10285 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10286 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10287 0xDE, 0xF4, 0xDE, 0xAD
10293 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10294 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10295 0x62, 0x8D, 0x62, 0x65
10302 data_corruption(uint8_t *data)
10308 tag_corruption(uint8_t *data, unsigned int tag_offset)
10310 data[tag_offset] += 1;
10314 create_auth_session(struct crypto_unittest_params *ut_params,
10316 const struct test_crypto_vector *reference,
10317 enum rte_crypto_auth_operation auth_op)
10319 struct crypto_testsuite_params *ts_params = &testsuite_params;
10320 uint8_t auth_key[reference->auth_key.len + 1];
10322 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10324 /* Setup Authentication Parameters */
10325 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10326 ut_params->auth_xform.auth.op = auth_op;
10327 ut_params->auth_xform.next = NULL;
10328 ut_params->auth_xform.auth.algo = reference->auth_algo;
10329 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10330 ut_params->auth_xform.auth.key.data = auth_key;
10331 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10333 /* Create Crypto session*/
10334 ut_params->sess = rte_cryptodev_sym_session_create(
10335 ts_params->session_mpool);
10337 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10338 &ut_params->auth_xform,
10339 ts_params->session_priv_mpool);
10341 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10347 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10349 const struct test_crypto_vector *reference,
10350 enum rte_crypto_auth_operation auth_op,
10351 enum rte_crypto_cipher_operation cipher_op)
10353 struct crypto_testsuite_params *ts_params = &testsuite_params;
10354 uint8_t cipher_key[reference->cipher_key.len + 1];
10355 uint8_t auth_key[reference->auth_key.len + 1];
10357 memcpy(cipher_key, reference->cipher_key.data,
10358 reference->cipher_key.len);
10359 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10361 /* Setup Authentication Parameters */
10362 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10363 ut_params->auth_xform.auth.op = auth_op;
10364 ut_params->auth_xform.auth.algo = reference->auth_algo;
10365 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10366 ut_params->auth_xform.auth.key.data = auth_key;
10367 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10369 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10370 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10371 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10373 ut_params->auth_xform.next = &ut_params->cipher_xform;
10375 /* Setup Cipher Parameters */
10376 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10377 ut_params->cipher_xform.next = NULL;
10378 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10379 ut_params->cipher_xform.cipher.op = cipher_op;
10380 ut_params->cipher_xform.cipher.key.data = cipher_key;
10381 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10382 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10383 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10386 /* Create Crypto session*/
10387 ut_params->sess = rte_cryptodev_sym_session_create(
10388 ts_params->session_mpool);
10390 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10391 &ut_params->auth_xform,
10392 ts_params->session_priv_mpool);
10394 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10400 create_auth_operation(struct crypto_testsuite_params *ts_params,
10401 struct crypto_unittest_params *ut_params,
10402 const struct test_crypto_vector *reference,
10403 unsigned int auth_generate)
10405 /* Generate Crypto op data structure */
10406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10408 TEST_ASSERT_NOT_NULL(ut_params->op,
10409 "Failed to allocate pktmbuf offload");
10411 /* Set crypto operation data parameters */
10412 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10414 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10416 /* set crypto operation source mbuf */
10417 sym_op->m_src = ut_params->ibuf;
10420 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10421 ut_params->ibuf, reference->digest.len);
10423 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10424 "no room to append auth tag");
10426 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10427 ut_params->ibuf, reference->plaintext.len);
10430 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10432 memcpy(sym_op->auth.digest.data,
10433 reference->digest.data,
10434 reference->digest.len);
10436 debug_hexdump(stdout, "digest:",
10437 sym_op->auth.digest.data,
10438 reference->digest.len);
10440 sym_op->auth.data.length = reference->plaintext.len;
10441 sym_op->auth.data.offset = 0;
10447 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10448 struct crypto_unittest_params *ut_params,
10449 const struct test_crypto_vector *reference,
10450 unsigned int auth_generate)
10452 /* Generate Crypto op data structure */
10453 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10454 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10455 TEST_ASSERT_NOT_NULL(ut_params->op,
10456 "Failed to allocate pktmbuf offload");
10458 /* Set crypto operation data parameters */
10459 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10461 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10463 /* set crypto operation source mbuf */
10464 sym_op->m_src = ut_params->ibuf;
10467 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10468 ut_params->ibuf, reference->digest.len);
10470 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10471 "no room to append auth tag");
10473 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10474 ut_params->ibuf, reference->ciphertext.len);
10477 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10479 memcpy(sym_op->auth.digest.data,
10480 reference->digest.data,
10481 reference->digest.len);
10483 debug_hexdump(stdout, "digest:",
10484 sym_op->auth.digest.data,
10485 reference->digest.len);
10487 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10488 reference->iv.data, reference->iv.len);
10490 sym_op->cipher.data.length = 0;
10491 sym_op->cipher.data.offset = 0;
10493 sym_op->auth.data.length = reference->plaintext.len;
10494 sym_op->auth.data.offset = 0;
10500 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10501 struct crypto_unittest_params *ut_params,
10502 const struct test_crypto_vector *reference,
10503 unsigned int auth_generate)
10505 /* Generate Crypto op data structure */
10506 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10507 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10508 TEST_ASSERT_NOT_NULL(ut_params->op,
10509 "Failed to allocate pktmbuf offload");
10511 /* Set crypto operation data parameters */
10512 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10514 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10516 /* set crypto operation source mbuf */
10517 sym_op->m_src = ut_params->ibuf;
10520 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10521 ut_params->ibuf, reference->digest.len);
10523 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10524 "no room to append auth tag");
10526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10527 ut_params->ibuf, reference->ciphertext.len);
10530 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10532 memcpy(sym_op->auth.digest.data,
10533 reference->digest.data,
10534 reference->digest.len);
10536 debug_hexdump(stdout, "digest:",
10537 sym_op->auth.digest.data,
10538 reference->digest.len);
10540 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10541 reference->iv.data, reference->iv.len);
10543 sym_op->cipher.data.length = reference->cipher_len;
10544 sym_op->cipher.data.offset = reference->cipher_offset;
10546 sym_op->auth.data.length = reference->plaintext.len;
10547 sym_op->auth.data.offset = reference->auth_offset;
10553 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10554 struct crypto_unittest_params *ut_params,
10555 const struct test_crypto_vector *reference)
10557 return create_auth_operation(ts_params, ut_params, reference, 0);
10561 create_auth_verify_GMAC_operation(
10562 struct crypto_testsuite_params *ts_params,
10563 struct crypto_unittest_params *ut_params,
10564 const struct test_crypto_vector *reference)
10566 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10570 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10571 struct crypto_unittest_params *ut_params,
10572 const struct test_crypto_vector *reference)
10574 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10578 test_authentication_verify_fail_when_data_corruption(
10579 struct crypto_testsuite_params *ts_params,
10580 struct crypto_unittest_params *ut_params,
10581 const struct test_crypto_vector *reference,
10582 unsigned int data_corrupted)
10586 uint8_t *plaintext;
10588 /* Verify the capabilities */
10589 struct rte_cryptodev_sym_capability_idx cap_idx;
10590 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10591 cap_idx.algo.auth = reference->auth_algo;
10592 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10596 /* Create session */
10597 retval = create_auth_session(ut_params,
10598 ts_params->valid_devs[0],
10600 RTE_CRYPTO_AUTH_OP_VERIFY);
10604 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10605 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10606 "Failed to allocate input buffer in mempool");
10608 /* clear mbuf payload */
10609 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10610 rte_pktmbuf_tailroom(ut_params->ibuf));
10612 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10613 reference->plaintext.len);
10614 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10615 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10617 debug_hexdump(stdout, "plaintext:", plaintext,
10618 reference->plaintext.len);
10620 /* Create operation */
10621 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10626 if (data_corrupted)
10627 data_corruption(plaintext);
10629 tag_corruption(plaintext, reference->plaintext.len);
10631 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10632 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10634 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10635 RTE_CRYPTO_OP_STATUS_SUCCESS,
10636 "authentication not failed");
10638 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10640 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10647 test_authentication_verify_GMAC_fail_when_corruption(
10648 struct crypto_testsuite_params *ts_params,
10649 struct crypto_unittest_params *ut_params,
10650 const struct test_crypto_vector *reference,
10651 unsigned int data_corrupted)
10654 uint8_t *plaintext;
10656 /* Verify the capabilities */
10657 struct rte_cryptodev_sym_capability_idx cap_idx;
10658 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10659 cap_idx.algo.auth = reference->auth_algo;
10660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10664 /* Create session */
10665 retval = create_auth_cipher_session(ut_params,
10666 ts_params->valid_devs[0],
10668 RTE_CRYPTO_AUTH_OP_VERIFY,
10669 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10673 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10674 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10675 "Failed to allocate input buffer in mempool");
10677 /* clear mbuf payload */
10678 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10679 rte_pktmbuf_tailroom(ut_params->ibuf));
10681 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10682 reference->plaintext.len);
10683 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10684 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10686 debug_hexdump(stdout, "plaintext:", plaintext,
10687 reference->plaintext.len);
10689 /* Create operation */
10690 retval = create_auth_verify_GMAC_operation(ts_params,
10697 if (data_corrupted)
10698 data_corruption(plaintext);
10700 tag_corruption(plaintext, reference->aad.len);
10702 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10703 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10705 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10706 RTE_CRYPTO_OP_STATUS_SUCCESS,
10707 "authentication not failed");
10709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10711 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10718 test_authenticated_decryption_fail_when_corruption(
10719 struct crypto_testsuite_params *ts_params,
10720 struct crypto_unittest_params *ut_params,
10721 const struct test_crypto_vector *reference,
10722 unsigned int data_corrupted)
10726 uint8_t *ciphertext;
10728 /* Verify the capabilities */
10729 struct rte_cryptodev_sym_capability_idx cap_idx;
10730 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10731 cap_idx.algo.auth = reference->auth_algo;
10732 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10736 cap_idx.algo.cipher = reference->crypto_algo;
10737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10741 /* Create session */
10742 retval = create_auth_cipher_session(ut_params,
10743 ts_params->valid_devs[0],
10745 RTE_CRYPTO_AUTH_OP_VERIFY,
10746 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10751 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10752 "Failed to allocate input buffer in mempool");
10754 /* clear mbuf payload */
10755 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10756 rte_pktmbuf_tailroom(ut_params->ibuf));
10758 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10759 reference->ciphertext.len);
10760 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10761 memcpy(ciphertext, reference->ciphertext.data,
10762 reference->ciphertext.len);
10764 /* Create operation */
10765 retval = create_cipher_auth_verify_operation(ts_params,
10772 if (data_corrupted)
10773 data_corruption(ciphertext);
10775 tag_corruption(ciphertext, reference->ciphertext.len);
10777 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10778 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10780 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10781 RTE_CRYPTO_OP_STATUS_SUCCESS,
10782 "authentication not failed");
10784 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10786 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10793 test_authenticated_encryt_with_esn(
10794 struct crypto_testsuite_params *ts_params,
10795 struct crypto_unittest_params *ut_params,
10796 const struct test_crypto_vector *reference)
10800 uint8_t *authciphertext, *plaintext, *auth_tag;
10801 uint16_t plaintext_pad_len;
10802 uint8_t cipher_key[reference->cipher_key.len + 1];
10803 uint8_t auth_key[reference->auth_key.len + 1];
10805 /* Verify the capabilities */
10806 struct rte_cryptodev_sym_capability_idx cap_idx;
10807 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10808 cap_idx.algo.auth = reference->auth_algo;
10809 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10813 cap_idx.algo.cipher = reference->crypto_algo;
10814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10818 /* Create session */
10819 memcpy(cipher_key, reference->cipher_key.data,
10820 reference->cipher_key.len);
10821 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10823 /* Setup Cipher Parameters */
10824 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10825 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10826 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10827 ut_params->cipher_xform.cipher.key.data = cipher_key;
10828 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10829 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10830 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10832 ut_params->cipher_xform.next = &ut_params->auth_xform;
10834 /* Setup Authentication Parameters */
10835 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10836 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10837 ut_params->auth_xform.auth.algo = reference->auth_algo;
10838 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10839 ut_params->auth_xform.auth.key.data = auth_key;
10840 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10841 ut_params->auth_xform.next = NULL;
10843 /* Create Crypto session*/
10844 ut_params->sess = rte_cryptodev_sym_session_create(
10845 ts_params->session_mpool);
10847 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10849 &ut_params->cipher_xform,
10850 ts_params->session_priv_mpool);
10852 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10855 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10856 "Failed to allocate input buffer in mempool");
10858 /* clear mbuf payload */
10859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10860 rte_pktmbuf_tailroom(ut_params->ibuf));
10862 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10863 reference->plaintext.len);
10864 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10865 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10867 /* Create operation */
10868 retval = create_cipher_auth_operation(ts_params,
10875 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10876 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10879 ut_params->op = process_crypto_request(
10880 ts_params->valid_devs[0], ut_params->op);
10882 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10884 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10885 "crypto op processing failed");
10887 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10889 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10890 ut_params->op->sym->auth.data.offset);
10891 auth_tag = authciphertext + plaintext_pad_len;
10892 debug_hexdump(stdout, "ciphertext:", authciphertext,
10893 reference->ciphertext.len);
10894 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10896 /* Validate obuf */
10897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10899 reference->ciphertext.data,
10900 reference->ciphertext.len,
10901 "Ciphertext data not as expected");
10903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10905 reference->digest.data,
10906 reference->digest.len,
10907 "Generated digest not as expected");
10909 return TEST_SUCCESS;
10914 test_authenticated_decrypt_with_esn(
10915 struct crypto_testsuite_params *ts_params,
10916 struct crypto_unittest_params *ut_params,
10917 const struct test_crypto_vector *reference)
10921 uint8_t *ciphertext;
10922 uint8_t cipher_key[reference->cipher_key.len + 1];
10923 uint8_t auth_key[reference->auth_key.len + 1];
10925 /* Verify the capabilities */
10926 struct rte_cryptodev_sym_capability_idx cap_idx;
10927 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10928 cap_idx.algo.auth = reference->auth_algo;
10929 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10932 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10933 cap_idx.algo.cipher = reference->crypto_algo;
10934 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10938 /* Create session */
10939 memcpy(cipher_key, reference->cipher_key.data,
10940 reference->cipher_key.len);
10941 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10943 /* Setup Authentication Parameters */
10944 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10945 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10946 ut_params->auth_xform.auth.algo = reference->auth_algo;
10947 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10948 ut_params->auth_xform.auth.key.data = auth_key;
10949 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10950 ut_params->auth_xform.next = &ut_params->cipher_xform;
10952 /* Setup Cipher Parameters */
10953 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10954 ut_params->cipher_xform.next = NULL;
10955 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10956 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10957 ut_params->cipher_xform.cipher.key.data = cipher_key;
10958 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10959 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10960 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10962 /* Create Crypto session*/
10963 ut_params->sess = rte_cryptodev_sym_session_create(
10964 ts_params->session_mpool);
10966 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10968 &ut_params->auth_xform,
10969 ts_params->session_priv_mpool);
10971 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10973 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10974 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10975 "Failed to allocate input buffer in mempool");
10977 /* clear mbuf payload */
10978 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10979 rte_pktmbuf_tailroom(ut_params->ibuf));
10981 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10982 reference->ciphertext.len);
10983 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10984 memcpy(ciphertext, reference->ciphertext.data,
10985 reference->ciphertext.len);
10987 /* Create operation */
10988 retval = create_cipher_auth_verify_operation(ts_params,
10995 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10996 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10999 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11002 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11003 TEST_ASSERT_EQUAL(ut_params->op->status,
11004 RTE_CRYPTO_OP_STATUS_SUCCESS,
11005 "crypto op processing passed");
11007 ut_params->obuf = ut_params->op->sym->m_src;
11008 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11014 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11015 const struct aead_test_data *tdata,
11016 void *digest_mem, uint64_t digest_phys)
11018 struct crypto_testsuite_params *ts_params = &testsuite_params;
11019 struct crypto_unittest_params *ut_params = &unittest_params;
11021 const unsigned int auth_tag_len = tdata->auth_tag.len;
11022 const unsigned int iv_len = tdata->iv.len;
11023 unsigned int aad_len = tdata->aad.len;
11024 unsigned int aad_len_pad = 0;
11026 /* Generate Crypto op data structure */
11027 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11028 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11029 TEST_ASSERT_NOT_NULL(ut_params->op,
11030 "Failed to allocate symmetric crypto operation struct");
11032 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11034 sym_op->aead.digest.data = digest_mem;
11036 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11037 "no room to append digest");
11039 sym_op->aead.digest.phys_addr = digest_phys;
11041 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11042 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11044 debug_hexdump(stdout, "digest:",
11045 sym_op->aead.digest.data,
11049 /* Append aad data */
11050 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11051 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11052 uint8_t *, IV_OFFSET);
11054 /* Copy IV 1 byte after the IV pointer, according to the API */
11055 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11057 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11059 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11060 ut_params->ibuf, aad_len);
11061 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11062 "no room to prepend aad");
11063 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11066 memset(sym_op->aead.aad.data, 0, aad_len);
11067 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11068 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11070 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11071 debug_hexdump(stdout, "aad:",
11072 sym_op->aead.aad.data, aad_len);
11074 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11075 uint8_t *, IV_OFFSET);
11077 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11079 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11081 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11082 ut_params->ibuf, aad_len_pad);
11083 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11084 "no room to prepend aad");
11085 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11088 memset(sym_op->aead.aad.data, 0, aad_len);
11089 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11091 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11092 debug_hexdump(stdout, "aad:",
11093 sym_op->aead.aad.data, aad_len);
11096 sym_op->aead.data.length = tdata->plaintext.len;
11097 sym_op->aead.data.offset = aad_len_pad;
11102 #define SGL_MAX_NO 16
11105 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11106 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11108 struct crypto_testsuite_params *ts_params = &testsuite_params;
11109 struct crypto_unittest_params *ut_params = &unittest_params;
11110 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11113 int to_trn_tbl[SGL_MAX_NO];
11115 unsigned int trn_data = 0;
11116 uint8_t *plaintext, *ciphertext, *auth_tag;
11117 struct rte_cryptodev_info dev_info;
11119 /* Verify the capabilities */
11120 struct rte_cryptodev_sym_capability_idx cap_idx;
11121 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11122 cap_idx.algo.aead = tdata->algo;
11123 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11127 /* OOP not supported with CPU crypto */
11128 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11131 /* Detailed check for the particular SGL support flag */
11132 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11134 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11135 if (sgl_in && (!(dev_info.feature_flags &
11136 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11139 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11140 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11141 tdata->plaintext.len;
11142 if (sgl_in && !sgl_out) {
11143 if (!(dev_info.feature_flags &
11144 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11146 } else if (!sgl_in && sgl_out) {
11147 if (!(dev_info.feature_flags &
11148 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11150 } else if (sgl_in && sgl_out) {
11151 if (!(dev_info.feature_flags &
11152 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11157 if (fragsz > tdata->plaintext.len)
11158 fragsz = tdata->plaintext.len;
11160 uint16_t plaintext_len = fragsz;
11161 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11163 if (fragsz_oop > tdata->plaintext.len)
11164 frag_size_oop = tdata->plaintext.len;
11167 void *digest_mem = NULL;
11169 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11171 if (tdata->plaintext.len % fragsz != 0) {
11172 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11175 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11180 * For out-op-place we need to alloc another mbuf
11183 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11184 rte_pktmbuf_append(ut_params->obuf,
11185 frag_size_oop + prepend_len);
11186 buf_oop = ut_params->obuf;
11189 /* Create AEAD session */
11190 retval = create_aead_session(ts_params->valid_devs[0],
11192 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11193 tdata->key.data, tdata->key.len,
11194 tdata->aad.len, tdata->auth_tag.len,
11199 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11201 /* clear mbuf payload */
11202 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11203 rte_pktmbuf_tailroom(ut_params->ibuf));
11205 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11208 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11210 trn_data += plaintext_len;
11212 buf = ut_params->ibuf;
11215 * Loop until no more fragments
11218 while (trn_data < tdata->plaintext.len) {
11220 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11221 (tdata->plaintext.len - trn_data) : fragsz;
11223 to_trn_tbl[ecx++] = to_trn;
11225 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11228 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11229 rte_pktmbuf_tailroom(buf));
11232 if (oop && !fragsz_oop) {
11233 buf_last_oop = buf_oop->next =
11234 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11235 buf_oop = buf_oop->next;
11236 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11237 0, rte_pktmbuf_tailroom(buf_oop));
11238 rte_pktmbuf_append(buf_oop, to_trn);
11241 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11244 memcpy(plaintext, tdata->plaintext.data + trn_data,
11246 trn_data += to_trn;
11247 if (trn_data == tdata->plaintext.len) {
11250 digest_mem = rte_pktmbuf_append(buf_oop,
11251 tdata->auth_tag.len);
11253 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11254 tdata->auth_tag.len);
11258 uint64_t digest_phys = 0;
11260 ut_params->ibuf->nb_segs = segs;
11263 if (fragsz_oop && oop) {
11267 if (frag_size_oop == tdata->plaintext.len) {
11268 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11269 tdata->auth_tag.len);
11271 digest_phys = rte_pktmbuf_iova_offset(
11273 tdata->plaintext.len + prepend_len);
11276 trn_data = frag_size_oop;
11277 while (trn_data < tdata->plaintext.len) {
11280 (tdata->plaintext.len - trn_data <
11282 (tdata->plaintext.len - trn_data) :
11285 to_trn_tbl[ecx++] = to_trn;
11287 buf_last_oop = buf_oop->next =
11288 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11289 buf_oop = buf_oop->next;
11290 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11291 0, rte_pktmbuf_tailroom(buf_oop));
11292 rte_pktmbuf_append(buf_oop, to_trn);
11294 trn_data += to_trn;
11296 if (trn_data == tdata->plaintext.len) {
11297 digest_mem = rte_pktmbuf_append(buf_oop,
11298 tdata->auth_tag.len);
11302 ut_params->obuf->nb_segs = segs;
11306 * Place digest at the end of the last buffer
11309 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11310 if (oop && buf_last_oop)
11311 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11313 if (!digest_mem && !oop) {
11314 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11315 + tdata->auth_tag.len);
11316 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11317 tdata->plaintext.len);
11320 /* Create AEAD operation */
11321 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11322 tdata, digest_mem, digest_phys);
11327 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11329 ut_params->op->sym->m_src = ut_params->ibuf;
11331 ut_params->op->sym->m_dst = ut_params->obuf;
11333 /* Process crypto operation */
11334 if (oop == IN_PLACE &&
11335 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11336 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11338 TEST_ASSERT_NOT_NULL(
11339 process_crypto_request(ts_params->valid_devs[0],
11340 ut_params->op), "failed to process sym crypto op");
11342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11343 "crypto op processing failed");
11346 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11347 uint8_t *, prepend_len);
11349 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11350 uint8_t *, prepend_len);
11354 fragsz = fragsz_oop;
11356 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11358 tdata->ciphertext.data,
11360 "Ciphertext data not as expected");
11362 buf = ut_params->op->sym->m_src->next;
11364 buf = ut_params->op->sym->m_dst->next;
11366 unsigned int off = fragsz;
11370 ciphertext = rte_pktmbuf_mtod(buf,
11373 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11375 tdata->ciphertext.data + off,
11377 "Ciphertext data not as expected");
11379 off += to_trn_tbl[ecx++];
11383 auth_tag = digest_mem;
11384 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11386 tdata->auth_tag.data,
11387 tdata->auth_tag.len,
11388 "Generated auth tag not as expected");
11394 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11396 return test_authenticated_encryption_SGL(
11397 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11401 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11403 return test_authenticated_encryption_SGL(
11404 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11408 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11410 return test_authenticated_encryption_SGL(
11411 &gcm_test_case_8, OUT_OF_PLACE, 400,
11412 gcm_test_case_8.plaintext.len);
11416 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11418 /* This test is not for OPENSSL PMD */
11419 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11420 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11423 return test_authenticated_encryption_SGL(
11424 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11428 test_authentication_verify_fail_when_data_corrupted(
11429 struct crypto_testsuite_params *ts_params,
11430 struct crypto_unittest_params *ut_params,
11431 const struct test_crypto_vector *reference)
11433 return test_authentication_verify_fail_when_data_corruption(
11434 ts_params, ut_params, reference, 1);
11438 test_authentication_verify_fail_when_tag_corrupted(
11439 struct crypto_testsuite_params *ts_params,
11440 struct crypto_unittest_params *ut_params,
11441 const struct test_crypto_vector *reference)
11443 return test_authentication_verify_fail_when_data_corruption(
11444 ts_params, ut_params, reference, 0);
11448 test_authentication_verify_GMAC_fail_when_data_corrupted(
11449 struct crypto_testsuite_params *ts_params,
11450 struct crypto_unittest_params *ut_params,
11451 const struct test_crypto_vector *reference)
11453 return test_authentication_verify_GMAC_fail_when_corruption(
11454 ts_params, ut_params, reference, 1);
11458 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11459 struct crypto_testsuite_params *ts_params,
11460 struct crypto_unittest_params *ut_params,
11461 const struct test_crypto_vector *reference)
11463 return test_authentication_verify_GMAC_fail_when_corruption(
11464 ts_params, ut_params, reference, 0);
11468 test_authenticated_decryption_fail_when_data_corrupted(
11469 struct crypto_testsuite_params *ts_params,
11470 struct crypto_unittest_params *ut_params,
11471 const struct test_crypto_vector *reference)
11473 return test_authenticated_decryption_fail_when_corruption(
11474 ts_params, ut_params, reference, 1);
11478 test_authenticated_decryption_fail_when_tag_corrupted(
11479 struct crypto_testsuite_params *ts_params,
11480 struct crypto_unittest_params *ut_params,
11481 const struct test_crypto_vector *reference)
11483 return test_authenticated_decryption_fail_when_corruption(
11484 ts_params, ut_params, reference, 0);
11488 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11490 return test_authentication_verify_fail_when_data_corrupted(
11491 &testsuite_params, &unittest_params,
11492 &hmac_sha1_test_crypto_vector);
11496 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11498 return test_authentication_verify_fail_when_tag_corrupted(
11499 &testsuite_params, &unittest_params,
11500 &hmac_sha1_test_crypto_vector);
11504 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11506 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11507 &testsuite_params, &unittest_params,
11508 &aes128_gmac_test_vector);
11512 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11514 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11515 &testsuite_params, &unittest_params,
11516 &aes128_gmac_test_vector);
11520 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11522 return test_authenticated_decryption_fail_when_data_corrupted(
11525 &aes128cbc_hmac_sha1_test_vector);
11529 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11531 return test_authenticated_decryption_fail_when_tag_corrupted(
11534 &aes128cbc_hmac_sha1_test_vector);
11538 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11540 return test_authenticated_encryt_with_esn(
11543 &aes128cbc_hmac_sha1_aad_test_vector);
11547 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11549 return test_authenticated_decrypt_with_esn(
11552 &aes128cbc_hmac_sha1_aad_test_vector);
11555 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11557 /* global AESNI slave IDs for the scheduler test */
11558 uint8_t aesni_ids[2];
11561 test_scheduler_attach_slave_op(void)
11563 struct crypto_testsuite_params *ts_params = &testsuite_params;
11564 uint8_t sched_id = ts_params->valid_devs[0];
11565 uint32_t nb_devs, i, nb_devs_attached = 0;
11567 char vdev_name[32];
11569 /* create 2 AESNI_MB if necessary */
11570 nb_devs = rte_cryptodev_device_count_by_driver(
11571 rte_cryptodev_driver_id_get(
11572 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11574 for (i = nb_devs; i < 2; i++) {
11575 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11578 ret = rte_vdev_init(vdev_name, NULL);
11580 TEST_ASSERT(ret == 0,
11581 "Failed to create instance %u of"
11583 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11587 /* attach 2 AESNI_MB cdevs */
11588 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11590 struct rte_cryptodev_info info;
11591 unsigned int session_size;
11593 rte_cryptodev_info_get(i, &info);
11594 if (info.driver_id != rte_cryptodev_driver_id_get(
11595 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11598 session_size = rte_cryptodev_sym_get_private_session_size(i);
11600 * Create the session mempool again, since now there are new devices
11601 * to use the mempool.
11603 if (ts_params->session_mpool) {
11604 rte_mempool_free(ts_params->session_mpool);
11605 ts_params->session_mpool = NULL;
11607 if (ts_params->session_priv_mpool) {
11608 rte_mempool_free(ts_params->session_priv_mpool);
11609 ts_params->session_priv_mpool = NULL;
11612 if (info.sym.max_nb_sessions != 0 &&
11613 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11614 RTE_LOG(ERR, USER1,
11615 "Device does not support "
11616 "at least %u sessions\n",
11618 return TEST_FAILED;
11621 * Create mempool with maximum number of sessions,
11622 * to include the session headers
11624 if (ts_params->session_mpool == NULL) {
11625 ts_params->session_mpool =
11626 rte_cryptodev_sym_session_pool_create(
11628 MAX_NB_SESSIONS, 0, 0, 0,
11630 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11631 "session mempool allocation failed");
11635 * Create mempool with maximum number of sessions,
11636 * to include device specific session private data
11638 if (ts_params->session_priv_mpool == NULL) {
11639 ts_params->session_priv_mpool = rte_mempool_create(
11640 "test_sess_mp_priv",
11643 0, 0, NULL, NULL, NULL,
11644 NULL, SOCKET_ID_ANY,
11647 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11648 "session mempool allocation failed");
11651 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11652 ts_params->qp_conf.mp_session_private =
11653 ts_params->session_priv_mpool;
11655 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11658 TEST_ASSERT(ret == 0,
11659 "Failed to attach device %u of pmd : %s", i,
11660 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11662 aesni_ids[nb_devs_attached] = (uint8_t)i;
11664 nb_devs_attached++;
11671 test_scheduler_detach_slave_op(void)
11673 struct crypto_testsuite_params *ts_params = &testsuite_params;
11674 uint8_t sched_id = ts_params->valid_devs[0];
11678 for (i = 0; i < 2; i++) {
11679 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11681 TEST_ASSERT(ret == 0,
11682 "Failed to detach device %u", aesni_ids[i]);
11689 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11691 struct crypto_testsuite_params *ts_params = &testsuite_params;
11692 uint8_t sched_id = ts_params->valid_devs[0];
11694 return rte_cryptodev_scheduler_mode_set(sched_id,
11699 test_scheduler_mode_roundrobin_op(void)
11701 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11702 0, "Failed to set roundrobin mode");
11708 test_scheduler_mode_multicore_op(void)
11710 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11711 0, "Failed to set multicore mode");
11717 test_scheduler_mode_failover_op(void)
11719 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11720 0, "Failed to set failover mode");
11726 test_scheduler_mode_pkt_size_distr_op(void)
11728 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11729 0, "Failed to set pktsize mode");
11734 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11735 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11736 .setup = testsuite_setup,
11737 .teardown = testsuite_teardown,
11738 .unit_test_cases = {
11740 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11741 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11743 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11744 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11745 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11748 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11749 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11750 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11751 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11752 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11753 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11756 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11757 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11758 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11759 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11760 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11761 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11764 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11765 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11766 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11767 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11768 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11769 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11771 TEST_CASES_END() /**< NULL terminate unit test array */
11775 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11777 static struct unit_test_suite cryptodev_testsuite = {
11778 .suite_name = "Crypto Unit Test Suite",
11779 .setup = testsuite_setup,
11780 .teardown = testsuite_teardown,
11781 .unit_test_cases = {
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_device_configure_invalid_dev_id),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_queue_pair_descriptor_setup),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_device_configure_invalid_queue_pair_ids),
11789 TEST_CASE_ST(ut_setup, ut_teardown,
11790 test_multi_session),
11791 TEST_CASE_ST(ut_setup, ut_teardown,
11792 test_multi_session_random_usage),
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_null_invalid_operation),
11796 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11798 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11799 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11800 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11801 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11802 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11803 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11804 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11805 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11806 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11808 /** AES CCM Authenticated Encryption 128 bits key */
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_AES_CCM_authenticated_encryption_test_case_128_1),
11811 TEST_CASE_ST(ut_setup, ut_teardown,
11812 test_AES_CCM_authenticated_encryption_test_case_128_2),
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_AES_CCM_authenticated_encryption_test_case_128_3),
11816 /** AES CCM Authenticated Decryption 128 bits key*/
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_CCM_authenticated_decryption_test_case_128_1),
11819 TEST_CASE_ST(ut_setup, ut_teardown,
11820 test_AES_CCM_authenticated_decryption_test_case_128_2),
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_CCM_authenticated_decryption_test_case_128_3),
11824 /** AES CCM Authenticated Encryption 192 bits key */
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_CCM_authenticated_encryption_test_case_192_1),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_CCM_authenticated_encryption_test_case_192_2),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_CCM_authenticated_encryption_test_case_192_3),
11832 /** AES CCM Authenticated Decryption 192 bits key*/
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_CCM_authenticated_decryption_test_case_192_1),
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_CCM_authenticated_decryption_test_case_192_2),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_CCM_authenticated_decryption_test_case_192_3),
11840 /** AES CCM Authenticated Encryption 256 bits key */
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_CCM_authenticated_encryption_test_case_256_1),
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_CCM_authenticated_encryption_test_case_256_2),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_CCM_authenticated_encryption_test_case_256_3),
11848 /** AES CCM Authenticated Decryption 256 bits key*/
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_CCM_authenticated_decryption_test_case_256_1),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_CCM_authenticated_decryption_test_case_256_2),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_CCM_authenticated_decryption_test_case_256_3),
11856 /** AES GCM Authenticated Encryption */
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_authenticated_encryption_test_case_1),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_authenticated_encryption_test_case_2),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_authenticated_encryption_test_case_3),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_authenticated_encryption_test_case_4),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_AES_GCM_authenticated_encryption_test_case_5),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_authenticated_encryption_test_case_6),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_authenticated_encryption_test_case_7),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_authenticated_encryption_test_case_8),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11884 /** AES GCM Authenticated Decryption */
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_authenticated_decryption_test_case_1),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_authenticated_decryption_test_case_2),
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_authenticated_decryption_test_case_3),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_authenticated_decryption_test_case_4),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_authenticated_decryption_test_case_5),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_authenticated_decryption_test_case_6),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_authenticated_decryption_test_case_7),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_authenticated_decryption_test_case_8),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11904 /** AES GCM Authenticated Encryption 192 bits key */
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_auth_encryption_test_case_192_1),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_auth_encryption_test_case_192_2),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_encryption_test_case_192_3),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_encryption_test_case_192_4),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_encryption_test_case_192_5),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_encryption_test_case_192_6),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_encryption_test_case_192_7),
11920 /** AES GCM Authenticated Decryption 192 bits key */
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_auth_decryption_test_case_192_1),
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_decryption_test_case_192_2),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_decryption_test_case_192_3),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_decryption_test_case_192_4),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_decryption_test_case_192_5),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_decryption_test_case_192_6),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_decryption_test_case_192_7),
11936 /** AES GCM Authenticated Encryption 256 bits key */
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_auth_encryption_test_case_256_1),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_auth_encryption_test_case_256_2),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_auth_encryption_test_case_256_3),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_encryption_test_case_256_4),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_encryption_test_case_256_5),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_encryption_test_case_256_6),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_encryption_test_case_256_7),
11952 /** AES GCM Authenticated Decryption 256 bits key */
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_decryption_test_case_256_1),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GCM_auth_decryption_test_case_256_2),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GCM_auth_decryption_test_case_256_3),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_decryption_test_case_256_4),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GCM_auth_decryption_test_case_256_5),
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_AES_GCM_auth_decryption_test_case_256_6),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_decryption_test_case_256_7),
11968 /** AES GCM Authenticated Encryption big aad size */
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_GCM_auth_encryption_test_case_aad_1),
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_auth_encryption_test_case_aad_2),
11974 /** AES GCM Authenticated Decryption big aad size */
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_GCM_auth_decryption_test_case_aad_1),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_GCM_auth_decryption_test_case_aad_2),
11980 /** Out of place tests */
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11986 /** Session-less tests */
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11992 /** AES GMAC Authentication */
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_GMAC_authentication_test_case_1),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_AES_GMAC_authentication_verify_test_case_1),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_AES_GMAC_authentication_test_case_2),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_AES_GMAC_authentication_verify_test_case_2),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_AES_GMAC_authentication_test_case_3),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_AES_GMAC_authentication_verify_test_case_3),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_AES_GMAC_authentication_test_case_4),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_AES_GMAC_authentication_verify_test_case_4),
12010 /** SNOW 3G encrypt only (UEA2) */
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_snow3g_encryption_test_case_1),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_snow3g_encryption_test_case_2),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_snow3g_encryption_test_case_3),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_snow3g_encryption_test_case_4),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_snow3g_encryption_test_case_5),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_snow3g_encryption_test_case_1_oop),
12024 TEST_CASE_ST(ut_setup, ut_teardown,
12025 test_snow3g_encryption_test_case_1_oop_sgl),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_encryption_test_case_1_offset_oop),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_decryption_test_case_1_oop),
12031 /** SNOW 3G generate auth, then encrypt (UEA2) */
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_auth_cipher_test_case_1),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_snow3g_auth_cipher_test_case_2),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_auth_cipher_test_case_2_oop),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_auth_cipher_part_digest_enc),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_auth_cipher_part_digest_enc_oop),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_test_case_3_sgl),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_part_digest_enc_sgl),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12051 /** SNOW 3G decrypt (UEA2), then verify auth */
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_verify_test_case_1),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_auth_cipher_verify_test_case_2),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_verify_test_case_2_oop),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_auth_cipher_verify_part_digest_enc),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12071 /** SNOW 3G decrypt only (UEA2) */
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_decryption_test_case_1),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_snow3g_decryption_test_case_2),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_decryption_test_case_3),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_snow3g_decryption_test_case_4),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 test_snow3g_decryption_test_case_5),
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_snow3g_decryption_with_digest_test_case_1),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_snow3g_hash_generate_test_case_1),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_snow3g_hash_generate_test_case_2),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_snow3g_hash_generate_test_case_3),
12090 /* Tests with buffers which length is not byte-aligned */
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_snow3g_hash_generate_test_case_4),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_snow3g_hash_generate_test_case_5),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_snow3g_hash_generate_test_case_6),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_snow3g_hash_verify_test_case_1),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_snow3g_hash_verify_test_case_2),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_snow3g_hash_verify_test_case_3),
12103 /* Tests with buffers which length is not byte-aligned */
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_snow3g_hash_verify_test_case_4),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_snow3g_hash_verify_test_case_5),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_snow3g_hash_verify_test_case_6),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_snow3g_cipher_auth_test_case_1),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_snow3g_auth_cipher_with_digest_test_case_1),
12115 /** ZUC encrypt only (EEA3) */
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_zuc_encryption_test_case_1),
12118 TEST_CASE_ST(ut_setup, ut_teardown,
12119 test_zuc_encryption_test_case_2),
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_encryption_test_case_3),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_encryption_test_case_4),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_encryption_test_case_5),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_encryption_test_case_6_sgl),
12129 /** ZUC authenticate (EIA3) */
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_zuc_hash_generate_test_case_1),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_zuc_hash_generate_test_case_2),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_hash_generate_test_case_3),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_zuc_hash_generate_test_case_4),
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_hash_generate_test_case_5),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_hash_generate_test_case_6),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_hash_generate_test_case_7),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_hash_generate_test_case_8),
12147 /** ZUC alg-chain (EEA3/EIA3) */
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_cipher_auth_test_case_1),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_zuc_cipher_auth_test_case_2),
12153 /** ZUC generate auth, then encrypt (EEA3) */
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_auth_cipher_test_case_1),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_zuc_auth_cipher_test_case_1_oop),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_zuc_auth_cipher_test_case_1_sgl),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_zuc_auth_cipher_test_case_1_oop_sgl),
12163 /** ZUC decrypt (EEA3), then verify auth */
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_zuc_auth_cipher_verify_test_case_1),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_zuc_auth_cipher_verify_test_case_1_oop),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_zuc_auth_cipher_verify_test_case_1_sgl),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12173 /** HMAC_MD5 Authentication */
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_MD5_HMAC_generate_case_1),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_MD5_HMAC_verify_case_1),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_MD5_HMAC_generate_case_2),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_MD5_HMAC_verify_case_2),
12183 /** KASUMI hash only (UIA1) */
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_kasumi_hash_generate_test_case_1),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_kasumi_hash_generate_test_case_2),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_kasumi_hash_generate_test_case_3),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_kasumi_hash_generate_test_case_4),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_kasumi_hash_generate_test_case_5),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_kasumi_hash_generate_test_case_6),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_kasumi_hash_verify_test_case_1),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_kasumi_hash_verify_test_case_2),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_hash_verify_test_case_3),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_hash_verify_test_case_4),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_hash_verify_test_case_5),
12208 /** KASUMI encrypt only (UEA1) */
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_kasumi_encryption_test_case_1),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_encryption_test_case_1_sgl),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_encryption_test_case_1_oop),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_encryption_test_case_1_oop_sgl),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_encryption_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_encryption_test_case_3),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_encryption_test_case_4),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_encryption_test_case_5),
12226 /** KASUMI decrypt only (UEA1) */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_decryption_test_case_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_kasumi_decryption_test_case_2),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_decryption_test_case_3),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_kasumi_decryption_test_case_4),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_kasumi_decryption_test_case_5),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_kasumi_decryption_test_case_1_oop),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_kasumi_cipher_auth_test_case_1),
12243 /** KASUMI generate auth, then encrypt (F8) */
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_kasumi_auth_cipher_test_case_1),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_kasumi_auth_cipher_test_case_2),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_kasumi_auth_cipher_test_case_2_oop),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_kasumi_auth_cipher_test_case_2_sgl),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12255 /** KASUMI decrypt (F8), then verify auth */
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 test_kasumi_auth_cipher_verify_test_case_1),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 test_kasumi_auth_cipher_verify_test_case_2),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 test_kasumi_auth_cipher_verify_test_case_2_oop),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12267 /** ESN Testcase */
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12273 /** Negative tests */
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 authentication_verify_AES128_GMAC_fail_data_corrupt),
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12311 /** Mixed CIPHER + HASH algorithms */
12312 /** AUTH AES CMAC + CIPHER AES CTR */
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12330 /** AUTH ZUC + CIPHER SNOW3G */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_auth_zuc_cipher_snow_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_verify_auth_zuc_cipher_snow_test_case_1),
12335 /** AUTH AES CMAC + CIPHER SNOW3G */
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_auth_aes_cmac_cipher_snow_test_case_1),
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12340 /** AUTH ZUC + CIPHER AES CTR */
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_auth_zuc_cipher_aes_ctr_test_case_1),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12345 /** AUTH SNOW3G + CIPHER AES CTR */
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_auth_snow_cipher_aes_ctr_test_case_1),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12350 /** AUTH SNOW3G + CIPHER ZUC */
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_auth_snow_cipher_zuc_test_case_1),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_verify_auth_snow_cipher_zuc_test_case_1),
12355 /** AUTH AES CMAC + CIPHER ZUC */
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_auth_aes_cmac_cipher_zuc_test_case_1),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12361 /** AUTH NULL + CIPHER SNOW3G */
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_auth_null_cipher_snow_test_case_1),
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_verify_auth_null_cipher_snow_test_case_1),
12366 /** AUTH NULL + CIPHER ZUC */
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_auth_null_cipher_zuc_test_case_1),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_verify_auth_null_cipher_zuc_test_case_1),
12371 /** AUTH SNOW3G + CIPHER NULL */
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_auth_snow_cipher_null_test_case_1),
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_verify_auth_snow_cipher_null_test_case_1),
12376 /** AUTH ZUC + CIPHER NULL */
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_auth_zuc_cipher_null_test_case_1),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_verify_auth_zuc_cipher_null_test_case_1),
12381 /** AUTH NULL + CIPHER AES CTR */
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_auth_null_cipher_aes_ctr_test_case_1),
12384 TEST_CASE_ST(ut_setup, ut_teardown,
12385 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12386 /** AUTH AES CMAC + CIPHER NULL */
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_auth_aes_cmac_cipher_null_test_case_1),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12392 #ifdef RTE_LIBRTE_SECURITY
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_PDCP_PROTO_all),
12396 TEST_CASES_END() /**< NULL terminate unit test array */
12400 static struct unit_test_suite cryptodev_virtio_testsuite = {
12401 .suite_name = "Crypto VIRTIO Unit Test Suite",
12402 .setup = testsuite_setup,
12403 .teardown = testsuite_teardown,
12404 .unit_test_cases = {
12405 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12407 TEST_CASES_END() /**< NULL terminate unit test array */
12411 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12412 .suite_name = "Crypto CAAM JR Unit Test Suite",
12413 .setup = testsuite_setup,
12414 .teardown = testsuite_teardown,
12415 .unit_test_cases = {
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_device_configure_invalid_dev_id),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_multi_session),
12421 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12422 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12423 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12424 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12425 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12427 TEST_CASES_END() /**< NULL terminate unit test array */
12431 static struct unit_test_suite cryptodev_armv8_testsuite = {
12432 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12433 .setup = testsuite_setup,
12434 .teardown = testsuite_teardown,
12435 .unit_test_cases = {
12436 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12438 /** Negative tests */
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12444 TEST_CASES_END() /**< NULL terminate unit test array */
12448 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12449 .suite_name = "Crypto Device Marvell Component Test Suite",
12450 .setup = testsuite_setup,
12451 .teardown = testsuite_teardown,
12452 .unit_test_cases = {
12453 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_multi_session_random_usage),
12456 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12457 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12458 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12459 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12460 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12462 /** Negative tests */
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12472 TEST_CASES_END() /**< NULL terminate unit test array */
12476 static struct unit_test_suite cryptodev_ccp_testsuite = {
12477 .suite_name = "Crypto Device CCP Unit Test Suite",
12478 .setup = testsuite_setup,
12479 .teardown = testsuite_teardown,
12480 .unit_test_cases = {
12481 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_multi_session_random_usage),
12484 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12485 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12486 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12487 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12488 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12490 /** Negative tests */
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12500 TEST_CASES_END() /**< NULL terminate unit test array */
12504 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12505 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12506 .setup = testsuite_setup,
12507 .teardown = testsuite_teardown,
12508 .unit_test_cases = {
12509 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12510 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12511 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12512 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12513 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12515 /** AES GCM Authenticated Encryption */
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_authenticated_encryption_test_case_1),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_authenticated_encryption_test_case_2),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_authenticated_encryption_test_case_3),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_authenticated_encryption_test_case_4),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_authenticated_encryption_test_case_5),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_authenticated_encryption_test_case_6),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_authenticated_encryption_test_case_7),
12531 /** AES GCM Authenticated Decryption */
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_authenticated_decryption_test_case_1),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_authenticated_decryption_test_case_2),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_authenticated_decryption_test_case_3),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_authenticated_decryption_test_case_4),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_authenticated_decryption_test_case_5),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_authenticated_decryption_test_case_6),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_authenticated_decryption_test_case_7),
12546 /** AES GMAC Authentication */
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_AES_GMAC_authentication_test_case_1),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_AES_GMAC_authentication_verify_test_case_1),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_AES_GMAC_authentication_test_case_2),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_AES_GMAC_authentication_verify_test_case_2),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_AES_GMAC_authentication_test_case_3),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_AES_GMAC_authentication_verify_test_case_3),
12560 /** SNOW 3G encrypt only (UEA2) */
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_snow3g_encryption_test_case_1),
12563 TEST_CASE_ST(ut_setup, ut_teardown,
12564 test_snow3g_encryption_test_case_2),
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_snow3g_encryption_test_case_3),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_snow3g_encryption_test_case_4),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_snow3g_encryption_test_case_5),
12572 TEST_CASE_ST(ut_setup, ut_teardown,
12573 test_snow3g_encryption_test_case_1_oop),
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_snow3g_decryption_test_case_1_oop),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_encryption_test_case_1_oop_sgl),
12579 /** SNOW 3G decrypt only (UEA2) */
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_snow3g_decryption_test_case_1),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_snow3g_decryption_test_case_2),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_snow3g_decryption_test_case_3),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_snow3g_decryption_test_case_4),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_snow3g_decryption_test_case_5),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_snow3g_hash_generate_test_case_1),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_snow3g_hash_generate_test_case_2),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_snow3g_hash_generate_test_case_3),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_snow3g_hash_verify_test_case_1),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_snow3g_hash_verify_test_case_2),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_snow3g_hash_verify_test_case_3),
12604 /** ZUC encrypt only (EEA3) */
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_zuc_encryption_test_case_1),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_zuc_encryption_test_case_2),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_zuc_encryption_test_case_3),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_zuc_encryption_test_case_4),
12613 TEST_CASE_ST(ut_setup, ut_teardown,
12614 test_zuc_encryption_test_case_5),
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_zuc_hash_generate_test_case_1),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_zuc_hash_generate_test_case_2),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_zuc_hash_generate_test_case_3),
12621 TEST_CASE_ST(ut_setup, ut_teardown,
12622 test_zuc_hash_generate_test_case_4),
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_zuc_hash_generate_test_case_5),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_zuc_encryption_test_case_6_sgl),
12628 /** KASUMI encrypt only (UEA1) */
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_kasumi_encryption_test_case_1),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_kasumi_encryption_test_case_2),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_kasumi_encryption_test_case_3),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_kasumi_encryption_test_case_4),
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_kasumi_encryption_test_case_5),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_kasumi_encryption_test_case_1_sgl),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_kasumi_encryption_test_case_1_oop_sgl),
12643 /** KASUMI decrypt only (UEA1) */
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_kasumi_decryption_test_case_1),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_kasumi_decryption_test_case_2),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_kasumi_decryption_test_case_3),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_kasumi_decryption_test_case_4),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_kasumi_decryption_test_case_5),
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 test_kasumi_encryption_test_case_1_oop),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_kasumi_decryption_test_case_1_oop),
12660 /** KASUMI hash only (UIA1) */
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_kasumi_hash_generate_test_case_1),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_kasumi_hash_generate_test_case_2),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_kasumi_hash_generate_test_case_3),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 test_kasumi_hash_generate_test_case_4),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_kasumi_hash_generate_test_case_5),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_kasumi_hash_generate_test_case_6),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_kasumi_hash_verify_test_case_1),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_kasumi_hash_verify_test_case_2),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_kasumi_hash_verify_test_case_3),
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_kasumi_hash_verify_test_case_4),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_kasumi_hash_verify_test_case_5),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_null_cipher_only_operation),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_null_auth_only_operation),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_null_cipher_auth_operation),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_null_auth_cipher_operation),
12694 /** Negative tests */
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 authentication_verify_AES128_GMAC_fail_data_corrupt),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12707 TEST_CASES_END() /**< NULL terminate unit test array */
12711 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12712 .suite_name = "Crypto NITROX Unit Test Suite",
12713 .setup = testsuite_setup,
12714 .teardown = testsuite_teardown,
12715 .unit_test_cases = {
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_device_configure_invalid_dev_id),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_device_configure_invalid_queue_pair_ids),
12720 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12721 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12723 TEST_CASES_END() /**< NULL terminate unit test array */
12727 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
12728 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
12729 .setup = testsuite_setup,
12730 .teardown = testsuite_teardown,
12731 .unit_test_cases = {
12732 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12733 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12734 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12735 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12736 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12738 /** AES GCM Authenticated Encryption */
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_authenticated_encryption_test_case_1),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_authenticated_encryption_test_case_2),
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_authenticated_encryption_test_case_3),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_encryption_test_case_4),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_encryption_test_case_5),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_authenticated_encryption_test_case_6),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_authenticated_encryption_test_case_7),
12754 /** AES GCM Authenticated Decryption */
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_authenticated_decryption_test_case_1),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_authenticated_decryption_test_case_2),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_authenticated_decryption_test_case_3),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_authenticated_decryption_test_case_4),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_authenticated_decryption_test_case_5),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_authenticated_decryption_test_case_6),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_authenticated_decryption_test_case_7),
12769 /** AES GMAC Authentication */
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_AES_GMAC_authentication_test_case_1),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_AES_GMAC_authentication_verify_test_case_1),
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GMAC_authentication_test_case_2),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_AES_GMAC_authentication_verify_test_case_2),
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_AES_GMAC_authentication_test_case_3),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GMAC_authentication_verify_test_case_3),
12783 /** SNOW 3G encrypt only (UEA2) */
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_snow3g_encryption_test_case_1),
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_snow3g_encryption_test_case_2),
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_snow3g_encryption_test_case_3),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_snow3g_encryption_test_case_4),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_snow3g_encryption_test_case_5),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_snow3g_encryption_test_case_1_oop),
12797 TEST_CASE_ST(ut_setup, ut_teardown,
12798 test_snow3g_decryption_test_case_1_oop),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_snow3g_encryption_test_case_1_oop_sgl),
12802 /** SNOW 3G decrypt only (UEA2) */
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_snow3g_decryption_test_case_1),
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_snow3g_decryption_test_case_2),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_snow3g_decryption_test_case_3),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_snow3g_decryption_test_case_4),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_snow3g_decryption_test_case_5),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_snow3g_hash_generate_test_case_1),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_snow3g_hash_generate_test_case_2),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_snow3g_hash_generate_test_case_3),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_snow3g_hash_verify_test_case_1),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_snow3g_hash_verify_test_case_2),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_snow3g_hash_verify_test_case_3),
12827 /** ZUC encrypt only (EEA3) */
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_zuc_encryption_test_case_1),
12830 TEST_CASE_ST(ut_setup, ut_teardown,
12831 test_zuc_encryption_test_case_2),
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_zuc_encryption_test_case_3),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_zuc_encryption_test_case_4),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_zuc_encryption_test_case_5),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_zuc_hash_generate_test_case_1),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_zuc_hash_generate_test_case_2),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_zuc_hash_generate_test_case_3),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_zuc_hash_generate_test_case_4),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_zuc_hash_generate_test_case_5),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_zuc_encryption_test_case_6_sgl),
12851 /** KASUMI encrypt only (UEA1) */
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_kasumi_encryption_test_case_1),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_kasumi_encryption_test_case_2),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_kasumi_encryption_test_case_3),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_kasumi_encryption_test_case_4),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_kasumi_encryption_test_case_5),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_kasumi_encryption_test_case_1_sgl),
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 test_kasumi_encryption_test_case_1_oop_sgl),
12866 /** KASUMI decrypt only (UEA1) */
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_kasumi_decryption_test_case_1),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_kasumi_decryption_test_case_2),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_kasumi_decryption_test_case_3),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_kasumi_decryption_test_case_4),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_kasumi_decryption_test_case_5),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_kasumi_encryption_test_case_1_oop),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_kasumi_decryption_test_case_1_oop),
12883 /** KASUMI hash only (UIA1) */
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_kasumi_hash_generate_test_case_1),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_kasumi_hash_generate_test_case_2),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_kasumi_hash_generate_test_case_3),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_kasumi_hash_generate_test_case_4),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_kasumi_hash_generate_test_case_5),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_kasumi_hash_generate_test_case_6),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_hash_verify_test_case_1),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_hash_verify_test_case_2),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_kasumi_hash_verify_test_case_3),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_hash_verify_test_case_4),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_kasumi_hash_verify_test_case_5),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_null_cipher_only_operation),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 test_null_auth_only_operation),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_null_cipher_auth_operation),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_null_auth_cipher_operation),
12917 /** Negative tests */
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 authentication_verify_AES128_GMAC_fail_data_corrupt),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12930 TEST_CASES_END() /**< NULL terminate unit test array */
12935 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12937 gbl_driver_id = rte_cryptodev_driver_id_get(
12938 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12940 if (gbl_driver_id == -1) {
12941 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12942 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12943 "are enabled in config file to run this testsuite.\n");
12944 return TEST_SKIPPED;
12947 return unit_test_suite_runner(&cryptodev_testsuite);
12951 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12953 gbl_driver_id = rte_cryptodev_driver_id_get(
12954 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12956 if (gbl_driver_id == -1) {
12957 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12958 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12959 "in config file to run this testsuite.\n");
12960 return TEST_FAILED;
12963 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12967 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12969 gbl_driver_id = rte_cryptodev_driver_id_get(
12970 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12972 if (gbl_driver_id == -1) {
12973 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12974 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12975 "in config file to run this testsuite.\n");
12976 return TEST_SKIPPED;
12979 return unit_test_suite_runner(&cryptodev_testsuite);
12983 test_cryptodev_cpu_aesni_mb(void)
12986 enum rte_security_session_action_type at;
12988 gbl_driver_id = rte_cryptodev_driver_id_get(
12989 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12991 if (gbl_driver_id == -1) {
12992 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12993 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12994 "in config file to run this testsuite.\n");
12995 return TEST_SKIPPED;
12998 at = gbl_action_type;
12999 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13000 rc = unit_test_suite_runner(&cryptodev_testsuite);
13001 gbl_action_type = at;
13006 test_cryptodev_openssl(void)
13008 gbl_driver_id = rte_cryptodev_driver_id_get(
13009 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13011 if (gbl_driver_id == -1) {
13012 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13013 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13014 "in config file to run this testsuite.\n");
13015 return TEST_SKIPPED;
13018 return unit_test_suite_runner(&cryptodev_testsuite);
13022 test_cryptodev_aesni_gcm(void)
13024 gbl_driver_id = rte_cryptodev_driver_id_get(
13025 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13027 if (gbl_driver_id == -1) {
13028 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13029 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13030 "in config file to run this testsuite.\n");
13031 return TEST_SKIPPED;
13034 return unit_test_suite_runner(&cryptodev_testsuite);
13038 test_cryptodev_cpu_aesni_gcm(void)
13041 enum rte_security_session_action_type at;
13043 gbl_driver_id = rte_cryptodev_driver_id_get(
13044 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13046 if (gbl_driver_id == -1) {
13047 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13048 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13049 "in config file to run this testsuite.\n");
13050 return TEST_SKIPPED;
13053 at = gbl_action_type;
13054 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13055 rc = unit_test_suite_runner(&cryptodev_testsuite);
13056 gbl_action_type = at;
13061 test_cryptodev_null(void)
13063 gbl_driver_id = rte_cryptodev_driver_id_get(
13064 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13066 if (gbl_driver_id == -1) {
13067 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13068 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13069 "in config file to run this testsuite.\n");
13070 return TEST_SKIPPED;
13073 return unit_test_suite_runner(&cryptodev_testsuite);
13077 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13079 gbl_driver_id = rte_cryptodev_driver_id_get(
13080 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13082 if (gbl_driver_id == -1) {
13083 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13084 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13085 "in config file to run this testsuite.\n");
13086 return TEST_SKIPPED;
13089 return unit_test_suite_runner(&cryptodev_testsuite);
13093 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13095 gbl_driver_id = rte_cryptodev_driver_id_get(
13096 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13098 if (gbl_driver_id == -1) {
13099 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13100 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13101 "in config file to run this testsuite.\n");
13102 return TEST_SKIPPED;
13105 return unit_test_suite_runner(&cryptodev_testsuite);
13109 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13111 gbl_driver_id = rte_cryptodev_driver_id_get(
13112 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13114 if (gbl_driver_id == -1) {
13115 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13116 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13117 "in config file to run this testsuite.\n");
13118 return TEST_SKIPPED;
13121 return unit_test_suite_runner(&cryptodev_testsuite);
13125 test_cryptodev_armv8(void)
13127 gbl_driver_id = rte_cryptodev_driver_id_get(
13128 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13130 if (gbl_driver_id == -1) {
13131 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13132 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13133 "in config file to run this testsuite.\n");
13134 return TEST_SKIPPED;
13137 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13141 test_cryptodev_mrvl(void)
13143 gbl_driver_id = rte_cryptodev_driver_id_get(
13144 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13146 if (gbl_driver_id == -1) {
13147 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13148 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13149 "in config file to run this testsuite.\n");
13150 return TEST_SKIPPED;
13153 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13156 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13159 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13161 gbl_driver_id = rte_cryptodev_driver_id_get(
13162 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13164 if (gbl_driver_id == -1) {
13165 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13166 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13167 "in config file to run this testsuite.\n");
13168 return TEST_SKIPPED;
13171 if (rte_cryptodev_driver_id_get(
13172 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13173 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13174 " enabled in config file to run this testsuite.\n");
13175 return TEST_SKIPPED;
13177 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13180 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13185 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13187 gbl_driver_id = rte_cryptodev_driver_id_get(
13188 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13190 if (gbl_driver_id == -1) {
13191 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13192 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13193 "in config file to run this testsuite.\n");
13194 return TEST_SKIPPED;
13197 return unit_test_suite_runner(&cryptodev_testsuite);
13201 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13203 gbl_driver_id = rte_cryptodev_driver_id_get(
13204 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13206 if (gbl_driver_id == -1) {
13207 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13208 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13209 "in config file to run this testsuite.\n");
13210 return TEST_SKIPPED;
13213 return unit_test_suite_runner(&cryptodev_testsuite);
13217 test_cryptodev_ccp(void)
13219 gbl_driver_id = rte_cryptodev_driver_id_get(
13220 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13222 if (gbl_driver_id == -1) {
13223 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13224 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13225 "in config file to run this testsuite.\n");
13226 return TEST_FAILED;
13229 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13233 test_cryptodev_octeontx(void)
13235 gbl_driver_id = rte_cryptodev_driver_id_get(
13236 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13237 if (gbl_driver_id == -1) {
13238 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13239 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13240 "enabled in config file to run this "
13242 return TEST_FAILED;
13244 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13248 test_cryptodev_octeontx2(void)
13250 gbl_driver_id = rte_cryptodev_driver_id_get(
13251 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13252 if (gbl_driver_id == -1) {
13253 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13254 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13255 "enabled in config file to run this "
13257 return TEST_FAILED;
13259 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13263 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13265 gbl_driver_id = rte_cryptodev_driver_id_get(
13266 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13268 if (gbl_driver_id == -1) {
13269 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13270 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13271 "in config file to run this testsuite.\n");
13272 return TEST_FAILED;
13275 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13279 test_cryptodev_nitrox(void)
13281 gbl_driver_id = rte_cryptodev_driver_id_get(
13282 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13284 if (gbl_driver_id == -1) {
13285 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13286 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13287 "in config file to run this testsuite.\n");
13288 return TEST_FAILED;
13291 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13294 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13295 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13296 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13297 test_cryptodev_cpu_aesni_mb);
13298 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13299 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13300 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13301 test_cryptodev_cpu_aesni_gcm);
13302 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13303 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13304 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13305 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13306 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13307 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13308 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13309 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13310 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13311 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13312 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13313 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13314 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13315 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);