1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* This test is for QAT and NITROX PMDs only */
771 if (gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
773 gbl_driver_id != rte_cryptodev_driver_id_get(
774 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
777 /* Stop the device in case it's started so it can be configured */
778 rte_cryptodev_stop(ts_params->valid_devs[0]);
780 /* valid - one queue pairs */
781 ts_params->conf.nb_queue_pairs = 1;
783 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
785 "Failed to configure cryptodev: dev_id %u, qp_id %u",
786 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
789 /* valid - max value queue pairs */
790 ts_params->conf.nb_queue_pairs = orig_nb_qps;
792 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
794 "Failed to configure cryptodev: dev_id %u, qp_id %u",
795 ts_params->valid_devs[0],
796 ts_params->conf.nb_queue_pairs);
799 /* invalid - zero queue pairs */
800 ts_params->conf.nb_queue_pairs = 0;
802 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
804 "Failed test for rte_cryptodev_configure, dev_id %u,"
806 ts_params->valid_devs[0],
807 ts_params->conf.nb_queue_pairs);
810 /* invalid - max value supported by field queue pairs */
811 ts_params->conf.nb_queue_pairs = UINT16_MAX;
813 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
815 "Failed test for rte_cryptodev_configure, dev_id %u,"
817 ts_params->valid_devs[0],
818 ts_params->conf.nb_queue_pairs);
821 /* invalid - max value + 1 queue pairs */
822 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
824 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
826 "Failed test for rte_cryptodev_configure, dev_id %u,"
828 ts_params->valid_devs[0],
829 ts_params->conf.nb_queue_pairs);
831 /* revert to original testsuite value */
832 ts_params->conf.nb_queue_pairs = orig_nb_qps;
838 test_queue_pair_descriptor_setup(void)
840 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 struct rte_cryptodev_info dev_info;
842 struct rte_cryptodev_qp_conf qp_conf = {
843 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
848 /* This test is for QAT PMD only */
849 if (gbl_driver_id != rte_cryptodev_driver_id_get(
850 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
853 /* Stop the device in case it's started so it can be configured */
854 rte_cryptodev_stop(ts_params->valid_devs[0]);
857 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
859 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
861 "Failed to configure cryptodev %u",
862 ts_params->valid_devs[0]);
865 * Test various ring sizes on this device. memzones can't be
866 * freed so are re-used if ring is released and re-created.
868 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
869 qp_conf.mp_session = ts_params->session_mpool;
870 qp_conf.mp_session_private = ts_params->session_priv_mpool;
872 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
873 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
874 ts_params->valid_devs[0], qp_id, &qp_conf,
875 rte_cryptodev_socket_id(
876 ts_params->valid_devs[0])),
878 "rte_cryptodev_queue_pair_setup: num_inflights "
879 "%u on qp %u on cryptodev %u",
880 qp_conf.nb_descriptors, qp_id,
881 ts_params->valid_devs[0]);
884 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
886 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
887 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
888 ts_params->valid_devs[0], qp_id, &qp_conf,
889 rte_cryptodev_socket_id(
890 ts_params->valid_devs[0])),
892 " rte_cryptodev_queue_pair_setup: num_inflights"
893 " %u on qp %u on cryptodev %u",
894 qp_conf.nb_descriptors, qp_id,
895 ts_params->valid_devs[0]);
898 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
900 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
901 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
902 ts_params->valid_devs[0], qp_id, &qp_conf,
903 rte_cryptodev_socket_id(
904 ts_params->valid_devs[0])),
906 "rte_cryptodev_queue_pair_setup: num_inflights"
907 " %u on qp %u on cryptodev %u",
908 qp_conf.nb_descriptors, qp_id,
909 ts_params->valid_devs[0]);
912 /* invalid number of descriptors - max supported + 2 */
913 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
915 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
916 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
917 ts_params->valid_devs[0], qp_id, &qp_conf,
918 rte_cryptodev_socket_id(
919 ts_params->valid_devs[0])),
920 "Unexpectedly passed test for "
921 "rte_cryptodev_queue_pair_setup:"
922 "num_inflights %u on qp %u on cryptodev %u",
923 qp_conf.nb_descriptors, qp_id,
924 ts_params->valid_devs[0]);
927 /* invalid number of descriptors - max value of parameter */
928 qp_conf.nb_descriptors = UINT32_MAX-1;
930 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
931 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
932 ts_params->valid_devs[0], qp_id, &qp_conf,
933 rte_cryptodev_socket_id(
934 ts_params->valid_devs[0])),
935 "Unexpectedly passed test for "
936 "rte_cryptodev_queue_pair_setup:"
937 "num_inflights %u on qp %u on cryptodev %u",
938 qp_conf.nb_descriptors, qp_id,
939 ts_params->valid_devs[0]);
942 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
944 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
945 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
946 ts_params->valid_devs[0], qp_id, &qp_conf,
947 rte_cryptodev_socket_id(
948 ts_params->valid_devs[0])),
950 " rte_cryptodev_queue_pair_setup:"
951 "num_inflights %u on qp %u on cryptodev %u",
952 qp_conf.nb_descriptors, qp_id,
953 ts_params->valid_devs[0]);
956 /* invalid number of descriptors - max supported + 1 */
957 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
959 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
960 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
961 ts_params->valid_devs[0], qp_id, &qp_conf,
962 rte_cryptodev_socket_id(
963 ts_params->valid_devs[0])),
964 "Unexpectedly passed test for "
965 "rte_cryptodev_queue_pair_setup:"
966 "num_inflights %u on qp %u on cryptodev %u",
967 qp_conf.nb_descriptors, qp_id,
968 ts_params->valid_devs[0]);
971 /* test invalid queue pair id */
972 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
974 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
976 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
977 ts_params->valid_devs[0],
979 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
980 "Failed test for rte_cryptodev_queue_pair_setup:"
981 "invalid qp %u on cryptodev %u",
982 qp_id, ts_params->valid_devs[0]);
984 qp_id = 0xffff; /*invalid*/
986 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
987 ts_params->valid_devs[0],
989 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
990 "Failed test for rte_cryptodev_queue_pair_setup:"
991 "invalid qp %u on cryptodev %u",
992 qp_id, ts_params->valid_devs[0]);
997 /* ***** Plaintext data for tests ***** */
999 const char catch_22_quote_1[] =
1000 "There was only one catch and that was Catch-22, which "
1001 "specified that a concern for one's safety in the face of "
1002 "dangers that were real and immediate was the process of a "
1003 "rational mind. Orr was crazy and could be grounded. All he "
1004 "had to do was ask; and as soon as he did, he would no longer "
1005 "be crazy and would have to fly more missions. Orr would be "
1006 "crazy to fly more missions and sane if he didn't, but if he "
1007 "was sane he had to fly them. If he flew them he was crazy "
1008 "and didn't have to; but if he didn't want to he was sane and "
1009 "had to. Yossarian was moved very deeply by the absolute "
1010 "simplicity of this clause of Catch-22 and let out a "
1011 "respectful whistle. \"That's some catch, that Catch-22\", he "
1012 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1014 const char catch_22_quote[] =
1015 "What a lousy earth! He wondered how many people were "
1016 "destitute that same night even in his own prosperous country, "
1017 "how many homes were shanties, how many husbands were drunk "
1018 "and wives socked, and how many children were bullied, abused, "
1019 "or abandoned. How many families hungered for food they could "
1020 "not afford to buy? How many hearts were broken? How many "
1021 "suicides would take place that same night, how many people "
1022 "would go insane? How many cockroaches and landlords would "
1023 "triumph? How many winners were losers, successes failures, "
1024 "and rich men poor men? How many wise guys were stupid? How "
1025 "many happy endings were unhappy endings? How many honest men "
1026 "were liars, brave men cowards, loyal men traitors, how many "
1027 "sainted men were corrupt, how many people in positions of "
1028 "trust had sold their souls to bodyguards, how many had never "
1029 "had souls? How many straight-and-narrow paths were crooked "
1030 "paths? How many best families were worst families and how "
1031 "many good people were bad people? When you added them all up "
1032 "and then subtracted, you might be left with only the children, "
1033 "and perhaps with Albert Einstein and an old violinist or "
1034 "sculptor somewhere.";
1036 #define QUOTE_480_BYTES (480)
1037 #define QUOTE_512_BYTES (512)
1038 #define QUOTE_768_BYTES (768)
1039 #define QUOTE_1024_BYTES (1024)
1043 /* ***** SHA1 Hash Tests ***** */
1045 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1047 static uint8_t hmac_sha1_key[] = {
1048 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1049 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1050 0xDE, 0xF4, 0xDE, 0xAD };
1052 /* ***** SHA224 Hash Tests ***** */
1054 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1057 /* ***** AES-CBC Cipher Tests ***** */
1059 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1060 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1062 static uint8_t aes_cbc_key[] = {
1063 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1064 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1066 static uint8_t aes_cbc_iv[] = {
1067 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1068 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1071 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1073 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1074 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1075 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1076 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1077 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1078 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1079 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1080 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1081 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1082 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1083 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1084 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1085 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1086 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1087 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1088 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1089 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1090 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1091 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1092 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1093 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1094 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1095 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1096 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1097 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1098 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1099 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1100 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1101 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1102 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1103 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1104 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1105 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1106 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1107 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1108 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1109 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1110 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1111 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1112 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1113 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1114 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1115 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1116 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1117 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1118 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1119 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1120 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1121 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1122 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1123 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1124 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1125 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1126 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1127 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1128 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1129 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1130 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1131 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1132 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1133 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1134 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1135 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1136 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1137 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1140 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1141 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1142 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1143 0x18, 0x8c, 0x1d, 0x32
1147 /* Multisession Vector context Test */
1148 /*Begin Session 0 */
1149 static uint8_t ms_aes_cbc_key0[] = {
1150 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1151 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1154 static uint8_t ms_aes_cbc_iv0[] = {
1155 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1156 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1159 static const uint8_t ms_aes_cbc_cipher0[] = {
1160 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1161 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1162 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1163 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1164 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1165 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1166 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1167 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1168 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1169 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1170 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1171 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1172 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1173 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1174 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1175 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1176 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1177 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1178 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1179 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1180 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1181 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1182 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1183 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1184 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1185 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1186 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1187 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1188 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1189 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1190 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1191 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1192 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1193 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1194 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1195 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1196 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1197 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1198 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1199 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1200 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1201 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1202 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1203 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1204 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1205 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1206 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1207 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1208 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1209 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1210 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1211 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1212 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1213 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1214 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1215 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1216 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1217 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1218 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1219 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1220 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1221 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1222 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1223 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1227 static uint8_t ms_hmac_key0[] = {
1228 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1229 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1230 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1231 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1232 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1233 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1234 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1235 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1238 static const uint8_t ms_hmac_digest0[] = {
1239 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1240 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1241 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1242 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1243 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1244 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1245 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1246 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1250 /* Begin session 1 */
1252 static uint8_t ms_aes_cbc_key1[] = {
1253 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1254 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1257 static uint8_t ms_aes_cbc_iv1[] = {
1258 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1259 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1262 static const uint8_t ms_aes_cbc_cipher1[] = {
1263 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1264 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1265 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1266 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1267 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1268 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1269 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1270 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1271 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1272 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1273 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1274 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1275 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1276 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1277 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1278 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1279 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1280 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1281 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1282 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1283 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1284 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1285 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1286 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1287 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1288 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1289 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1290 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1291 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1292 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1293 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1294 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1295 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1296 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1297 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1298 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1299 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1300 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1301 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1302 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1303 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1304 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1305 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1306 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1307 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1308 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1309 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1310 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1311 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1312 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1313 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1314 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1315 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1316 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1317 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1318 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1319 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1320 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1321 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1322 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1323 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1324 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1325 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1326 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1330 static uint8_t ms_hmac_key1[] = {
1331 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1332 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1333 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1334 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1335 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1336 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1337 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1338 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1341 static const uint8_t ms_hmac_digest1[] = {
1342 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1343 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1344 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1345 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1346 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1347 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1348 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1349 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1352 /* Begin Session 2 */
1353 static uint8_t ms_aes_cbc_key2[] = {
1354 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1355 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1358 static uint8_t ms_aes_cbc_iv2[] = {
1359 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1360 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1363 static const uint8_t ms_aes_cbc_cipher2[] = {
1364 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1365 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1366 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1367 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1368 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1369 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1370 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1371 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1372 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1373 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1374 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1375 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1376 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1377 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1378 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1379 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1380 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1381 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1382 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1383 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1384 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1385 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1386 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1387 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1388 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1389 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1390 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1391 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1392 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1393 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1394 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1395 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1396 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1397 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1398 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1399 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1400 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1401 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1402 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1403 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1404 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1405 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1406 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1407 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1408 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1409 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1410 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1411 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1412 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1413 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1414 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1415 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1416 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1417 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1418 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1419 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1420 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1421 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1422 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1423 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1424 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1425 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1426 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1427 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1430 static uint8_t ms_hmac_key2[] = {
1431 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1432 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1433 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1434 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1435 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1436 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1437 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1438 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1441 static const uint8_t ms_hmac_digest2[] = {
1442 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1443 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1444 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1445 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1446 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1447 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1448 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1449 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1456 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1458 struct crypto_testsuite_params *ts_params = &testsuite_params;
1459 struct crypto_unittest_params *ut_params = &unittest_params;
1461 /* Verify the capabilities */
1462 struct rte_cryptodev_sym_capability_idx cap_idx;
1463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1464 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1469 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1474 /* Generate test mbuf data and space for digest */
1475 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1476 catch_22_quote, QUOTE_512_BYTES, 0);
1478 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1479 DIGEST_BYTE_LENGTH_SHA1);
1480 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1482 /* Setup Cipher Parameters */
1483 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1484 ut_params->cipher_xform.next = &ut_params->auth_xform;
1486 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1487 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1488 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1489 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1490 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1491 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1493 /* Setup HMAC Parameters */
1494 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1496 ut_params->auth_xform.next = NULL;
1498 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1499 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1500 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1501 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1502 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1504 ut_params->sess = rte_cryptodev_sym_session_create(
1505 ts_params->session_mpool);
1507 /* Create crypto session*/
1508 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1509 ut_params->sess, &ut_params->cipher_xform,
1510 ts_params->session_priv_mpool);
1511 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1513 /* Generate crypto op data structure */
1514 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1515 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1516 TEST_ASSERT_NOT_NULL(ut_params->op,
1517 "Failed to allocate symmetric crypto operation struct");
1519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1523 /* set crypto operation source mbuf */
1524 sym_op->m_src = ut_params->ibuf;
1526 /* Set crypto operation authentication parameters */
1527 sym_op->auth.digest.data = ut_params->digest;
1528 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1529 ut_params->ibuf, QUOTE_512_BYTES);
1531 sym_op->auth.data.offset = 0;
1532 sym_op->auth.data.length = QUOTE_512_BYTES;
1534 /* Copy IV at the end of the crypto operation */
1535 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1536 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1538 /* Set crypto operation cipher parameters */
1539 sym_op->cipher.data.offset = 0;
1540 sym_op->cipher.data.length = QUOTE_512_BYTES;
1542 /* Process crypto operation */
1543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1544 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1547 TEST_ASSERT_NOT_NULL(
1548 process_crypto_request(ts_params->valid_devs[0],
1550 "failed to process sym crypto op");
1552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1553 "crypto op processing failed");
1556 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1559 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1560 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1562 "ciphertext data not as expected");
1564 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1566 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1567 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1568 gbl_driver_id == rte_cryptodev_driver_id_get(
1569 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1570 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1571 DIGEST_BYTE_LENGTH_SHA1,
1572 "Generated digest data not as expected");
1574 return TEST_SUCCESS;
1577 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1579 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1581 static uint8_t hmac_sha512_key[] = {
1582 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1583 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1584 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1585 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1586 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1587 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1588 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1589 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1591 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1592 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1593 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1594 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1595 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1596 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1597 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1598 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1599 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1604 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1605 struct crypto_unittest_params *ut_params,
1606 uint8_t *cipher_key,
1610 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1611 struct crypto_unittest_params *ut_params,
1612 struct crypto_testsuite_params *ts_params,
1613 const uint8_t *cipher,
1614 const uint8_t *digest,
1619 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1620 struct crypto_unittest_params *ut_params,
1621 uint8_t *cipher_key,
1625 /* Setup Cipher Parameters */
1626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1627 ut_params->cipher_xform.next = NULL;
1629 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1630 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1631 ut_params->cipher_xform.cipher.key.data = cipher_key;
1632 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1633 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1634 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1636 /* Setup HMAC Parameters */
1637 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1638 ut_params->auth_xform.next = &ut_params->cipher_xform;
1640 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1641 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1642 ut_params->auth_xform.auth.key.data = hmac_key;
1643 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1644 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1646 return TEST_SUCCESS;
1651 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1652 struct crypto_unittest_params *ut_params,
1653 struct crypto_testsuite_params *ts_params,
1654 const uint8_t *cipher,
1655 const uint8_t *digest,
1658 /* Generate test mbuf data and digest */
1659 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1662 QUOTE_512_BYTES, 0);
1664 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1665 DIGEST_BYTE_LENGTH_SHA512);
1666 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1668 rte_memcpy(ut_params->digest,
1670 DIGEST_BYTE_LENGTH_SHA512);
1672 /* Generate Crypto op data structure */
1673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1675 TEST_ASSERT_NOT_NULL(ut_params->op,
1676 "Failed to allocate symmetric crypto operation struct");
1678 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1680 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1682 /* set crypto operation source mbuf */
1683 sym_op->m_src = ut_params->ibuf;
1685 sym_op->auth.digest.data = ut_params->digest;
1686 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1687 ut_params->ibuf, QUOTE_512_BYTES);
1689 sym_op->auth.data.offset = 0;
1690 sym_op->auth.data.length = QUOTE_512_BYTES;
1692 /* Copy IV at the end of the crypto operation */
1693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1694 iv, CIPHER_IV_LENGTH_AES_CBC);
1696 sym_op->cipher.data.offset = 0;
1697 sym_op->cipher.data.length = QUOTE_512_BYTES;
1699 /* Process crypto operation */
1700 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1701 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1704 TEST_ASSERT_NOT_NULL(
1705 process_crypto_request(ts_params->valid_devs[0],
1707 "failed to process sym crypto op");
1709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1710 "crypto op processing failed");
1712 ut_params->obuf = ut_params->op->sym->m_src;
1715 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1716 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1719 "Plaintext data not as expected");
1722 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1723 "Digest verification failed");
1725 return TEST_SUCCESS;
1729 test_blockcipher(enum blockcipher_test_type test_type)
1731 struct crypto_testsuite_params *ts_params = &testsuite_params;
1734 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1735 ts_params->op_mpool,
1736 ts_params->session_mpool, ts_params->session_priv_mpool,
1737 ts_params->valid_devs[0],
1740 if (status == -ENOTSUP)
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 return TEST_SUCCESS;
1749 test_AES_cipheronly_all(void)
1751 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1755 test_AES_docsis_all(void)
1757 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1761 test_DES_docsis_all(void)
1763 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1767 test_DES_cipheronly_all(void)
1769 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1773 test_authonly_all(void)
1775 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1779 test_AES_chain_all(void)
1781 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1785 test_3DES_chain_all(void)
1787 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1791 test_3DES_cipheronly_all(void)
1793 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1796 /* ***** SNOW 3G Tests ***** */
1798 create_wireless_algo_hash_session(uint8_t dev_id,
1799 const uint8_t *key, const uint8_t key_len,
1800 const uint8_t iv_len, const uint8_t auth_len,
1801 enum rte_crypto_auth_operation op,
1802 enum rte_crypto_auth_algorithm algo)
1804 uint8_t hash_key[key_len];
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 struct crypto_unittest_params *ut_params = &unittest_params;
1810 memcpy(hash_key, key, key_len);
1812 debug_hexdump(stdout, "key:", key, key_len);
1814 /* Setup Authentication Parameters */
1815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1816 ut_params->auth_xform.next = NULL;
1818 ut_params->auth_xform.auth.op = op;
1819 ut_params->auth_xform.auth.algo = algo;
1820 ut_params->auth_xform.auth.key.length = key_len;
1821 ut_params->auth_xform.auth.key.data = hash_key;
1822 ut_params->auth_xform.auth.digest_length = auth_len;
1823 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1824 ut_params->auth_xform.auth.iv.length = iv_len;
1825 ut_params->sess = rte_cryptodev_sym_session_create(
1826 ts_params->session_mpool);
1828 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1829 &ut_params->auth_xform,
1830 ts_params->session_priv_mpool);
1831 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1837 create_wireless_algo_cipher_session(uint8_t dev_id,
1838 enum rte_crypto_cipher_operation op,
1839 enum rte_crypto_cipher_algorithm algo,
1840 const uint8_t *key, const uint8_t key_len,
1843 uint8_t cipher_key[key_len];
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 struct crypto_unittest_params *ut_params = &unittest_params;
1848 memcpy(cipher_key, key, key_len);
1850 /* Setup Cipher Parameters */
1851 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1852 ut_params->cipher_xform.next = NULL;
1854 ut_params->cipher_xform.cipher.algo = algo;
1855 ut_params->cipher_xform.cipher.op = op;
1856 ut_params->cipher_xform.cipher.key.data = cipher_key;
1857 ut_params->cipher_xform.cipher.key.length = key_len;
1858 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1859 ut_params->cipher_xform.cipher.iv.length = iv_len;
1861 debug_hexdump(stdout, "key:", key, key_len);
1863 /* Create Crypto session */
1864 ut_params->sess = rte_cryptodev_sym_session_create(
1865 ts_params->session_mpool);
1867 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1868 &ut_params->cipher_xform,
1869 ts_params->session_priv_mpool);
1870 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1871 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1876 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1877 unsigned int cipher_len,
1878 unsigned int cipher_offset)
1880 struct crypto_testsuite_params *ts_params = &testsuite_params;
1881 struct crypto_unittest_params *ut_params = &unittest_params;
1883 /* Generate Crypto op data structure */
1884 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1885 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1886 TEST_ASSERT_NOT_NULL(ut_params->op,
1887 "Failed to allocate pktmbuf offload");
1889 /* Set crypto operation data parameters */
1890 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1892 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1894 /* set crypto operation source mbuf */
1895 sym_op->m_src = ut_params->ibuf;
1898 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1900 sym_op->cipher.data.length = cipher_len;
1901 sym_op->cipher.data.offset = cipher_offset;
1906 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1907 unsigned int cipher_len,
1908 unsigned int cipher_offset)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1911 struct crypto_unittest_params *ut_params = &unittest_params;
1913 /* Generate Crypto op data structure */
1914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1916 TEST_ASSERT_NOT_NULL(ut_params->op,
1917 "Failed to allocate pktmbuf offload");
1919 /* Set crypto operation data parameters */
1920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1922 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1924 /* set crypto operation source mbuf */
1925 sym_op->m_src = ut_params->ibuf;
1926 sym_op->m_dst = ut_params->obuf;
1929 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1931 sym_op->cipher.data.length = cipher_len;
1932 sym_op->cipher.data.offset = cipher_offset;
1937 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1938 enum rte_crypto_cipher_operation cipher_op,
1939 enum rte_crypto_auth_operation auth_op,
1940 enum rte_crypto_auth_algorithm auth_algo,
1941 enum rte_crypto_cipher_algorithm cipher_algo,
1942 const uint8_t *key, uint8_t key_len,
1943 uint8_t auth_iv_len, uint8_t auth_len,
1944 uint8_t cipher_iv_len)
1947 uint8_t cipher_auth_key[key_len];
1950 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 struct crypto_unittest_params *ut_params = &unittest_params;
1953 memcpy(cipher_auth_key, key, key_len);
1955 /* Setup Authentication Parameters */
1956 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1957 ut_params->auth_xform.next = NULL;
1959 ut_params->auth_xform.auth.op = auth_op;
1960 ut_params->auth_xform.auth.algo = auth_algo;
1961 ut_params->auth_xform.auth.key.length = key_len;
1962 /* Hash key = cipher key */
1963 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1964 ut_params->auth_xform.auth.digest_length = auth_len;
1965 /* Auth IV will be after cipher IV */
1966 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1967 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1969 /* Setup Cipher Parameters */
1970 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1971 ut_params->cipher_xform.next = &ut_params->auth_xform;
1973 ut_params->cipher_xform.cipher.algo = cipher_algo;
1974 ut_params->cipher_xform.cipher.op = cipher_op;
1975 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1976 ut_params->cipher_xform.cipher.key.length = key_len;
1977 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1978 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1980 debug_hexdump(stdout, "key:", key, key_len);
1982 /* Create Crypto session*/
1983 ut_params->sess = rte_cryptodev_sym_session_create(
1984 ts_params->session_mpool);
1985 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1987 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1988 &ut_params->cipher_xform,
1989 ts_params->session_priv_mpool);
1990 if (status == -ENOTSUP)
1993 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1998 create_wireless_cipher_auth_session(uint8_t dev_id,
1999 enum rte_crypto_cipher_operation cipher_op,
2000 enum rte_crypto_auth_operation auth_op,
2001 enum rte_crypto_auth_algorithm auth_algo,
2002 enum rte_crypto_cipher_algorithm cipher_algo,
2003 const struct wireless_test_data *tdata)
2005 const uint8_t key_len = tdata->key.len;
2006 uint8_t cipher_auth_key[key_len];
2009 struct crypto_testsuite_params *ts_params = &testsuite_params;
2010 struct crypto_unittest_params *ut_params = &unittest_params;
2011 const uint8_t *key = tdata->key.data;
2012 const uint8_t auth_len = tdata->digest.len;
2013 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2014 uint8_t auth_iv_len = tdata->auth_iv.len;
2016 memcpy(cipher_auth_key, key, key_len);
2018 /* Setup Authentication Parameters */
2019 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2020 ut_params->auth_xform.next = NULL;
2022 ut_params->auth_xform.auth.op = auth_op;
2023 ut_params->auth_xform.auth.algo = auth_algo;
2024 ut_params->auth_xform.auth.key.length = key_len;
2025 /* Hash key = cipher key */
2026 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 /* Auth IV will be after cipher IV */
2029 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2030 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2032 /* Setup Cipher Parameters */
2033 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2034 ut_params->cipher_xform.next = &ut_params->auth_xform;
2036 ut_params->cipher_xform.cipher.algo = cipher_algo;
2037 ut_params->cipher_xform.cipher.op = cipher_op;
2038 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2039 ut_params->cipher_xform.cipher.key.length = key_len;
2040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2041 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2044 debug_hexdump(stdout, "key:", key, key_len);
2046 /* Create Crypto session*/
2047 ut_params->sess = rte_cryptodev_sym_session_create(
2048 ts_params->session_mpool);
2050 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2051 &ut_params->cipher_xform,
2052 ts_params->session_priv_mpool);
2053 if (status == -ENOTSUP)
2056 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2057 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2062 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2063 const struct wireless_test_data *tdata)
2065 return create_wireless_cipher_auth_session(dev_id,
2066 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2067 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2068 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2072 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2073 enum rte_crypto_cipher_operation cipher_op,
2074 enum rte_crypto_auth_operation auth_op,
2075 enum rte_crypto_auth_algorithm auth_algo,
2076 enum rte_crypto_cipher_algorithm cipher_algo,
2077 const uint8_t *key, const uint8_t key_len,
2078 uint8_t auth_iv_len, uint8_t auth_len,
2079 uint8_t cipher_iv_len)
2081 uint8_t auth_cipher_key[key_len];
2083 struct crypto_testsuite_params *ts_params = &testsuite_params;
2084 struct crypto_unittest_params *ut_params = &unittest_params;
2086 memcpy(auth_cipher_key, key, key_len);
2088 /* Setup Authentication Parameters */
2089 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2090 ut_params->auth_xform.auth.op = auth_op;
2091 ut_params->auth_xform.next = &ut_params->cipher_xform;
2092 ut_params->auth_xform.auth.algo = auth_algo;
2093 ut_params->auth_xform.auth.key.length = key_len;
2094 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2095 ut_params->auth_xform.auth.digest_length = auth_len;
2096 /* Auth IV will be after cipher IV */
2097 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2098 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2100 /* Setup Cipher Parameters */
2101 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2102 ut_params->cipher_xform.next = NULL;
2103 ut_params->cipher_xform.cipher.algo = cipher_algo;
2104 ut_params->cipher_xform.cipher.op = cipher_op;
2105 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2106 ut_params->cipher_xform.cipher.key.length = key_len;
2107 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2108 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2110 debug_hexdump(stdout, "key:", key, key_len);
2112 /* Create Crypto session*/
2113 ut_params->sess = rte_cryptodev_sym_session_create(
2114 ts_params->session_mpool);
2115 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2117 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2118 ut_params->auth_xform.next = NULL;
2119 ut_params->cipher_xform.next = &ut_params->auth_xform;
2120 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2121 &ut_params->cipher_xform,
2122 ts_params->session_priv_mpool);
2125 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2126 &ut_params->auth_xform,
2127 ts_params->session_priv_mpool);
2129 if (status == -ENOTSUP)
2132 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2138 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2139 unsigned int auth_tag_len,
2140 const uint8_t *iv, unsigned int iv_len,
2141 unsigned int data_pad_len,
2142 enum rte_crypto_auth_operation op,
2143 unsigned int auth_len, unsigned int auth_offset)
2145 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 struct crypto_unittest_params *ut_params = &unittest_params;
2149 /* Generate Crypto op data structure */
2150 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2151 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2152 TEST_ASSERT_NOT_NULL(ut_params->op,
2153 "Failed to allocate pktmbuf offload");
2155 /* Set crypto operation data parameters */
2156 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2158 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2160 /* set crypto operation source mbuf */
2161 sym_op->m_src = ut_params->ibuf;
2164 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2167 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2168 ut_params->ibuf, auth_tag_len);
2170 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2171 "no room to append auth tag");
2172 ut_params->digest = sym_op->auth.digest.data;
2173 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2174 ut_params->ibuf, data_pad_len);
2175 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2176 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2178 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2180 debug_hexdump(stdout, "digest:",
2181 sym_op->auth.digest.data,
2184 sym_op->auth.data.length = auth_len;
2185 sym_op->auth.data.offset = auth_offset;
2191 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2192 enum rte_crypto_auth_operation op)
2194 struct crypto_testsuite_params *ts_params = &testsuite_params;
2195 struct crypto_unittest_params *ut_params = &unittest_params;
2197 const uint8_t *auth_tag = tdata->digest.data;
2198 const unsigned int auth_tag_len = tdata->digest.len;
2199 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2200 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2202 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2203 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2204 const uint8_t *auth_iv = tdata->auth_iv.data;
2205 const uint8_t auth_iv_len = tdata->auth_iv.len;
2206 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2207 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2209 /* Generate Crypto op data structure */
2210 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2211 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2212 TEST_ASSERT_NOT_NULL(ut_params->op,
2213 "Failed to allocate pktmbuf offload");
2214 /* Set crypto operation data parameters */
2215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2217 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2219 /* set crypto operation source mbuf */
2220 sym_op->m_src = ut_params->ibuf;
2223 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2224 ut_params->ibuf, auth_tag_len);
2226 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2227 "no room to append auth tag");
2228 ut_params->digest = sym_op->auth.digest.data;
2229 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2230 ut_params->ibuf, data_pad_len);
2231 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2232 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2234 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2236 debug_hexdump(stdout, "digest:",
2237 sym_op->auth.digest.data,
2240 /* Copy cipher and auth IVs at the end of the crypto operation */
2241 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2243 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2244 iv_ptr += cipher_iv_len;
2245 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2247 sym_op->cipher.data.length = cipher_len;
2248 sym_op->cipher.data.offset = 0;
2249 sym_op->auth.data.length = auth_len;
2250 sym_op->auth.data.offset = 0;
2256 create_zuc_cipher_hash_generate_operation(
2257 const struct wireless_test_data *tdata)
2259 return create_wireless_cipher_hash_operation(tdata,
2260 RTE_CRYPTO_AUTH_OP_GENERATE);
2264 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2265 const unsigned auth_tag_len,
2266 const uint8_t *auth_iv, uint8_t auth_iv_len,
2267 unsigned data_pad_len,
2268 enum rte_crypto_auth_operation op,
2269 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2270 const unsigned cipher_len, const unsigned cipher_offset,
2271 const unsigned auth_len, const unsigned auth_offset)
2273 struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 struct crypto_unittest_params *ut_params = &unittest_params;
2276 enum rte_crypto_cipher_algorithm cipher_algo =
2277 ut_params->cipher_xform.cipher.algo;
2278 enum rte_crypto_auth_algorithm auth_algo =
2279 ut_params->auth_xform.auth.algo;
2281 /* Generate Crypto op data structure */
2282 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2283 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2284 TEST_ASSERT_NOT_NULL(ut_params->op,
2285 "Failed to allocate pktmbuf offload");
2286 /* Set crypto operation data parameters */
2287 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2289 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2291 /* set crypto operation source mbuf */
2292 sym_op->m_src = ut_params->ibuf;
2295 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2296 ut_params->ibuf, auth_tag_len);
2298 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2299 "no room to append auth tag");
2300 ut_params->digest = sym_op->auth.digest.data;
2302 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2303 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2304 ut_params->ibuf, data_pad_len);
2306 struct rte_mbuf *m = ut_params->ibuf;
2307 unsigned int offset = data_pad_len;
2309 while (offset > m->data_len && m->next != NULL) {
2310 offset -= m->data_len;
2313 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2317 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2318 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2320 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2322 debug_hexdump(stdout, "digest:",
2323 sym_op->auth.digest.data,
2326 /* Copy cipher and auth IVs at the end of the crypto operation */
2327 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2329 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2330 iv_ptr += cipher_iv_len;
2331 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2333 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2334 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2335 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2336 sym_op->cipher.data.length = cipher_len;
2337 sym_op->cipher.data.offset = cipher_offset;
2339 sym_op->cipher.data.length = cipher_len >> 3;
2340 sym_op->cipher.data.offset = cipher_offset >> 3;
2343 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2344 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2345 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2346 sym_op->auth.data.length = auth_len;
2347 sym_op->auth.data.offset = auth_offset;
2349 sym_op->auth.data.length = auth_len >> 3;
2350 sym_op->auth.data.offset = auth_offset >> 3;
2357 create_wireless_algo_auth_cipher_operation(
2358 const uint8_t *auth_tag, unsigned int auth_tag_len,
2359 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2360 const uint8_t *auth_iv, uint8_t auth_iv_len,
2361 unsigned int data_pad_len,
2362 unsigned int cipher_len, unsigned int cipher_offset,
2363 unsigned int auth_len, unsigned int auth_offset,
2364 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2366 struct crypto_testsuite_params *ts_params = &testsuite_params;
2367 struct crypto_unittest_params *ut_params = &unittest_params;
2369 enum rte_crypto_cipher_algorithm cipher_algo =
2370 ut_params->cipher_xform.cipher.algo;
2371 enum rte_crypto_auth_algorithm auth_algo =
2372 ut_params->auth_xform.auth.algo;
2374 /* Generate Crypto op data structure */
2375 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2376 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2377 TEST_ASSERT_NOT_NULL(ut_params->op,
2378 "Failed to allocate pktmbuf offload");
2380 /* Set crypto operation data parameters */
2381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2383 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2385 /* set crypto operation mbufs */
2386 sym_op->m_src = ut_params->ibuf;
2387 if (op_mode == OUT_OF_PLACE)
2388 sym_op->m_dst = ut_params->obuf;
2392 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2393 (op_mode == IN_PLACE ?
2394 ut_params->ibuf : ut_params->obuf),
2395 uint8_t *, data_pad_len);
2396 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2397 (op_mode == IN_PLACE ?
2398 ut_params->ibuf : ut_params->obuf),
2400 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2402 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2403 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2404 sym_op->m_src : sym_op->m_dst);
2405 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2406 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2407 sgl_buf = sgl_buf->next;
2409 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2410 uint8_t *, remaining_off);
2411 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2413 memset(sym_op->auth.digest.data, 0, remaining_off);
2414 while (sgl_buf->next != NULL) {
2415 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2416 0, rte_pktmbuf_data_len(sgl_buf));
2417 sgl_buf = sgl_buf->next;
2421 /* Copy digest for the verification */
2423 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2425 /* Copy cipher and auth IVs at the end of the crypto operation */
2426 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2427 ut_params->op, uint8_t *, IV_OFFSET);
2429 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2430 iv_ptr += cipher_iv_len;
2431 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2433 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2434 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2435 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2436 sym_op->cipher.data.length = cipher_len;
2437 sym_op->cipher.data.offset = cipher_offset;
2439 sym_op->cipher.data.length = cipher_len >> 3;
2440 sym_op->cipher.data.offset = cipher_offset >> 3;
2443 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2444 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2445 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2446 sym_op->auth.data.length = auth_len;
2447 sym_op->auth.data.offset = auth_offset;
2449 sym_op->auth.data.length = auth_len >> 3;
2450 sym_op->auth.data.offset = auth_offset >> 3;
2457 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2459 struct crypto_testsuite_params *ts_params = &testsuite_params;
2460 struct crypto_unittest_params *ut_params = &unittest_params;
2463 unsigned plaintext_pad_len;
2464 unsigned plaintext_len;
2466 struct rte_cryptodev_info dev_info;
2468 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2469 uint64_t feat_flags = dev_info.feature_flags;
2471 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2472 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2473 printf("Device doesn't support NON-Byte Aligned Data.\n");
2477 /* Verify the capabilities */
2478 struct rte_cryptodev_sym_capability_idx cap_idx;
2479 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2480 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2481 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2485 /* Create SNOW 3G session */
2486 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2487 tdata->key.data, tdata->key.len,
2488 tdata->auth_iv.len, tdata->digest.len,
2489 RTE_CRYPTO_AUTH_OP_GENERATE,
2490 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2494 /* alloc mbuf and set payload */
2495 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2497 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2498 rte_pktmbuf_tailroom(ut_params->ibuf));
2500 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2501 /* Append data which is padded to a multiple of */
2502 /* the algorithms block size */
2503 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2504 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2506 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2508 /* Create SNOW 3G operation */
2509 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2510 tdata->auth_iv.data, tdata->auth_iv.len,
2511 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2512 tdata->validAuthLenInBits.len,
2517 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2519 ut_params->obuf = ut_params->op->sym->m_src;
2520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2521 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2522 + plaintext_pad_len;
2525 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2528 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2529 "SNOW 3G Generated auth tag not as expected");
2535 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2537 struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 struct crypto_unittest_params *ut_params = &unittest_params;
2541 unsigned plaintext_pad_len;
2542 unsigned plaintext_len;
2544 struct rte_cryptodev_info dev_info;
2546 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2547 uint64_t feat_flags = dev_info.feature_flags;
2549 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2550 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2551 printf("Device doesn't support NON-Byte Aligned Data.\n");
2555 /* Verify the capabilities */
2556 struct rte_cryptodev_sym_capability_idx cap_idx;
2557 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2558 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2559 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2563 /* Create SNOW 3G session */
2564 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2565 tdata->key.data, tdata->key.len,
2566 tdata->auth_iv.len, tdata->digest.len,
2567 RTE_CRYPTO_AUTH_OP_VERIFY,
2568 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2571 /* alloc mbuf and set payload */
2572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2574 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2575 rte_pktmbuf_tailroom(ut_params->ibuf));
2577 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2578 /* Append data which is padded to a multiple of */
2579 /* the algorithms block size */
2580 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2581 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2583 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2585 /* Create SNOW 3G operation */
2586 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2588 tdata->auth_iv.data, tdata->auth_iv.len,
2590 RTE_CRYPTO_AUTH_OP_VERIFY,
2591 tdata->validAuthLenInBits.len,
2596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2599 ut_params->obuf = ut_params->op->sym->m_src;
2600 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2601 + plaintext_pad_len;
2604 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2613 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2615 struct crypto_testsuite_params *ts_params = &testsuite_params;
2616 struct crypto_unittest_params *ut_params = &unittest_params;
2619 unsigned plaintext_pad_len;
2620 unsigned plaintext_len;
2623 /* Verify the capabilities */
2624 struct rte_cryptodev_sym_capability_idx cap_idx;
2625 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2626 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2627 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2631 /* Create KASUMI session */
2632 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2633 tdata->key.data, tdata->key.len,
2634 0, tdata->digest.len,
2635 RTE_CRYPTO_AUTH_OP_GENERATE,
2636 RTE_CRYPTO_AUTH_KASUMI_F9);
2640 /* alloc mbuf and set payload */
2641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2644 rte_pktmbuf_tailroom(ut_params->ibuf));
2646 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2647 /* Append data which is padded to a multiple of */
2648 /* the algorithms block size */
2649 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2650 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2652 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2654 /* Create KASUMI operation */
2655 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2657 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2658 tdata->plaintext.len,
2663 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2664 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2667 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2670 ut_params->obuf = ut_params->op->sym->m_src;
2671 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2672 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2673 + plaintext_pad_len;
2676 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2679 DIGEST_BYTE_LENGTH_KASUMI_F9,
2680 "KASUMI Generated auth tag not as expected");
2686 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2688 struct crypto_testsuite_params *ts_params = &testsuite_params;
2689 struct crypto_unittest_params *ut_params = &unittest_params;
2692 unsigned plaintext_pad_len;
2693 unsigned plaintext_len;
2696 /* Verify the capabilities */
2697 struct rte_cryptodev_sym_capability_idx cap_idx;
2698 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2699 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2700 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2704 /* Create KASUMI session */
2705 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2706 tdata->key.data, tdata->key.len,
2707 0, tdata->digest.len,
2708 RTE_CRYPTO_AUTH_OP_VERIFY,
2709 RTE_CRYPTO_AUTH_KASUMI_F9);
2712 /* alloc mbuf and set payload */
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2716 rte_pktmbuf_tailroom(ut_params->ibuf));
2718 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2719 /* Append data which is padded to a multiple */
2720 /* of the algorithms block size */
2721 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2722 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2724 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2726 /* Create KASUMI operation */
2727 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2731 RTE_CRYPTO_AUTH_OP_VERIFY,
2732 tdata->plaintext.len,
2737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2740 ut_params->obuf = ut_params->op->sym->m_src;
2741 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2742 + plaintext_pad_len;
2745 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2754 test_snow3g_hash_generate_test_case_1(void)
2756 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2760 test_snow3g_hash_generate_test_case_2(void)
2762 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2766 test_snow3g_hash_generate_test_case_3(void)
2768 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2772 test_snow3g_hash_generate_test_case_4(void)
2774 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2778 test_snow3g_hash_generate_test_case_5(void)
2780 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2784 test_snow3g_hash_generate_test_case_6(void)
2786 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2790 test_snow3g_hash_verify_test_case_1(void)
2792 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2797 test_snow3g_hash_verify_test_case_2(void)
2799 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2803 test_snow3g_hash_verify_test_case_3(void)
2805 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2809 test_snow3g_hash_verify_test_case_4(void)
2811 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2815 test_snow3g_hash_verify_test_case_5(void)
2817 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2821 test_snow3g_hash_verify_test_case_6(void)
2823 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2827 test_kasumi_hash_generate_test_case_1(void)
2829 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2833 test_kasumi_hash_generate_test_case_2(void)
2835 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2839 test_kasumi_hash_generate_test_case_3(void)
2841 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2845 test_kasumi_hash_generate_test_case_4(void)
2847 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2851 test_kasumi_hash_generate_test_case_5(void)
2853 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2857 test_kasumi_hash_generate_test_case_6(void)
2859 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2863 test_kasumi_hash_verify_test_case_1(void)
2865 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2869 test_kasumi_hash_verify_test_case_2(void)
2871 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2875 test_kasumi_hash_verify_test_case_3(void)
2877 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2881 test_kasumi_hash_verify_test_case_4(void)
2883 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2887 test_kasumi_hash_verify_test_case_5(void)
2889 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2893 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2895 struct crypto_testsuite_params *ts_params = &testsuite_params;
2896 struct crypto_unittest_params *ut_params = &unittest_params;
2899 uint8_t *plaintext, *ciphertext;
2900 unsigned plaintext_pad_len;
2901 unsigned plaintext_len;
2903 /* Verify the capabilities */
2904 struct rte_cryptodev_sym_capability_idx cap_idx;
2905 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2906 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2907 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2911 /* Create KASUMI session */
2912 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2913 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2914 RTE_CRYPTO_CIPHER_KASUMI_F8,
2915 tdata->key.data, tdata->key.len,
2916 tdata->cipher_iv.len);
2920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2922 /* Clear mbuf payload */
2923 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2924 rte_pktmbuf_tailroom(ut_params->ibuf));
2926 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2927 /* Append data which is padded to a multiple */
2928 /* of the algorithms block size */
2929 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2930 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2932 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2934 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2936 /* Create KASUMI operation */
2937 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2938 tdata->cipher_iv.len,
2939 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2940 tdata->validCipherOffsetInBits.len);
2944 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2946 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2948 ut_params->obuf = ut_params->op->sym->m_dst;
2949 if (ut_params->obuf)
2950 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2952 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2954 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2956 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2957 (tdata->validCipherOffsetInBits.len >> 3);
2959 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2961 reference_ciphertext,
2962 tdata->validCipherLenInBits.len,
2963 "KASUMI Ciphertext data not as expected");
2968 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2970 struct crypto_testsuite_params *ts_params = &testsuite_params;
2971 struct crypto_unittest_params *ut_params = &unittest_params;
2975 unsigned int plaintext_pad_len;
2976 unsigned int plaintext_len;
2978 uint8_t buffer[10000];
2979 const uint8_t *ciphertext;
2981 struct rte_cryptodev_info dev_info;
2983 /* Verify the capabilities */
2984 struct rte_cryptodev_sym_capability_idx cap_idx;
2985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2986 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2987 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2991 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2993 uint64_t feat_flags = dev_info.feature_flags;
2995 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2996 printf("Device doesn't support in-place scatter-gather. "
3001 /* Create KASUMI session */
3002 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3003 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3004 RTE_CRYPTO_CIPHER_KASUMI_F8,
3005 tdata->key.data, tdata->key.len,
3006 tdata->cipher_iv.len);
3010 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3013 /* Append data which is padded to a multiple */
3014 /* of the algorithms block size */
3015 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3017 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3018 plaintext_pad_len, 10, 0);
3020 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3022 /* Create KASUMI operation */
3023 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3024 tdata->cipher_iv.len,
3025 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3026 tdata->validCipherOffsetInBits.len);
3030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3034 ut_params->obuf = ut_params->op->sym->m_dst;
3036 if (ut_params->obuf)
3037 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3038 plaintext_len, buffer);
3040 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3041 tdata->validCipherOffsetInBits.len >> 3,
3042 plaintext_len, buffer);
3045 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3047 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3048 (tdata->validCipherOffsetInBits.len >> 3);
3050 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3052 reference_ciphertext,
3053 tdata->validCipherLenInBits.len,
3054 "KASUMI Ciphertext data not as expected");
3059 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3061 struct crypto_testsuite_params *ts_params = &testsuite_params;
3062 struct crypto_unittest_params *ut_params = &unittest_params;
3065 uint8_t *plaintext, *ciphertext;
3066 unsigned plaintext_pad_len;
3067 unsigned plaintext_len;
3069 /* Verify the capabilities */
3070 struct rte_cryptodev_sym_capability_idx cap_idx;
3071 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3072 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3073 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3077 /* Create KASUMI session */
3078 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3080 RTE_CRYPTO_CIPHER_KASUMI_F8,
3081 tdata->key.data, tdata->key.len,
3082 tdata->cipher_iv.len);
3086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3087 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3089 /* Clear mbuf payload */
3090 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3091 rte_pktmbuf_tailroom(ut_params->ibuf));
3093 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3094 /* Append data which is padded to a multiple */
3095 /* of the algorithms block size */
3096 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3097 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3099 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3100 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3102 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3104 /* Create KASUMI operation */
3105 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3106 tdata->cipher_iv.len,
3107 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3108 tdata->validCipherOffsetInBits.len);
3112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3114 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3116 ut_params->obuf = ut_params->op->sym->m_dst;
3117 if (ut_params->obuf)
3118 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3120 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3122 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3124 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3125 (tdata->validCipherOffsetInBits.len >> 3);
3127 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3129 reference_ciphertext,
3130 tdata->validCipherLenInBits.len,
3131 "KASUMI Ciphertext data not as expected");
3136 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3138 struct crypto_testsuite_params *ts_params = &testsuite_params;
3139 struct crypto_unittest_params *ut_params = &unittest_params;
3142 unsigned int plaintext_pad_len;
3143 unsigned int plaintext_len;
3145 const uint8_t *ciphertext;
3146 uint8_t buffer[2048];
3148 struct rte_cryptodev_info dev_info;
3150 /* Verify the capabilities */
3151 struct rte_cryptodev_sym_capability_idx cap_idx;
3152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3153 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3158 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3160 uint64_t feat_flags = dev_info.feature_flags;
3161 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3162 printf("Device doesn't support out-of-place scatter-gather "
3163 "in both input and output mbufs. "
3168 /* Create KASUMI session */
3169 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3170 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3171 RTE_CRYPTO_CIPHER_KASUMI_F8,
3172 tdata->key.data, tdata->key.len,
3173 tdata->cipher_iv.len);
3177 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3178 /* Append data which is padded to a multiple */
3179 /* of the algorithms block size */
3180 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3182 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3183 plaintext_pad_len, 10, 0);
3184 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3185 plaintext_pad_len, 3, 0);
3187 /* Append data which is padded to a multiple */
3188 /* of the algorithms block size */
3189 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3191 /* Create KASUMI operation */
3192 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3193 tdata->cipher_iv.len,
3194 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3195 tdata->validCipherOffsetInBits.len);
3199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3201 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3203 ut_params->obuf = ut_params->op->sym->m_dst;
3204 if (ut_params->obuf)
3205 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3206 plaintext_pad_len, buffer);
3208 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3209 tdata->validCipherOffsetInBits.len >> 3,
3210 plaintext_pad_len, buffer);
3212 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3213 (tdata->validCipherOffsetInBits.len >> 3);
3215 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3217 reference_ciphertext,
3218 tdata->validCipherLenInBits.len,
3219 "KASUMI Ciphertext data not as expected");
3225 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3227 struct crypto_testsuite_params *ts_params = &testsuite_params;
3228 struct crypto_unittest_params *ut_params = &unittest_params;
3231 uint8_t *ciphertext, *plaintext;
3232 unsigned ciphertext_pad_len;
3233 unsigned ciphertext_len;
3235 /* Verify the capabilities */
3236 struct rte_cryptodev_sym_capability_idx cap_idx;
3237 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3238 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3243 /* Create KASUMI session */
3244 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3245 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3246 RTE_CRYPTO_CIPHER_KASUMI_F8,
3247 tdata->key.data, tdata->key.len,
3248 tdata->cipher_iv.len);
3252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3253 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3255 /* Clear mbuf payload */
3256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3257 rte_pktmbuf_tailroom(ut_params->ibuf));
3259 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3260 /* Append data which is padded to a multiple */
3261 /* of the algorithms block size */
3262 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3263 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3264 ciphertext_pad_len);
3265 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3266 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3268 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3270 /* Create KASUMI operation */
3271 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3272 tdata->cipher_iv.len,
3273 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3274 tdata->validCipherOffsetInBits.len);
3278 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3280 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3282 ut_params->obuf = ut_params->op->sym->m_dst;
3283 if (ut_params->obuf)
3284 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3286 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3288 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3290 const uint8_t *reference_plaintext = tdata->plaintext.data +
3291 (tdata->validCipherOffsetInBits.len >> 3);
3293 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3295 reference_plaintext,
3296 tdata->validCipherLenInBits.len,
3297 "KASUMI Plaintext data not as expected");
3302 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3304 struct crypto_testsuite_params *ts_params = &testsuite_params;
3305 struct crypto_unittest_params *ut_params = &unittest_params;
3308 uint8_t *ciphertext, *plaintext;
3309 unsigned ciphertext_pad_len;
3310 unsigned ciphertext_len;
3312 /* Verify the capabilities */
3313 struct rte_cryptodev_sym_capability_idx cap_idx;
3314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3315 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3316 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3320 /* Create KASUMI session */
3321 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3322 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3323 RTE_CRYPTO_CIPHER_KASUMI_F8,
3324 tdata->key.data, tdata->key.len,
3325 tdata->cipher_iv.len);
3329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3331 /* Clear mbuf payload */
3332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3333 rte_pktmbuf_tailroom(ut_params->ibuf));
3335 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3336 /* Append data which is padded to a multiple */
3337 /* of the algorithms block size */
3338 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3339 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3340 ciphertext_pad_len);
3341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3343 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3345 /* Create KASUMI operation */
3346 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3347 tdata->cipher_iv.len,
3348 tdata->ciphertext.len,
3349 tdata->validCipherOffsetInBits.len);
3353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3357 ut_params->obuf = ut_params->op->sym->m_dst;
3358 if (ut_params->obuf)
3359 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3361 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3363 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3365 const uint8_t *reference_plaintext = tdata->plaintext.data +
3366 (tdata->validCipherOffsetInBits.len >> 3);
3368 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3370 reference_plaintext,
3371 tdata->validCipherLenInBits.len,
3372 "KASUMI Plaintext data not as expected");
3377 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3379 struct crypto_testsuite_params *ts_params = &testsuite_params;
3380 struct crypto_unittest_params *ut_params = &unittest_params;
3383 uint8_t *plaintext, *ciphertext;
3384 unsigned plaintext_pad_len;
3385 unsigned plaintext_len;
3387 /* Verify the capabilities */
3388 struct rte_cryptodev_sym_capability_idx cap_idx;
3389 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3390 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3391 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3395 /* Create SNOW 3G session */
3396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3397 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3399 tdata->key.data, tdata->key.len,
3400 tdata->cipher_iv.len);
3404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3406 /* Clear mbuf payload */
3407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3408 rte_pktmbuf_tailroom(ut_params->ibuf));
3410 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3411 /* Append data which is padded to a multiple of */
3412 /* the algorithms block size */
3413 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3414 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3416 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3418 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3420 /* Create SNOW 3G operation */
3421 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3422 tdata->cipher_iv.len,
3423 tdata->validCipherLenInBits.len,
3428 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3430 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3432 ut_params->obuf = ut_params->op->sym->m_dst;
3433 if (ut_params->obuf)
3434 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3436 ciphertext = plaintext;
3438 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3441 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3443 tdata->ciphertext.data,
3444 tdata->validDataLenInBits.len,
3445 "SNOW 3G Ciphertext data not as expected");
3451 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3453 struct crypto_testsuite_params *ts_params = &testsuite_params;
3454 struct crypto_unittest_params *ut_params = &unittest_params;
3455 uint8_t *plaintext, *ciphertext;
3458 unsigned plaintext_pad_len;
3459 unsigned plaintext_len;
3461 /* Verify the capabilities */
3462 struct rte_cryptodev_sym_capability_idx cap_idx;
3463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3464 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3469 /* Create SNOW 3G session */
3470 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3472 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3473 tdata->key.data, tdata->key.len,
3474 tdata->cipher_iv.len);
3478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3481 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3482 "Failed to allocate input buffer in mempool");
3483 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3484 "Failed to allocate output buffer in mempool");
3486 /* Clear mbuf payload */
3487 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3488 rte_pktmbuf_tailroom(ut_params->ibuf));
3490 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3491 /* Append data which is padded to a multiple of */
3492 /* the algorithms block size */
3493 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3494 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3496 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3497 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3499 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3501 /* Create SNOW 3G operation */
3502 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3503 tdata->cipher_iv.len,
3504 tdata->validCipherLenInBits.len,
3509 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3511 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3513 ut_params->obuf = ut_params->op->sym->m_dst;
3514 if (ut_params->obuf)
3515 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3517 ciphertext = plaintext;
3519 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3524 tdata->ciphertext.data,
3525 tdata->validDataLenInBits.len,
3526 "SNOW 3G Ciphertext data not as expected");
3531 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3533 struct crypto_testsuite_params *ts_params = &testsuite_params;
3534 struct crypto_unittest_params *ut_params = &unittest_params;
3537 unsigned int plaintext_pad_len;
3538 unsigned int plaintext_len;
3539 uint8_t buffer[10000];
3540 const uint8_t *ciphertext;
3542 struct rte_cryptodev_info dev_info;
3544 /* Verify the capabilities */
3545 struct rte_cryptodev_sym_capability_idx cap_idx;
3546 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3547 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3548 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3554 uint64_t feat_flags = dev_info.feature_flags;
3556 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3557 printf("Device doesn't support out-of-place scatter-gather "
3558 "in both input and output mbufs. "
3563 /* Create SNOW 3G session */
3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3567 tdata->key.data, tdata->key.len,
3568 tdata->cipher_iv.len);
3572 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 /* Append data which is padded to a multiple of */
3574 /* the algorithms block size */
3575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3577 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3578 plaintext_pad_len, 10, 0);
3579 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3580 plaintext_pad_len, 3, 0);
3582 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3583 "Failed to allocate input buffer in mempool");
3584 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3585 "Failed to allocate output buffer in mempool");
3587 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3589 /* Create SNOW 3G operation */
3590 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3591 tdata->cipher_iv.len,
3592 tdata->validCipherLenInBits.len,
3597 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3601 ut_params->obuf = ut_params->op->sym->m_dst;
3602 if (ut_params->obuf)
3603 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3604 plaintext_len, buffer);
3606 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3607 plaintext_len, buffer);
3609 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3614 tdata->ciphertext.data,
3615 tdata->validDataLenInBits.len,
3616 "SNOW 3G Ciphertext data not as expected");
3621 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3623 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3625 uint8_t curr_byte, prev_byte;
3626 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3627 uint8_t lower_byte_mask = (1 << offset) - 1;
3630 prev_byte = buffer[0];
3631 buffer[0] >>= offset;
3633 for (i = 1; i < length_in_bytes; i++) {
3634 curr_byte = buffer[i];
3635 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3636 (curr_byte >> offset);
3637 prev_byte = curr_byte;
3642 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3644 struct crypto_testsuite_params *ts_params = &testsuite_params;
3645 struct crypto_unittest_params *ut_params = &unittest_params;
3646 uint8_t *plaintext, *ciphertext;
3648 uint32_t plaintext_len;
3649 uint32_t plaintext_pad_len;
3650 uint8_t extra_offset = 4;
3651 uint8_t *expected_ciphertext_shifted;
3652 struct rte_cryptodev_info dev_info;
3654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3655 uint64_t feat_flags = dev_info.feature_flags;
3657 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3658 ((tdata->validDataLenInBits.len % 8) != 0)) {
3659 printf("Device doesn't support NON-Byte Aligned Data.\n");
3663 /* Verify the capabilities */
3664 struct rte_cryptodev_sym_capability_idx cap_idx;
3665 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3666 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3667 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3671 /* Create SNOW 3G session */
3672 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3673 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3674 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3675 tdata->key.data, tdata->key.len,
3676 tdata->cipher_iv.len);
3680 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3681 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3683 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3684 "Failed to allocate input buffer in mempool");
3685 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3686 "Failed to allocate output buffer in mempool");
3688 /* Clear mbuf payload */
3689 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3690 rte_pktmbuf_tailroom(ut_params->ibuf));
3692 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3694 * Append data which is padded to a
3695 * multiple of the algorithms block size
3697 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3699 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3702 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3704 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3705 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3707 #ifdef RTE_APP_TEST_DEBUG
3708 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3710 /* Create SNOW 3G operation */
3711 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3712 tdata->cipher_iv.len,
3713 tdata->validCipherLenInBits.len,
3718 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3720 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3722 ut_params->obuf = ut_params->op->sym->m_dst;
3723 if (ut_params->obuf)
3724 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3726 ciphertext = plaintext;
3728 #ifdef RTE_APP_TEST_DEBUG
3729 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3732 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3734 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3735 "failed to reserve memory for ciphertext shifted\n");
3737 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3738 ceil_byte_length(tdata->ciphertext.len));
3739 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3742 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3744 expected_ciphertext_shifted,
3745 tdata->validDataLenInBits.len,
3747 "SNOW 3G Ciphertext data not as expected");
3751 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3753 struct crypto_testsuite_params *ts_params = &testsuite_params;
3754 struct crypto_unittest_params *ut_params = &unittest_params;
3758 uint8_t *plaintext, *ciphertext;
3759 unsigned ciphertext_pad_len;
3760 unsigned ciphertext_len;
3762 /* Verify the capabilities */
3763 struct rte_cryptodev_sym_capability_idx cap_idx;
3764 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3765 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3766 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3770 /* Create SNOW 3G session */
3771 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3772 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3773 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3774 tdata->key.data, tdata->key.len,
3775 tdata->cipher_iv.len);
3779 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3781 /* Clear mbuf payload */
3782 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3783 rte_pktmbuf_tailroom(ut_params->ibuf));
3785 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3786 /* Append data which is padded to a multiple of */
3787 /* the algorithms block size */
3788 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3789 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3790 ciphertext_pad_len);
3791 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3793 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3795 /* Create SNOW 3G operation */
3796 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3797 tdata->cipher_iv.len,
3798 tdata->validCipherLenInBits.len,
3799 tdata->cipher.offset_bits);
3803 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3805 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3806 ut_params->obuf = ut_params->op->sym->m_dst;
3807 if (ut_params->obuf)
3808 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3810 plaintext = ciphertext;
3812 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3815 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3816 tdata->plaintext.data,
3817 tdata->validDataLenInBits.len,
3818 "SNOW 3G Plaintext data not as expected");
3822 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3824 struct crypto_testsuite_params *ts_params = &testsuite_params;
3825 struct crypto_unittest_params *ut_params = &unittest_params;
3829 uint8_t *plaintext, *ciphertext;
3830 unsigned ciphertext_pad_len;
3831 unsigned ciphertext_len;
3833 /* Verify the capabilities */
3834 struct rte_cryptodev_sym_capability_idx cap_idx;
3835 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3836 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3837 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3841 /* Create SNOW 3G session */
3842 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3843 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3844 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3845 tdata->key.data, tdata->key.len,
3846 tdata->cipher_iv.len);
3850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3853 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3854 "Failed to allocate input buffer");
3855 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3856 "Failed to allocate output buffer");
3858 /* Clear mbuf payload */
3859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3860 rte_pktmbuf_tailroom(ut_params->ibuf));
3862 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3863 rte_pktmbuf_tailroom(ut_params->obuf));
3865 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3866 /* Append data which is padded to a multiple of */
3867 /* the algorithms block size */
3868 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3869 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3870 ciphertext_pad_len);
3871 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3872 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3874 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3876 /* Create SNOW 3G operation */
3877 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3878 tdata->cipher_iv.len,
3879 tdata->validCipherLenInBits.len,
3884 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3886 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3887 ut_params->obuf = ut_params->op->sym->m_dst;
3888 if (ut_params->obuf)
3889 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3891 plaintext = ciphertext;
3893 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3897 tdata->plaintext.data,
3898 tdata->validDataLenInBits.len,
3899 "SNOW 3G Plaintext data not as expected");
3904 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3906 struct crypto_testsuite_params *ts_params = &testsuite_params;
3907 struct crypto_unittest_params *ut_params = &unittest_params;
3911 uint8_t *plaintext, *ciphertext;
3912 unsigned int plaintext_pad_len;
3913 unsigned int plaintext_len;
3915 struct rte_cryptodev_info dev_info;
3916 struct rte_cryptodev_sym_capability_idx cap_idx;
3918 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3919 uint64_t feat_flags = dev_info.feature_flags;
3921 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3922 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3923 (tdata->validDataLenInBits.len % 8 != 0))) {
3924 printf("Device doesn't support NON-Byte Aligned Data.\n");
3928 /* Check if device supports ZUC EEA3 */
3929 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3930 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3932 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3936 /* Check if device supports ZUC EIA3 */
3937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3938 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3944 /* Create ZUC session */
3945 retval = create_zuc_cipher_auth_encrypt_generate_session(
3946 ts_params->valid_devs[0],
3950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3952 /* clear mbuf payload */
3953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 rte_pktmbuf_tailroom(ut_params->ibuf));
3956 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3957 /* Append data which is padded to a multiple of */
3958 /* the algorithms block size */
3959 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3960 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3964 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3966 /* Create ZUC operation */
3967 retval = create_zuc_cipher_hash_generate_operation(tdata);
3971 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3973 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3974 ut_params->obuf = ut_params->op->sym->m_src;
3975 if (ut_params->obuf)
3976 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3978 ciphertext = plaintext;
3980 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3982 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3984 tdata->ciphertext.data,
3985 tdata->validDataLenInBits.len,
3986 "ZUC Ciphertext data not as expected");
3988 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3989 + plaintext_pad_len;
3992 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3996 "ZUC Generated auth tag not as expected");
4001 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4003 struct crypto_testsuite_params *ts_params = &testsuite_params;
4004 struct crypto_unittest_params *ut_params = &unittest_params;
4008 uint8_t *plaintext, *ciphertext;
4009 unsigned plaintext_pad_len;
4010 unsigned plaintext_len;
4012 /* Verify the capabilities */
4013 struct rte_cryptodev_sym_capability_idx cap_idx;
4014 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4015 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4016 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4020 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4025 /* Create SNOW 3G session */
4026 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4027 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4028 RTE_CRYPTO_AUTH_OP_GENERATE,
4029 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4030 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4031 tdata->key.data, tdata->key.len,
4032 tdata->auth_iv.len, tdata->digest.len,
4033 tdata->cipher_iv.len);
4036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4038 /* clear mbuf payload */
4039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4040 rte_pktmbuf_tailroom(ut_params->ibuf));
4042 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4043 /* Append data which is padded to a multiple of */
4044 /* the algorithms block size */
4045 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4046 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4048 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4050 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4052 /* Create SNOW 3G operation */
4053 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4054 tdata->digest.len, tdata->auth_iv.data,
4056 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4057 tdata->cipher_iv.data, tdata->cipher_iv.len,
4058 tdata->validCipherLenInBits.len,
4060 tdata->validAuthLenInBits.len,
4066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4069 ut_params->obuf = ut_params->op->sym->m_src;
4070 if (ut_params->obuf)
4071 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4073 ciphertext = plaintext;
4075 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4077 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4079 tdata->ciphertext.data,
4080 tdata->validDataLenInBits.len,
4081 "SNOW 3G Ciphertext data not as expected");
4083 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4084 + plaintext_pad_len;
4087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4090 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4091 "SNOW 3G Generated auth tag not as expected");
4096 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4097 uint8_t op_mode, uint8_t verify)
4099 struct crypto_testsuite_params *ts_params = &testsuite_params;
4100 struct crypto_unittest_params *ut_params = &unittest_params;
4104 uint8_t *plaintext = NULL, *ciphertext = NULL;
4105 unsigned int plaintext_pad_len;
4106 unsigned int plaintext_len;
4107 unsigned int ciphertext_pad_len;
4108 unsigned int ciphertext_len;
4110 struct rte_cryptodev_info dev_info;
4112 /* Verify the capabilities */
4113 struct rte_cryptodev_sym_capability_idx cap_idx;
4114 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4115 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4116 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4120 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4125 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4127 uint64_t feat_flags = dev_info.feature_flags;
4129 if (op_mode == OUT_OF_PLACE) {
4130 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4131 printf("Device doesn't support digest encrypted.\n");
4136 /* Create SNOW 3G session */
4137 retval = create_wireless_algo_auth_cipher_session(
4138 ts_params->valid_devs[0],
4139 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4140 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4141 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4142 : RTE_CRYPTO_AUTH_OP_GENERATE),
4143 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4144 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4145 tdata->key.data, tdata->key.len,
4146 tdata->auth_iv.len, tdata->digest.len,
4147 tdata->cipher_iv.len);
4152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4153 if (op_mode == OUT_OF_PLACE)
4154 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4156 /* clear mbuf payload */
4157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4158 rte_pktmbuf_tailroom(ut_params->ibuf));
4159 if (op_mode == OUT_OF_PLACE)
4160 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4161 rte_pktmbuf_tailroom(ut_params->obuf));
4163 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4164 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4165 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4166 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4169 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4170 ciphertext_pad_len);
4171 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4172 if (op_mode == OUT_OF_PLACE)
4173 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4174 debug_hexdump(stdout, "ciphertext:", ciphertext,
4177 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4179 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4180 if (op_mode == OUT_OF_PLACE)
4181 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4182 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4185 /* Create SNOW 3G operation */
4186 retval = create_wireless_algo_auth_cipher_operation(
4187 tdata->digest.data, tdata->digest.len,
4188 tdata->cipher_iv.data, tdata->cipher_iv.len,
4189 tdata->auth_iv.data, tdata->auth_iv.len,
4190 (tdata->digest.offset_bytes == 0 ?
4191 (verify ? ciphertext_pad_len : plaintext_pad_len)
4192 : tdata->digest.offset_bytes),
4193 tdata->validCipherLenInBits.len,
4194 tdata->cipher.offset_bits,
4195 tdata->validAuthLenInBits.len,
4196 tdata->auth.offset_bits,
4197 op_mode, 0, verify);
4202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4207 ut_params->obuf = (op_mode == IN_PLACE ?
4208 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4211 if (ut_params->obuf)
4212 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4215 plaintext = ciphertext +
4216 (tdata->cipher.offset_bits >> 3);
4218 debug_hexdump(stdout, "plaintext:", plaintext,
4219 (tdata->plaintext.len >> 3) - tdata->digest.len);
4220 debug_hexdump(stdout, "plaintext expected:",
4221 tdata->plaintext.data,
4222 (tdata->plaintext.len >> 3) - tdata->digest.len);
4224 if (ut_params->obuf)
4225 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4228 ciphertext = plaintext;
4230 debug_hexdump(stdout, "ciphertext:", ciphertext,
4232 debug_hexdump(stdout, "ciphertext expected:",
4233 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4235 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4236 + (tdata->digest.offset_bytes == 0 ?
4237 plaintext_pad_len : tdata->digest.offset_bytes);
4239 debug_hexdump(stdout, "digest:", ut_params->digest,
4241 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4247 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4249 tdata->plaintext.data,
4250 tdata->plaintext.len >> 3,
4251 "SNOW 3G Plaintext data not as expected");
4253 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4255 tdata->ciphertext.data,
4256 tdata->validDataLenInBits.len,
4257 "SNOW 3G Ciphertext data not as expected");
4259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4262 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4263 "SNOW 3G Generated auth tag not as expected");
4269 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4270 uint8_t op_mode, uint8_t verify)
4272 struct crypto_testsuite_params *ts_params = &testsuite_params;
4273 struct crypto_unittest_params *ut_params = &unittest_params;
4277 const uint8_t *plaintext = NULL;
4278 const uint8_t *ciphertext = NULL;
4279 const uint8_t *digest = NULL;
4280 unsigned int plaintext_pad_len;
4281 unsigned int plaintext_len;
4282 unsigned int ciphertext_pad_len;
4283 unsigned int ciphertext_len;
4284 uint8_t buffer[10000];
4285 uint8_t digest_buffer[10000];
4287 struct rte_cryptodev_info dev_info;
4289 /* Verify the capabilities */
4290 struct rte_cryptodev_sym_capability_idx cap_idx;
4291 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4292 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4293 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4297 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4302 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4304 uint64_t feat_flags = dev_info.feature_flags;
4306 if (op_mode == IN_PLACE) {
4307 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4308 printf("Device doesn't support in-place scatter-gather "
4309 "in both input and output mbufs.\n");
4313 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4314 printf("Device doesn't support out-of-place scatter-gather "
4315 "in both input and output mbufs.\n");
4318 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4319 printf("Device doesn't support digest encrypted.\n");
4324 /* Create SNOW 3G session */
4325 retval = create_wireless_algo_auth_cipher_session(
4326 ts_params->valid_devs[0],
4327 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4328 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4329 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4330 : RTE_CRYPTO_AUTH_OP_GENERATE),
4331 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4332 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4333 tdata->key.data, tdata->key.len,
4334 tdata->auth_iv.len, tdata->digest.len,
4335 tdata->cipher_iv.len);
4340 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4341 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4342 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4343 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4345 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4346 plaintext_pad_len, 15, 0);
4347 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4348 "Failed to allocate input buffer in mempool");
4350 if (op_mode == OUT_OF_PLACE) {
4351 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4352 plaintext_pad_len, 15, 0);
4353 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4354 "Failed to allocate output buffer in mempool");
4358 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4359 tdata->ciphertext.data);
4360 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4361 ciphertext_len, buffer);
4362 debug_hexdump(stdout, "ciphertext:", ciphertext,
4365 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4366 tdata->plaintext.data);
4367 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4368 plaintext_len, buffer);
4369 debug_hexdump(stdout, "plaintext:", plaintext,
4372 memset(buffer, 0, sizeof(buffer));
4374 /* Create SNOW 3G operation */
4375 retval = create_wireless_algo_auth_cipher_operation(
4376 tdata->digest.data, tdata->digest.len,
4377 tdata->cipher_iv.data, tdata->cipher_iv.len,
4378 tdata->auth_iv.data, tdata->auth_iv.len,
4379 (tdata->digest.offset_bytes == 0 ?
4380 (verify ? ciphertext_pad_len : plaintext_pad_len)
4381 : tdata->digest.offset_bytes),
4382 tdata->validCipherLenInBits.len,
4383 tdata->cipher.offset_bits,
4384 tdata->validAuthLenInBits.len,
4385 tdata->auth.offset_bits,
4386 op_mode, 1, verify);
4391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4394 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4396 ut_params->obuf = (op_mode == IN_PLACE ?
4397 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4400 if (ut_params->obuf)
4401 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4402 plaintext_len, buffer);
4404 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4405 plaintext_len, buffer);
4407 debug_hexdump(stdout, "plaintext:", plaintext,
4408 (tdata->plaintext.len >> 3) - tdata->digest.len);
4409 debug_hexdump(stdout, "plaintext expected:",
4410 tdata->plaintext.data,
4411 (tdata->plaintext.len >> 3) - tdata->digest.len);
4413 if (ut_params->obuf)
4414 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4415 ciphertext_len, buffer);
4417 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4418 ciphertext_len, buffer);
4420 debug_hexdump(stdout, "ciphertext:", ciphertext,
4422 debug_hexdump(stdout, "ciphertext expected:",
4423 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4425 if (ut_params->obuf)
4426 digest = rte_pktmbuf_read(ut_params->obuf,
4427 (tdata->digest.offset_bytes == 0 ?
4428 plaintext_pad_len : tdata->digest.offset_bytes),
4429 tdata->digest.len, digest_buffer);
4431 digest = rte_pktmbuf_read(ut_params->ibuf,
4432 (tdata->digest.offset_bytes == 0 ?
4433 plaintext_pad_len : tdata->digest.offset_bytes),
4434 tdata->digest.len, digest_buffer);
4436 debug_hexdump(stdout, "digest:", digest,
4438 debug_hexdump(stdout, "digest expected:",
4439 tdata->digest.data, tdata->digest.len);
4444 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4446 tdata->plaintext.data,
4447 tdata->plaintext.len >> 3,
4448 "SNOW 3G Plaintext data not as expected");
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4452 tdata->ciphertext.data,
4453 tdata->validDataLenInBits.len,
4454 "SNOW 3G Ciphertext data not as expected");
4456 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4459 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4460 "SNOW 3G Generated auth tag not as expected");
4466 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4467 uint8_t op_mode, uint8_t verify)
4469 struct crypto_testsuite_params *ts_params = &testsuite_params;
4470 struct crypto_unittest_params *ut_params = &unittest_params;
4474 uint8_t *plaintext = NULL, *ciphertext = NULL;
4475 unsigned int plaintext_pad_len;
4476 unsigned int plaintext_len;
4477 unsigned int ciphertext_pad_len;
4478 unsigned int ciphertext_len;
4480 struct rte_cryptodev_info dev_info;
4482 /* Verify the capabilities */
4483 struct rte_cryptodev_sym_capability_idx cap_idx;
4484 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4485 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4486 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4489 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4490 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4491 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4495 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4497 uint64_t feat_flags = dev_info.feature_flags;
4499 if (op_mode == OUT_OF_PLACE) {
4500 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4501 printf("Device doesn't support digest encrypted.\n");
4506 /* Create KASUMI session */
4507 retval = create_wireless_algo_auth_cipher_session(
4508 ts_params->valid_devs[0],
4509 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4510 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4511 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4512 : RTE_CRYPTO_AUTH_OP_GENERATE),
4513 RTE_CRYPTO_AUTH_KASUMI_F9,
4514 RTE_CRYPTO_CIPHER_KASUMI_F8,
4515 tdata->key.data, tdata->key.len,
4516 0, tdata->digest.len,
4517 tdata->cipher_iv.len);
4522 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4523 if (op_mode == OUT_OF_PLACE)
4524 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4526 /* clear mbuf payload */
4527 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4528 rte_pktmbuf_tailroom(ut_params->ibuf));
4529 if (op_mode == OUT_OF_PLACE)
4530 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4531 rte_pktmbuf_tailroom(ut_params->obuf));
4533 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4534 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4535 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4539 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4540 ciphertext_pad_len);
4541 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4542 if (op_mode == OUT_OF_PLACE)
4543 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4544 debug_hexdump(stdout, "ciphertext:", ciphertext,
4547 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4549 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4550 if (op_mode == OUT_OF_PLACE)
4551 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4552 debug_hexdump(stdout, "plaintext:", plaintext,
4556 /* Create KASUMI operation */
4557 retval = create_wireless_algo_auth_cipher_operation(
4558 tdata->digest.data, tdata->digest.len,
4559 tdata->cipher_iv.data, tdata->cipher_iv.len,
4561 (tdata->digest.offset_bytes == 0 ?
4562 (verify ? ciphertext_pad_len : plaintext_pad_len)
4563 : tdata->digest.offset_bytes),
4564 tdata->validCipherLenInBits.len,
4565 tdata->validCipherOffsetInBits.len,
4566 tdata->validAuthLenInBits.len,
4568 op_mode, 0, verify);
4573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4578 ut_params->obuf = (op_mode == IN_PLACE ?
4579 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4583 if (ut_params->obuf)
4584 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4587 plaintext = ciphertext;
4589 debug_hexdump(stdout, "plaintext:", plaintext,
4590 (tdata->plaintext.len >> 3) - tdata->digest.len);
4591 debug_hexdump(stdout, "plaintext expected:",
4592 tdata->plaintext.data,
4593 (tdata->plaintext.len >> 3) - tdata->digest.len);
4595 if (ut_params->obuf)
4596 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4599 ciphertext = plaintext;
4601 debug_hexdump(stdout, "ciphertext:", ciphertext,
4603 debug_hexdump(stdout, "ciphertext expected:",
4604 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4606 ut_params->digest = rte_pktmbuf_mtod(
4607 ut_params->obuf, uint8_t *) +
4608 (tdata->digest.offset_bytes == 0 ?
4609 plaintext_pad_len : tdata->digest.offset_bytes);
4611 debug_hexdump(stdout, "digest:", ut_params->digest,
4613 debug_hexdump(stdout, "digest expected:",
4614 tdata->digest.data, tdata->digest.len);
4619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4621 tdata->plaintext.data,
4622 tdata->plaintext.len >> 3,
4623 "KASUMI Plaintext data not as expected");
4625 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4627 tdata->ciphertext.data,
4628 tdata->ciphertext.len >> 3,
4629 "KASUMI Ciphertext data not as expected");
4631 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4634 DIGEST_BYTE_LENGTH_KASUMI_F9,
4635 "KASUMI Generated auth tag not as expected");
4641 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4642 uint8_t op_mode, uint8_t verify)
4644 struct crypto_testsuite_params *ts_params = &testsuite_params;
4645 struct crypto_unittest_params *ut_params = &unittest_params;
4649 const uint8_t *plaintext = NULL;
4650 const uint8_t *ciphertext = NULL;
4651 const uint8_t *digest = NULL;
4652 unsigned int plaintext_pad_len;
4653 unsigned int plaintext_len;
4654 unsigned int ciphertext_pad_len;
4655 unsigned int ciphertext_len;
4656 uint8_t buffer[10000];
4657 uint8_t digest_buffer[10000];
4659 struct rte_cryptodev_info dev_info;
4661 /* Verify the capabilities */
4662 struct rte_cryptodev_sym_capability_idx cap_idx;
4663 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4664 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4665 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4669 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4670 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4674 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4676 uint64_t feat_flags = dev_info.feature_flags;
4678 if (op_mode == IN_PLACE) {
4679 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4680 printf("Device doesn't support in-place scatter-gather "
4681 "in both input and output mbufs.\n");
4685 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4686 printf("Device doesn't support out-of-place scatter-gather "
4687 "in both input and output mbufs.\n");
4690 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4691 printf("Device doesn't support digest encrypted.\n");
4696 /* Create KASUMI session */
4697 retval = create_wireless_algo_auth_cipher_session(
4698 ts_params->valid_devs[0],
4699 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4700 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4701 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4702 : RTE_CRYPTO_AUTH_OP_GENERATE),
4703 RTE_CRYPTO_AUTH_KASUMI_F9,
4704 RTE_CRYPTO_CIPHER_KASUMI_F8,
4705 tdata->key.data, tdata->key.len,
4706 0, tdata->digest.len,
4707 tdata->cipher_iv.len);
4712 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4714 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4715 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4717 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4718 plaintext_pad_len, 15, 0);
4719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4720 "Failed to allocate input buffer in mempool");
4722 if (op_mode == OUT_OF_PLACE) {
4723 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4724 plaintext_pad_len, 15, 0);
4725 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4726 "Failed to allocate output buffer in mempool");
4730 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4731 tdata->ciphertext.data);
4732 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4733 ciphertext_len, buffer);
4734 debug_hexdump(stdout, "ciphertext:", ciphertext,
4737 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4738 tdata->plaintext.data);
4739 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4740 plaintext_len, buffer);
4741 debug_hexdump(stdout, "plaintext:", plaintext,
4744 memset(buffer, 0, sizeof(buffer));
4746 /* Create KASUMI operation */
4747 retval = create_wireless_algo_auth_cipher_operation(
4748 tdata->digest.data, tdata->digest.len,
4749 tdata->cipher_iv.data, tdata->cipher_iv.len,
4751 (tdata->digest.offset_bytes == 0 ?
4752 (verify ? ciphertext_pad_len : plaintext_pad_len)
4753 : tdata->digest.offset_bytes),
4754 tdata->validCipherLenInBits.len,
4755 tdata->validCipherOffsetInBits.len,
4756 tdata->validAuthLenInBits.len,
4758 op_mode, 1, verify);
4763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4766 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4768 ut_params->obuf = (op_mode == IN_PLACE ?
4769 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4772 if (ut_params->obuf)
4773 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4774 plaintext_len, buffer);
4776 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4777 plaintext_len, buffer);
4779 debug_hexdump(stdout, "plaintext:", plaintext,
4780 (tdata->plaintext.len >> 3) - tdata->digest.len);
4781 debug_hexdump(stdout, "plaintext expected:",
4782 tdata->plaintext.data,
4783 (tdata->plaintext.len >> 3) - tdata->digest.len);
4785 if (ut_params->obuf)
4786 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4787 ciphertext_len, buffer);
4789 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4790 ciphertext_len, buffer);
4792 debug_hexdump(stdout, "ciphertext:", ciphertext,
4794 debug_hexdump(stdout, "ciphertext expected:",
4795 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4797 if (ut_params->obuf)
4798 digest = rte_pktmbuf_read(ut_params->obuf,
4799 (tdata->digest.offset_bytes == 0 ?
4800 plaintext_pad_len : tdata->digest.offset_bytes),
4801 tdata->digest.len, digest_buffer);
4803 digest = rte_pktmbuf_read(ut_params->ibuf,
4804 (tdata->digest.offset_bytes == 0 ?
4805 plaintext_pad_len : tdata->digest.offset_bytes),
4806 tdata->digest.len, digest_buffer);
4808 debug_hexdump(stdout, "digest:", digest,
4810 debug_hexdump(stdout, "digest expected:",
4811 tdata->digest.data, tdata->digest.len);
4816 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4818 tdata->plaintext.data,
4819 tdata->plaintext.len >> 3,
4820 "KASUMI Plaintext data not as expected");
4822 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4824 tdata->ciphertext.data,
4825 tdata->validDataLenInBits.len,
4826 "KASUMI Ciphertext data not as expected");
4828 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4831 DIGEST_BYTE_LENGTH_KASUMI_F9,
4832 "KASUMI Generated auth tag not as expected");
4838 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4840 struct crypto_testsuite_params *ts_params = &testsuite_params;
4841 struct crypto_unittest_params *ut_params = &unittest_params;
4845 uint8_t *plaintext, *ciphertext;
4846 unsigned plaintext_pad_len;
4847 unsigned plaintext_len;
4849 /* Verify the capabilities */
4850 struct rte_cryptodev_sym_capability_idx cap_idx;
4851 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4852 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4853 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4857 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4862 /* Create KASUMI session */
4863 retval = create_wireless_algo_cipher_auth_session(
4864 ts_params->valid_devs[0],
4865 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4866 RTE_CRYPTO_AUTH_OP_GENERATE,
4867 RTE_CRYPTO_AUTH_KASUMI_F9,
4868 RTE_CRYPTO_CIPHER_KASUMI_F8,
4869 tdata->key.data, tdata->key.len,
4870 0, tdata->digest.len,
4871 tdata->cipher_iv.len);
4875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4877 /* clear mbuf payload */
4878 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4879 rte_pktmbuf_tailroom(ut_params->ibuf));
4881 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4882 /* Append data which is padded to a multiple of */
4883 /* the algorithms block size */
4884 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4885 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4887 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4889 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4891 /* Create KASUMI operation */
4892 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4893 tdata->digest.len, NULL, 0,
4894 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4895 tdata->cipher_iv.data, tdata->cipher_iv.len,
4896 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4897 tdata->validCipherOffsetInBits.len,
4898 tdata->validAuthLenInBits.len,
4904 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4906 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4908 if (ut_params->op->sym->m_dst)
4909 ut_params->obuf = ut_params->op->sym->m_dst;
4911 ut_params->obuf = ut_params->op->sym->m_src;
4913 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4914 tdata->validCipherOffsetInBits.len >> 3);
4916 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4917 + plaintext_pad_len;
4919 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4920 (tdata->validCipherOffsetInBits.len >> 3);
4922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4924 reference_ciphertext,
4925 tdata->validCipherLenInBits.len,
4926 "KASUMI Ciphertext data not as expected");
4929 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4932 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4933 "KASUMI Generated auth tag not as expected");
4938 test_zuc_encryption(const struct wireless_test_data *tdata)
4940 struct crypto_testsuite_params *ts_params = &testsuite_params;
4941 struct crypto_unittest_params *ut_params = &unittest_params;
4944 uint8_t *plaintext, *ciphertext;
4945 unsigned plaintext_pad_len;
4946 unsigned plaintext_len;
4948 struct rte_cryptodev_sym_capability_idx cap_idx;
4950 /* Check if device supports ZUC EEA3 */
4951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4952 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4958 /* Create ZUC session */
4959 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4960 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4961 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4962 tdata->key.data, tdata->key.len,
4963 tdata->cipher_iv.len);
4967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4969 /* Clear mbuf payload */
4970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4971 rte_pktmbuf_tailroom(ut_params->ibuf));
4973 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4974 /* Append data which is padded to a multiple */
4975 /* of the algorithms block size */
4976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4977 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4979 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4981 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4983 /* Create ZUC operation */
4984 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4985 tdata->cipher_iv.len,
4986 tdata->plaintext.len,
4991 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4993 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4995 ut_params->obuf = ut_params->op->sym->m_dst;
4996 if (ut_params->obuf)
4997 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4999 ciphertext = plaintext;
5001 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5006 tdata->ciphertext.data,
5007 tdata->validCipherLenInBits.len,
5008 "ZUC Ciphertext data not as expected");
5013 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5015 struct crypto_testsuite_params *ts_params = &testsuite_params;
5016 struct crypto_unittest_params *ut_params = &unittest_params;
5020 unsigned int plaintext_pad_len;
5021 unsigned int plaintext_len;
5022 const uint8_t *ciphertext;
5023 uint8_t ciphertext_buffer[2048];
5024 struct rte_cryptodev_info dev_info;
5026 struct rte_cryptodev_sym_capability_idx cap_idx;
5028 /* Check if device supports ZUC EEA3 */
5029 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5030 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5032 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5036 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5038 uint64_t feat_flags = dev_info.feature_flags;
5040 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5041 printf("Device doesn't support in-place scatter-gather. "
5046 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5048 /* Append data which is padded to a multiple */
5049 /* of the algorithms block size */
5050 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5052 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5053 plaintext_pad_len, 10, 0);
5055 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5056 tdata->plaintext.data);
5058 /* Create ZUC session */
5059 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5060 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5061 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5062 tdata->key.data, tdata->key.len,
5063 tdata->cipher_iv.len);
5067 /* Clear mbuf payload */
5069 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5071 /* Create ZUC operation */
5072 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5073 tdata->cipher_iv.len, tdata->plaintext.len,
5078 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5080 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5082 ut_params->obuf = ut_params->op->sym->m_dst;
5083 if (ut_params->obuf)
5084 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5085 0, plaintext_len, ciphertext_buffer);
5087 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5088 0, plaintext_len, ciphertext_buffer);
5091 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5094 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5096 tdata->ciphertext.data,
5097 tdata->validCipherLenInBits.len,
5098 "ZUC Ciphertext data not as expected");
5104 test_zuc_authentication(const struct wireless_test_data *tdata)
5106 struct crypto_testsuite_params *ts_params = &testsuite_params;
5107 struct crypto_unittest_params *ut_params = &unittest_params;
5110 unsigned plaintext_pad_len;
5111 unsigned plaintext_len;
5114 struct rte_cryptodev_sym_capability_idx cap_idx;
5115 struct rte_cryptodev_info dev_info;
5117 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5118 uint64_t feat_flags = dev_info.feature_flags;
5120 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5121 (tdata->validAuthLenInBits.len % 8 != 0)) {
5122 printf("Device doesn't support NON-Byte Aligned Data.\n");
5126 /* Check if device supports ZUC EIA3 */
5127 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5128 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5130 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5134 /* Create ZUC session */
5135 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5136 tdata->key.data, tdata->key.len,
5137 tdata->auth_iv.len, tdata->digest.len,
5138 RTE_CRYPTO_AUTH_OP_GENERATE,
5139 RTE_CRYPTO_AUTH_ZUC_EIA3);
5143 /* alloc mbuf and set payload */
5144 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5146 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5147 rte_pktmbuf_tailroom(ut_params->ibuf));
5149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5150 /* Append data which is padded to a multiple of */
5151 /* the algorithms block size */
5152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5153 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5155 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5157 /* Create ZUC operation */
5158 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5159 tdata->auth_iv.data, tdata->auth_iv.len,
5160 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5161 tdata->validAuthLenInBits.len,
5166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5168 ut_params->obuf = ut_params->op->sym->m_src;
5169 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5170 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5171 + plaintext_pad_len;
5174 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5178 "ZUC Generated auth tag not as expected");
5184 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5185 uint8_t op_mode, uint8_t verify)
5187 struct crypto_testsuite_params *ts_params = &testsuite_params;
5188 struct crypto_unittest_params *ut_params = &unittest_params;
5192 uint8_t *plaintext = NULL, *ciphertext = NULL;
5193 unsigned int plaintext_pad_len;
5194 unsigned int plaintext_len;
5195 unsigned int ciphertext_pad_len;
5196 unsigned int ciphertext_len;
5198 struct rte_cryptodev_info dev_info;
5199 struct rte_cryptodev_sym_capability_idx cap_idx;
5201 /* Check if device supports ZUC EIA3 */
5202 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5203 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5209 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5211 uint64_t feat_flags = dev_info.feature_flags;
5213 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5214 printf("Device doesn't support digest encrypted.\n");
5217 if (op_mode == IN_PLACE) {
5218 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5219 printf("Device doesn't support in-place scatter-gather "
5220 "in both input and output mbufs.\n");
5224 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5225 printf("Device doesn't support out-of-place scatter-gather "
5226 "in both input and output mbufs.\n");
5231 /* Create ZUC session */
5232 retval = create_wireless_algo_auth_cipher_session(
5233 ts_params->valid_devs[0],
5234 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5235 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5236 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5237 : RTE_CRYPTO_AUTH_OP_GENERATE),
5238 RTE_CRYPTO_AUTH_ZUC_EIA3,
5239 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5240 tdata->key.data, tdata->key.len,
5241 tdata->auth_iv.len, tdata->digest.len,
5242 tdata->cipher_iv.len);
5247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5248 if (op_mode == OUT_OF_PLACE)
5249 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5251 /* clear mbuf payload */
5252 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5253 rte_pktmbuf_tailroom(ut_params->ibuf));
5254 if (op_mode == OUT_OF_PLACE)
5255 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5256 rte_pktmbuf_tailroom(ut_params->obuf));
5258 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5259 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5260 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5264 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5265 ciphertext_pad_len);
5266 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5267 if (op_mode == OUT_OF_PLACE)
5268 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5269 debug_hexdump(stdout, "ciphertext:", ciphertext,
5272 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5274 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5275 if (op_mode == OUT_OF_PLACE)
5276 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5277 debug_hexdump(stdout, "plaintext:", plaintext,
5281 /* Create ZUC operation */
5282 retval = create_wireless_algo_auth_cipher_operation(
5283 tdata->digest.data, tdata->digest.len,
5284 tdata->cipher_iv.data, tdata->cipher_iv.len,
5285 tdata->auth_iv.data, tdata->auth_iv.len,
5286 (tdata->digest.offset_bytes == 0 ?
5287 (verify ? ciphertext_pad_len : plaintext_pad_len)
5288 : tdata->digest.offset_bytes),
5289 tdata->validCipherLenInBits.len,
5290 tdata->validCipherOffsetInBits.len,
5291 tdata->validAuthLenInBits.len,
5293 op_mode, 0, verify);
5298 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5301 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5303 ut_params->obuf = (op_mode == IN_PLACE ?
5304 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5308 if (ut_params->obuf)
5309 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5312 plaintext = ciphertext;
5314 debug_hexdump(stdout, "plaintext:", plaintext,
5315 (tdata->plaintext.len >> 3) - tdata->digest.len);
5316 debug_hexdump(stdout, "plaintext expected:",
5317 tdata->plaintext.data,
5318 (tdata->plaintext.len >> 3) - tdata->digest.len);
5320 if (ut_params->obuf)
5321 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5324 ciphertext = plaintext;
5326 debug_hexdump(stdout, "ciphertext:", ciphertext,
5328 debug_hexdump(stdout, "ciphertext expected:",
5329 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5331 ut_params->digest = rte_pktmbuf_mtod(
5332 ut_params->obuf, uint8_t *) +
5333 (tdata->digest.offset_bytes == 0 ?
5334 plaintext_pad_len : tdata->digest.offset_bytes);
5336 debug_hexdump(stdout, "digest:", ut_params->digest,
5338 debug_hexdump(stdout, "digest expected:",
5339 tdata->digest.data, tdata->digest.len);
5344 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5346 tdata->plaintext.data,
5347 tdata->plaintext.len >> 3,
5348 "ZUC Plaintext data not as expected");
5350 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5352 tdata->ciphertext.data,
5353 tdata->ciphertext.len >> 3,
5354 "ZUC Ciphertext data not as expected");
5356 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5359 DIGEST_BYTE_LENGTH_KASUMI_F9,
5360 "ZUC Generated auth tag not as expected");
5366 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5367 uint8_t op_mode, uint8_t verify)
5369 struct crypto_testsuite_params *ts_params = &testsuite_params;
5370 struct crypto_unittest_params *ut_params = &unittest_params;
5374 const uint8_t *plaintext = NULL;
5375 const uint8_t *ciphertext = NULL;
5376 const uint8_t *digest = NULL;
5377 unsigned int plaintext_pad_len;
5378 unsigned int plaintext_len;
5379 unsigned int ciphertext_pad_len;
5380 unsigned int ciphertext_len;
5381 uint8_t buffer[10000];
5382 uint8_t digest_buffer[10000];
5384 struct rte_cryptodev_info dev_info;
5385 struct rte_cryptodev_sym_capability_idx cap_idx;
5387 /* Check if device supports ZUC EIA3 */
5388 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5389 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5391 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5395 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5397 uint64_t feat_flags = dev_info.feature_flags;
5399 if (op_mode == IN_PLACE) {
5400 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5401 printf("Device doesn't support in-place scatter-gather "
5402 "in both input and output mbufs.\n");
5406 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5407 printf("Device doesn't support out-of-place scatter-gather "
5408 "in both input and output mbufs.\n");
5411 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5412 printf("Device doesn't support digest encrypted.\n");
5417 /* Create ZUC session */
5418 retval = create_wireless_algo_auth_cipher_session(
5419 ts_params->valid_devs[0],
5420 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5421 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5422 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5423 : RTE_CRYPTO_AUTH_OP_GENERATE),
5424 RTE_CRYPTO_AUTH_ZUC_EIA3,
5425 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5426 tdata->key.data, tdata->key.len,
5427 tdata->auth_iv.len, tdata->digest.len,
5428 tdata->cipher_iv.len);
5433 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5434 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5435 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5436 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5438 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5439 plaintext_pad_len, 15, 0);
5440 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5441 "Failed to allocate input buffer in mempool");
5443 if (op_mode == OUT_OF_PLACE) {
5444 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5445 plaintext_pad_len, 15, 0);
5446 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5447 "Failed to allocate output buffer in mempool");
5451 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5452 tdata->ciphertext.data);
5453 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5454 ciphertext_len, buffer);
5455 debug_hexdump(stdout, "ciphertext:", ciphertext,
5458 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5459 tdata->plaintext.data);
5460 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5461 plaintext_len, buffer);
5462 debug_hexdump(stdout, "plaintext:", plaintext,
5465 memset(buffer, 0, sizeof(buffer));
5467 /* Create ZUC operation */
5468 retval = create_wireless_algo_auth_cipher_operation(
5469 tdata->digest.data, tdata->digest.len,
5470 tdata->cipher_iv.data, tdata->cipher_iv.len,
5472 (tdata->digest.offset_bytes == 0 ?
5473 (verify ? ciphertext_pad_len : plaintext_pad_len)
5474 : tdata->digest.offset_bytes),
5475 tdata->validCipherLenInBits.len,
5476 tdata->validCipherOffsetInBits.len,
5477 tdata->validAuthLenInBits.len,
5479 op_mode, 1, verify);
5484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5489 ut_params->obuf = (op_mode == IN_PLACE ?
5490 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5493 if (ut_params->obuf)
5494 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5495 plaintext_len, buffer);
5497 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5498 plaintext_len, buffer);
5500 debug_hexdump(stdout, "plaintext:", plaintext,
5501 (tdata->plaintext.len >> 3) - tdata->digest.len);
5502 debug_hexdump(stdout, "plaintext expected:",
5503 tdata->plaintext.data,
5504 (tdata->plaintext.len >> 3) - tdata->digest.len);
5506 if (ut_params->obuf)
5507 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5508 ciphertext_len, buffer);
5510 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5511 ciphertext_len, buffer);
5513 debug_hexdump(stdout, "ciphertext:", ciphertext,
5515 debug_hexdump(stdout, "ciphertext expected:",
5516 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5518 if (ut_params->obuf)
5519 digest = rte_pktmbuf_read(ut_params->obuf,
5520 (tdata->digest.offset_bytes == 0 ?
5521 plaintext_pad_len : tdata->digest.offset_bytes),
5522 tdata->digest.len, digest_buffer);
5524 digest = rte_pktmbuf_read(ut_params->ibuf,
5525 (tdata->digest.offset_bytes == 0 ?
5526 plaintext_pad_len : tdata->digest.offset_bytes),
5527 tdata->digest.len, digest_buffer);
5529 debug_hexdump(stdout, "digest:", digest,
5531 debug_hexdump(stdout, "digest expected:",
5532 tdata->digest.data, tdata->digest.len);
5537 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5539 tdata->plaintext.data,
5540 tdata->plaintext.len >> 3,
5541 "ZUC Plaintext data not as expected");
5543 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5545 tdata->ciphertext.data,
5546 tdata->validDataLenInBits.len,
5547 "ZUC Ciphertext data not as expected");
5549 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5552 DIGEST_BYTE_LENGTH_KASUMI_F9,
5553 "ZUC Generated auth tag not as expected");
5559 test_kasumi_encryption_test_case_1(void)
5561 return test_kasumi_encryption(&kasumi_test_case_1);
5565 test_kasumi_encryption_test_case_1_sgl(void)
5567 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5571 test_kasumi_encryption_test_case_1_oop(void)
5573 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5577 test_kasumi_encryption_test_case_1_oop_sgl(void)
5579 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5583 test_kasumi_encryption_test_case_2(void)
5585 return test_kasumi_encryption(&kasumi_test_case_2);
5589 test_kasumi_encryption_test_case_3(void)
5591 return test_kasumi_encryption(&kasumi_test_case_3);
5595 test_kasumi_encryption_test_case_4(void)
5597 return test_kasumi_encryption(&kasumi_test_case_4);
5601 test_kasumi_encryption_test_case_5(void)
5603 return test_kasumi_encryption(&kasumi_test_case_5);
5607 test_kasumi_decryption_test_case_1(void)
5609 return test_kasumi_decryption(&kasumi_test_case_1);
5613 test_kasumi_decryption_test_case_1_oop(void)
5615 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5619 test_kasumi_decryption_test_case_2(void)
5621 return test_kasumi_decryption(&kasumi_test_case_2);
5625 test_kasumi_decryption_test_case_3(void)
5627 return test_kasumi_decryption(&kasumi_test_case_3);
5631 test_kasumi_decryption_test_case_4(void)
5633 return test_kasumi_decryption(&kasumi_test_case_4);
5637 test_kasumi_decryption_test_case_5(void)
5639 return test_kasumi_decryption(&kasumi_test_case_5);
5642 test_snow3g_encryption_test_case_1(void)
5644 return test_snow3g_encryption(&snow3g_test_case_1);
5648 test_snow3g_encryption_test_case_1_oop(void)
5650 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5654 test_snow3g_encryption_test_case_1_oop_sgl(void)
5656 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5661 test_snow3g_encryption_test_case_1_offset_oop(void)
5663 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5667 test_snow3g_encryption_test_case_2(void)
5669 return test_snow3g_encryption(&snow3g_test_case_2);
5673 test_snow3g_encryption_test_case_3(void)
5675 return test_snow3g_encryption(&snow3g_test_case_3);
5679 test_snow3g_encryption_test_case_4(void)
5681 return test_snow3g_encryption(&snow3g_test_case_4);
5685 test_snow3g_encryption_test_case_5(void)
5687 return test_snow3g_encryption(&snow3g_test_case_5);
5691 test_snow3g_decryption_test_case_1(void)
5693 return test_snow3g_decryption(&snow3g_test_case_1);
5697 test_snow3g_decryption_test_case_1_oop(void)
5699 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5703 test_snow3g_decryption_test_case_2(void)
5705 return test_snow3g_decryption(&snow3g_test_case_2);
5709 test_snow3g_decryption_test_case_3(void)
5711 return test_snow3g_decryption(&snow3g_test_case_3);
5715 test_snow3g_decryption_test_case_4(void)
5717 return test_snow3g_decryption(&snow3g_test_case_4);
5721 test_snow3g_decryption_test_case_5(void)
5723 return test_snow3g_decryption(&snow3g_test_case_5);
5727 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5728 * Pattern digest from snow3g_test_data must be allocated as
5729 * 4 last bytes in plaintext.
5732 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5733 struct snow3g_hash_test_data *output)
5735 if ((pattern != NULL) && (output != NULL)) {
5736 output->key.len = pattern->key.len;
5738 memcpy(output->key.data,
5739 pattern->key.data, pattern->key.len);
5741 output->auth_iv.len = pattern->auth_iv.len;
5743 memcpy(output->auth_iv.data,
5744 pattern->auth_iv.data, pattern->auth_iv.len);
5746 output->plaintext.len = pattern->plaintext.len;
5748 memcpy(output->plaintext.data,
5749 pattern->plaintext.data, pattern->plaintext.len >> 3);
5751 output->digest.len = pattern->digest.len;
5753 memcpy(output->digest.data,
5754 &pattern->plaintext.data[pattern->digest.offset_bytes],
5755 pattern->digest.len);
5757 output->validAuthLenInBits.len =
5758 pattern->validAuthLenInBits.len;
5763 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5766 test_snow3g_decryption_with_digest_test_case_1(void)
5768 struct snow3g_hash_test_data snow3g_hash_data;
5771 * Function prepare data for hash veryfication test case.
5772 * Digest is allocated in 4 last bytes in plaintext, pattern.
5774 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5776 return test_snow3g_decryption(&snow3g_test_case_7) &
5777 test_snow3g_authentication_verify(&snow3g_hash_data);
5781 test_snow3g_cipher_auth_test_case_1(void)
5783 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5787 test_snow3g_auth_cipher_test_case_1(void)
5789 return test_snow3g_auth_cipher(
5790 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5794 test_snow3g_auth_cipher_test_case_2(void)
5796 return test_snow3g_auth_cipher(
5797 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5801 test_snow3g_auth_cipher_test_case_2_oop(void)
5803 return test_snow3g_auth_cipher(
5804 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5808 test_snow3g_auth_cipher_part_digest_enc(void)
5810 return test_snow3g_auth_cipher(
5811 &snow3g_auth_cipher_partial_digest_encryption,
5816 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5818 return test_snow3g_auth_cipher(
5819 &snow3g_auth_cipher_partial_digest_encryption,
5824 test_snow3g_auth_cipher_test_case_3_sgl(void)
5826 return test_snow3g_auth_cipher_sgl(
5827 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5831 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5833 return test_snow3g_auth_cipher_sgl(
5834 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5838 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5840 return test_snow3g_auth_cipher_sgl(
5841 &snow3g_auth_cipher_partial_digest_encryption,
5846 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5848 return test_snow3g_auth_cipher_sgl(
5849 &snow3g_auth_cipher_partial_digest_encryption,
5854 test_snow3g_auth_cipher_verify_test_case_1(void)
5856 return test_snow3g_auth_cipher(
5857 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5861 test_snow3g_auth_cipher_verify_test_case_2(void)
5863 return test_snow3g_auth_cipher(
5864 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5868 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5870 return test_snow3g_auth_cipher(
5871 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5875 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5877 return test_snow3g_auth_cipher(
5878 &snow3g_auth_cipher_partial_digest_encryption,
5883 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5885 return test_snow3g_auth_cipher(
5886 &snow3g_auth_cipher_partial_digest_encryption,
5891 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5893 return test_snow3g_auth_cipher_sgl(
5894 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5898 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5900 return test_snow3g_auth_cipher_sgl(
5901 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5905 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5907 return test_snow3g_auth_cipher_sgl(
5908 &snow3g_auth_cipher_partial_digest_encryption,
5913 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5915 return test_snow3g_auth_cipher_sgl(
5916 &snow3g_auth_cipher_partial_digest_encryption,
5921 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5923 return test_snow3g_auth_cipher(
5924 &snow3g_test_case_7, IN_PLACE, 0);
5928 test_kasumi_auth_cipher_test_case_1(void)
5930 return test_kasumi_auth_cipher(
5931 &kasumi_test_case_3, IN_PLACE, 0);
5935 test_kasumi_auth_cipher_test_case_2(void)
5937 return test_kasumi_auth_cipher(
5938 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5942 test_kasumi_auth_cipher_test_case_2_oop(void)
5944 return test_kasumi_auth_cipher(
5945 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5949 test_kasumi_auth_cipher_test_case_2_sgl(void)
5951 return test_kasumi_auth_cipher_sgl(
5952 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5956 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5958 return test_kasumi_auth_cipher_sgl(
5959 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5963 test_kasumi_auth_cipher_verify_test_case_1(void)
5965 return test_kasumi_auth_cipher(
5966 &kasumi_test_case_3, IN_PLACE, 1);
5970 test_kasumi_auth_cipher_verify_test_case_2(void)
5972 return test_kasumi_auth_cipher(
5973 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5977 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5979 return test_kasumi_auth_cipher(
5980 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5984 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5986 return test_kasumi_auth_cipher_sgl(
5987 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5991 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5993 return test_kasumi_auth_cipher_sgl(
5994 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5998 test_kasumi_cipher_auth_test_case_1(void)
6000 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6004 test_zuc_encryption_test_case_1(void)
6006 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6010 test_zuc_encryption_test_case_2(void)
6012 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6016 test_zuc_encryption_test_case_3(void)
6018 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6022 test_zuc_encryption_test_case_4(void)
6024 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6028 test_zuc_encryption_test_case_5(void)
6030 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6034 test_zuc_encryption_test_case_6_sgl(void)
6036 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6040 test_zuc_hash_generate_test_case_1(void)
6042 return test_zuc_authentication(&zuc_test_case_auth_1b);
6046 test_zuc_hash_generate_test_case_2(void)
6048 return test_zuc_authentication(&zuc_test_case_auth_90b);
6052 test_zuc_hash_generate_test_case_3(void)
6054 return test_zuc_authentication(&zuc_test_case_auth_577b);
6058 test_zuc_hash_generate_test_case_4(void)
6060 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6064 test_zuc_hash_generate_test_case_5(void)
6066 return test_zuc_authentication(&zuc_test_auth_5670b);
6070 test_zuc_hash_generate_test_case_6(void)
6072 return test_zuc_authentication(&zuc_test_case_auth_128b);
6076 test_zuc_hash_generate_test_case_7(void)
6078 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6082 test_zuc_hash_generate_test_case_8(void)
6084 return test_zuc_authentication(&zuc_test_case_auth_584b);
6088 test_zuc_cipher_auth_test_case_1(void)
6090 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6094 test_zuc_cipher_auth_test_case_2(void)
6096 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6100 test_zuc_auth_cipher_test_case_1(void)
6102 return test_zuc_auth_cipher(
6103 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6107 test_zuc_auth_cipher_test_case_1_oop(void)
6109 return test_zuc_auth_cipher(
6110 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6114 test_zuc_auth_cipher_test_case_1_sgl(void)
6116 return test_zuc_auth_cipher_sgl(
6117 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6121 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6123 return test_zuc_auth_cipher_sgl(
6124 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6128 test_zuc_auth_cipher_verify_test_case_1(void)
6130 return test_zuc_auth_cipher(
6131 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6135 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6137 return test_zuc_auth_cipher(
6138 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6142 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6144 return test_zuc_auth_cipher_sgl(
6145 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6149 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6151 return test_zuc_auth_cipher_sgl(
6152 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6156 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6158 uint8_t dev_id = testsuite_params.valid_devs[0];
6160 struct rte_cryptodev_sym_capability_idx cap_idx;
6162 /* Check if device supports particular cipher algorithm */
6163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6164 cap_idx.algo.cipher = tdata->cipher_algo;
6165 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6168 /* Check if device supports particular hash algorithm */
6169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6170 cap_idx.algo.auth = tdata->auth_algo;
6171 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6178 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6179 uint8_t op_mode, uint8_t verify)
6181 struct crypto_testsuite_params *ts_params = &testsuite_params;
6182 struct crypto_unittest_params *ut_params = &unittest_params;
6186 uint8_t *plaintext = NULL, *ciphertext = NULL;
6187 unsigned int plaintext_pad_len;
6188 unsigned int plaintext_len;
6189 unsigned int ciphertext_pad_len;
6190 unsigned int ciphertext_len;
6192 struct rte_cryptodev_info dev_info;
6193 struct rte_crypto_op *op;
6195 /* Check if device supports particular algorithms separately */
6196 if (test_mixed_check_if_unsupported(tdata))
6199 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6201 uint64_t feat_flags = dev_info.feature_flags;
6203 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6204 printf("Device doesn't support digest encrypted.\n");
6208 /* Create the session */
6210 retval = create_wireless_algo_cipher_auth_session(
6211 ts_params->valid_devs[0],
6212 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6213 RTE_CRYPTO_AUTH_OP_VERIFY,
6216 tdata->auth_key.data, tdata->auth_key.len,
6217 tdata->auth_iv.len, tdata->digest_enc.len,
6218 tdata->cipher_iv.len);
6220 retval = create_wireless_algo_auth_cipher_session(
6221 ts_params->valid_devs[0],
6222 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6223 RTE_CRYPTO_AUTH_OP_GENERATE,
6226 tdata->auth_key.data, tdata->auth_key.len,
6227 tdata->auth_iv.len, tdata->digest_enc.len,
6228 tdata->cipher_iv.len);
6232 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6233 if (op_mode == OUT_OF_PLACE)
6234 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6236 /* clear mbuf payload */
6237 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6238 rte_pktmbuf_tailroom(ut_params->ibuf));
6239 if (op_mode == OUT_OF_PLACE)
6240 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6241 rte_pktmbuf_tailroom(ut_params->obuf));
6243 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6244 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6245 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6246 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6249 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6250 ciphertext_pad_len);
6251 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6252 if (op_mode == OUT_OF_PLACE)
6253 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6254 debug_hexdump(stdout, "ciphertext:", ciphertext,
6257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6260 if (op_mode == OUT_OF_PLACE)
6261 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6262 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6265 /* Create the operation */
6266 retval = create_wireless_algo_auth_cipher_operation(
6267 tdata->digest_enc.data, tdata->digest_enc.len,
6268 tdata->cipher_iv.data, tdata->cipher_iv.len,
6269 tdata->auth_iv.data, tdata->auth_iv.len,
6270 (tdata->digest_enc.offset == 0 ?
6272 : tdata->digest_enc.offset),
6273 tdata->validCipherLen.len_bits,
6274 tdata->cipher.offset_bits,
6275 tdata->validAuthLen.len_bits,
6276 tdata->auth.offset_bits,
6277 op_mode, 0, verify);
6282 op = process_crypto_request(ts_params->valid_devs[0],
6285 /* Check if the op failed because the device doesn't */
6286 /* support this particular combination of algorithms */
6287 if (op == NULL && ut_params->op->status ==
6288 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6289 printf("Device doesn't support this mixed combination. "
6295 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6297 ut_params->obuf = (op_mode == IN_PLACE ?
6298 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6301 if (ut_params->obuf)
6302 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6305 plaintext = ciphertext +
6306 (tdata->cipher.offset_bits >> 3);
6308 debug_hexdump(stdout, "plaintext:", plaintext,
6309 tdata->plaintext.len_bits >> 3);
6310 debug_hexdump(stdout, "plaintext expected:",
6311 tdata->plaintext.data,
6312 tdata->plaintext.len_bits >> 3);
6314 if (ut_params->obuf)
6315 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6318 ciphertext = plaintext;
6320 debug_hexdump(stdout, "ciphertext:", ciphertext,
6322 debug_hexdump(stdout, "ciphertext expected:",
6323 tdata->ciphertext.data,
6324 tdata->ciphertext.len_bits >> 3);
6326 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6327 + (tdata->digest_enc.offset == 0 ?
6328 plaintext_pad_len : tdata->digest_enc.offset);
6330 debug_hexdump(stdout, "digest:", ut_params->digest,
6331 tdata->digest_enc.len);
6332 debug_hexdump(stdout, "digest expected:",
6333 tdata->digest_enc.data,
6334 tdata->digest_enc.len);
6339 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6341 tdata->plaintext.data,
6342 tdata->plaintext.len_bits >> 3,
6343 "Plaintext data not as expected");
6345 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6347 tdata->ciphertext.data,
6348 tdata->validDataLen.len_bits,
6349 "Ciphertext data not as expected");
6351 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6353 tdata->digest_enc.data,
6354 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6355 "Generated auth tag not as expected");
6358 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6359 "crypto op processing failed");
6365 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6366 uint8_t op_mode, uint8_t verify)
6368 struct crypto_testsuite_params *ts_params = &testsuite_params;
6369 struct crypto_unittest_params *ut_params = &unittest_params;
6373 const uint8_t *plaintext = NULL;
6374 const uint8_t *ciphertext = NULL;
6375 const uint8_t *digest = NULL;
6376 unsigned int plaintext_pad_len;
6377 unsigned int plaintext_len;
6378 unsigned int ciphertext_pad_len;
6379 unsigned int ciphertext_len;
6380 uint8_t buffer[10000];
6381 uint8_t digest_buffer[10000];
6383 struct rte_cryptodev_info dev_info;
6384 struct rte_crypto_op *op;
6386 /* Check if device supports particular algorithms */
6387 if (test_mixed_check_if_unsupported(tdata))
6390 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6392 uint64_t feat_flags = dev_info.feature_flags;
6394 if (op_mode == IN_PLACE) {
6395 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6396 printf("Device doesn't support in-place scatter-gather "
6397 "in both input and output mbufs.\n");
6401 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6402 printf("Device doesn't support out-of-place scatter-gather "
6403 "in both input and output mbufs.\n");
6406 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6407 printf("Device doesn't support digest encrypted.\n");
6412 /* Create the session */
6414 retval = create_wireless_algo_cipher_auth_session(
6415 ts_params->valid_devs[0],
6416 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6417 RTE_CRYPTO_AUTH_OP_VERIFY,
6420 tdata->auth_key.data, tdata->auth_key.len,
6421 tdata->auth_iv.len, tdata->digest_enc.len,
6422 tdata->cipher_iv.len);
6424 retval = create_wireless_algo_auth_cipher_session(
6425 ts_params->valid_devs[0],
6426 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6427 RTE_CRYPTO_AUTH_OP_GENERATE,
6430 tdata->auth_key.data, tdata->auth_key.len,
6431 tdata->auth_iv.len, tdata->digest_enc.len,
6432 tdata->cipher_iv.len);
6436 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6437 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6438 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6439 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6441 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6442 ciphertext_pad_len, 15, 0);
6443 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6444 "Failed to allocate input buffer in mempool");
6446 if (op_mode == OUT_OF_PLACE) {
6447 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6448 plaintext_pad_len, 15, 0);
6449 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6450 "Failed to allocate output buffer in mempool");
6454 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6455 tdata->ciphertext.data);
6456 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6457 ciphertext_len, buffer);
6458 debug_hexdump(stdout, "ciphertext:", ciphertext,
6461 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6462 tdata->plaintext.data);
6463 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6464 plaintext_len, buffer);
6465 debug_hexdump(stdout, "plaintext:", plaintext,
6468 memset(buffer, 0, sizeof(buffer));
6470 /* Create the operation */
6471 retval = create_wireless_algo_auth_cipher_operation(
6472 tdata->digest_enc.data, tdata->digest_enc.len,
6473 tdata->cipher_iv.data, tdata->cipher_iv.len,
6474 tdata->auth_iv.data, tdata->auth_iv.len,
6475 (tdata->digest_enc.offset == 0 ?
6477 : tdata->digest_enc.offset),
6478 tdata->validCipherLen.len_bits,
6479 tdata->cipher.offset_bits,
6480 tdata->validAuthLen.len_bits,
6481 tdata->auth.offset_bits,
6482 op_mode, 1, verify);
6487 op = process_crypto_request(ts_params->valid_devs[0],
6490 /* Check if the op failed because the device doesn't */
6491 /* support this particular combination of algorithms */
6492 if (op == NULL && ut_params->op->status ==
6493 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6494 printf("Device doesn't support this mixed combination. "
6501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6503 ut_params->obuf = (op_mode == IN_PLACE ?
6504 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6507 if (ut_params->obuf)
6508 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6509 plaintext_len, buffer);
6511 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6512 plaintext_len, buffer);
6514 debug_hexdump(stdout, "plaintext:", plaintext,
6515 (tdata->plaintext.len_bits >> 3) -
6516 tdata->digest_enc.len);
6517 debug_hexdump(stdout, "plaintext expected:",
6518 tdata->plaintext.data,
6519 (tdata->plaintext.len_bits >> 3) -
6520 tdata->digest_enc.len);
6522 if (ut_params->obuf)
6523 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6524 ciphertext_len, buffer);
6526 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6527 ciphertext_len, buffer);
6529 debug_hexdump(stdout, "ciphertext:", ciphertext,
6531 debug_hexdump(stdout, "ciphertext expected:",
6532 tdata->ciphertext.data,
6533 tdata->ciphertext.len_bits >> 3);
6535 if (ut_params->obuf)
6536 digest = rte_pktmbuf_read(ut_params->obuf,
6537 (tdata->digest_enc.offset == 0 ?
6539 tdata->digest_enc.offset),
6540 tdata->digest_enc.len, digest_buffer);
6542 digest = rte_pktmbuf_read(ut_params->ibuf,
6543 (tdata->digest_enc.offset == 0 ?
6545 tdata->digest_enc.offset),
6546 tdata->digest_enc.len, digest_buffer);
6548 debug_hexdump(stdout, "digest:", digest,
6549 tdata->digest_enc.len);
6550 debug_hexdump(stdout, "digest expected:",
6551 tdata->digest_enc.data, tdata->digest_enc.len);
6556 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6558 tdata->plaintext.data,
6559 tdata->plaintext.len_bits >> 3,
6560 "Plaintext data not as expected");
6562 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6564 tdata->ciphertext.data,
6565 tdata->validDataLen.len_bits,
6566 "Ciphertext data not as expected");
6567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6569 tdata->digest_enc.data,
6570 tdata->digest_enc.len,
6571 "Generated auth tag not as expected");
6574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6575 "crypto op processing failed");
6580 /** AUTH AES CMAC + CIPHER AES CTR */
6583 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6585 return test_mixed_auth_cipher(
6586 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6590 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6592 return test_mixed_auth_cipher(
6593 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6597 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6599 return test_mixed_auth_cipher_sgl(
6600 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6604 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6606 return test_mixed_auth_cipher_sgl(
6607 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6611 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6618 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6620 return test_mixed_auth_cipher(
6621 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6625 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6627 return test_mixed_auth_cipher_sgl(
6628 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6632 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6634 return test_mixed_auth_cipher_sgl(
6635 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6638 /** MIXED AUTH + CIPHER */
6641 test_auth_zuc_cipher_snow_test_case_1(void)
6643 return test_mixed_auth_cipher(
6644 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6648 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6650 return test_mixed_auth_cipher(
6651 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6655 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6657 return test_mixed_auth_cipher(
6658 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6662 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6664 return test_mixed_auth_cipher(
6665 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6669 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6671 return test_mixed_auth_cipher(
6672 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6676 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6678 return test_mixed_auth_cipher(
6679 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6683 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6685 return test_mixed_auth_cipher(
6686 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6690 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6692 return test_mixed_auth_cipher(
6693 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6697 test_auth_snow_cipher_zuc_test_case_1(void)
6699 return test_mixed_auth_cipher(
6700 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6704 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6706 return test_mixed_auth_cipher(
6707 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6711 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6713 return test_mixed_auth_cipher(
6714 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6718 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6720 return test_mixed_auth_cipher(
6721 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6725 test_auth_null_cipher_snow_test_case_1(void)
6727 return test_mixed_auth_cipher(
6728 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6732 test_verify_auth_null_cipher_snow_test_case_1(void)
6734 return test_mixed_auth_cipher(
6735 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6739 test_auth_null_cipher_zuc_test_case_1(void)
6741 return test_mixed_auth_cipher(
6742 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6746 test_verify_auth_null_cipher_zuc_test_case_1(void)
6748 return test_mixed_auth_cipher(
6749 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6753 test_auth_snow_cipher_null_test_case_1(void)
6755 return test_mixed_auth_cipher(
6756 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6760 test_verify_auth_snow_cipher_null_test_case_1(void)
6762 return test_mixed_auth_cipher(
6763 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6767 test_auth_zuc_cipher_null_test_case_1(void)
6769 return test_mixed_auth_cipher(
6770 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6774 test_verify_auth_zuc_cipher_null_test_case_1(void)
6776 return test_mixed_auth_cipher(
6777 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6781 test_auth_null_cipher_aes_ctr_test_case_1(void)
6783 return test_mixed_auth_cipher(
6784 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6788 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6790 return test_mixed_auth_cipher(
6791 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6795 test_auth_aes_cmac_cipher_null_test_case_1(void)
6797 return test_mixed_auth_cipher(
6798 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6802 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6804 return test_mixed_auth_cipher(
6805 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6808 /* ***** AEAD algorithm Tests ***** */
6811 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6812 enum rte_crypto_aead_operation op,
6813 const uint8_t *key, const uint8_t key_len,
6814 const uint16_t aad_len, const uint8_t auth_len,
6817 uint8_t aead_key[key_len];
6819 struct crypto_testsuite_params *ts_params = &testsuite_params;
6820 struct crypto_unittest_params *ut_params = &unittest_params;
6822 memcpy(aead_key, key, key_len);
6824 /* Setup AEAD Parameters */
6825 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6826 ut_params->aead_xform.next = NULL;
6827 ut_params->aead_xform.aead.algo = algo;
6828 ut_params->aead_xform.aead.op = op;
6829 ut_params->aead_xform.aead.key.data = aead_key;
6830 ut_params->aead_xform.aead.key.length = key_len;
6831 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6832 ut_params->aead_xform.aead.iv.length = iv_len;
6833 ut_params->aead_xform.aead.digest_length = auth_len;
6834 ut_params->aead_xform.aead.aad_length = aad_len;
6836 debug_hexdump(stdout, "key:", key, key_len);
6838 /* Create Crypto session*/
6839 ut_params->sess = rte_cryptodev_sym_session_create(
6840 ts_params->session_mpool);
6842 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6843 &ut_params->aead_xform,
6844 ts_params->session_priv_mpool);
6846 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6852 create_aead_xform(struct rte_crypto_op *op,
6853 enum rte_crypto_aead_algorithm algo,
6854 enum rte_crypto_aead_operation aead_op,
6855 uint8_t *key, const uint8_t key_len,
6856 const uint8_t aad_len, const uint8_t auth_len,
6859 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6860 "failed to allocate space for crypto transform");
6862 struct rte_crypto_sym_op *sym_op = op->sym;
6864 /* Setup AEAD Parameters */
6865 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6866 sym_op->xform->next = NULL;
6867 sym_op->xform->aead.algo = algo;
6868 sym_op->xform->aead.op = aead_op;
6869 sym_op->xform->aead.key.data = key;
6870 sym_op->xform->aead.key.length = key_len;
6871 sym_op->xform->aead.iv.offset = IV_OFFSET;
6872 sym_op->xform->aead.iv.length = iv_len;
6873 sym_op->xform->aead.digest_length = auth_len;
6874 sym_op->xform->aead.aad_length = aad_len;
6876 debug_hexdump(stdout, "key:", key, key_len);
6882 create_aead_operation(enum rte_crypto_aead_operation op,
6883 const struct aead_test_data *tdata)
6885 struct crypto_testsuite_params *ts_params = &testsuite_params;
6886 struct crypto_unittest_params *ut_params = &unittest_params;
6888 uint8_t *plaintext, *ciphertext;
6889 unsigned int aad_pad_len, plaintext_pad_len;
6891 /* Generate Crypto op data structure */
6892 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6893 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6894 TEST_ASSERT_NOT_NULL(ut_params->op,
6895 "Failed to allocate symmetric crypto operation struct");
6897 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6899 /* Append aad data */
6900 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6901 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6902 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6904 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6905 "no room to append aad");
6907 sym_op->aead.aad.phys_addr =
6908 rte_pktmbuf_iova(ut_params->ibuf);
6909 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6910 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6911 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6914 /* Append IV at the end of the crypto operation*/
6915 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6916 uint8_t *, IV_OFFSET);
6918 /* Copy IV 1 byte after the IV pointer, according to the API */
6919 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6920 debug_hexdump(stdout, "iv:", iv_ptr,
6923 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6924 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6926 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6927 "no room to append aad");
6929 sym_op->aead.aad.phys_addr =
6930 rte_pktmbuf_iova(ut_params->ibuf);
6931 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6932 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6935 /* Append IV at the end of the crypto operation*/
6936 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6937 uint8_t *, IV_OFFSET);
6939 if (tdata->iv.len == 0) {
6940 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6941 debug_hexdump(stdout, "iv:", iv_ptr,
6944 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6945 debug_hexdump(stdout, "iv:", iv_ptr,
6950 /* Append plaintext/ciphertext */
6951 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6952 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6953 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6955 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6957 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6958 debug_hexdump(stdout, "plaintext:", plaintext,
6959 tdata->plaintext.len);
6961 if (ut_params->obuf) {
6962 ciphertext = (uint8_t *)rte_pktmbuf_append(
6964 plaintext_pad_len + aad_pad_len);
6965 TEST_ASSERT_NOT_NULL(ciphertext,
6966 "no room to append ciphertext");
6968 memset(ciphertext + aad_pad_len, 0,
6969 tdata->ciphertext.len);
6972 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6973 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6975 TEST_ASSERT_NOT_NULL(ciphertext,
6976 "no room to append ciphertext");
6978 memcpy(ciphertext, tdata->ciphertext.data,
6979 tdata->ciphertext.len);
6980 debug_hexdump(stdout, "ciphertext:", ciphertext,
6981 tdata->ciphertext.len);
6983 if (ut_params->obuf) {
6984 plaintext = (uint8_t *)rte_pktmbuf_append(
6986 plaintext_pad_len + aad_pad_len);
6987 TEST_ASSERT_NOT_NULL(plaintext,
6988 "no room to append plaintext");
6990 memset(plaintext + aad_pad_len, 0,
6991 tdata->plaintext.len);
6995 /* Append digest data */
6996 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6997 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6998 ut_params->obuf ? ut_params->obuf :
7000 tdata->auth_tag.len);
7001 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7002 "no room to append digest");
7003 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7004 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7005 ut_params->obuf ? ut_params->obuf :
7010 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7011 ut_params->ibuf, tdata->auth_tag.len);
7012 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7013 "no room to append digest");
7014 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7016 plaintext_pad_len + aad_pad_len);
7018 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7019 tdata->auth_tag.len);
7020 debug_hexdump(stdout, "digest:",
7021 sym_op->aead.digest.data,
7022 tdata->auth_tag.len);
7025 sym_op->aead.data.length = tdata->plaintext.len;
7026 sym_op->aead.data.offset = aad_pad_len;
7032 test_authenticated_encryption(const struct aead_test_data *tdata)
7034 struct crypto_testsuite_params *ts_params = &testsuite_params;
7035 struct crypto_unittest_params *ut_params = &unittest_params;
7038 uint8_t *ciphertext, *auth_tag;
7039 uint16_t plaintext_pad_len;
7042 /* Verify the capabilities */
7043 struct rte_cryptodev_sym_capability_idx cap_idx;
7044 const struct rte_cryptodev_symmetric_capability *capability;
7045 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7046 cap_idx.algo.aead = tdata->algo;
7047 capability = rte_cryptodev_sym_capability_get(
7048 ts_params->valid_devs[0], &cap_idx);
7049 if (capability == NULL)
7051 if (rte_cryptodev_sym_capability_check_aead(
7052 capability, tdata->key.len, tdata->auth_tag.len,
7053 tdata->aad.len, tdata->iv.len))
7056 /* Create AEAD session */
7057 retval = create_aead_session(ts_params->valid_devs[0],
7059 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7060 tdata->key.data, tdata->key.len,
7061 tdata->aad.len, tdata->auth_tag.len,
7066 if (tdata->aad.len > MBUF_SIZE) {
7067 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7068 /* Populate full size of add data */
7069 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7070 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7074 /* clear mbuf payload */
7075 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7076 rte_pktmbuf_tailroom(ut_params->ibuf));
7078 /* Create AEAD operation */
7079 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7083 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7085 ut_params->op->sym->m_src = ut_params->ibuf;
7087 /* Process crypto operation */
7088 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7089 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7091 TEST_ASSERT_NOT_NULL(
7092 process_crypto_request(ts_params->valid_devs[0],
7093 ut_params->op), "failed to process sym crypto op");
7095 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7096 "crypto op processing failed");
7098 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7100 if (ut_params->op->sym->m_dst) {
7101 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7103 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7104 uint8_t *, plaintext_pad_len);
7106 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7108 ut_params->op->sym->cipher.data.offset);
7109 auth_tag = ciphertext + plaintext_pad_len;
7112 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7113 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7118 tdata->ciphertext.data,
7119 tdata->ciphertext.len,
7120 "Ciphertext data not as expected");
7122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7124 tdata->auth_tag.data,
7125 tdata->auth_tag.len,
7126 "Generated auth tag not as expected");
7132 #ifdef RTE_LIBRTE_SECURITY
7133 /* Basic algorithm run function for async inplace mode.
7134 * Creates a session from input parameters and runs one operation
7135 * on input_vec. Checks the output of the crypto operation against
7139 test_pdcp_proto(int i, int oop,
7140 enum rte_crypto_cipher_operation opc,
7141 enum rte_crypto_auth_operation opa,
7143 unsigned int input_vec_len,
7144 uint8_t *output_vec,
7145 unsigned int output_vec_len)
7147 struct crypto_testsuite_params *ts_params = &testsuite_params;
7148 struct crypto_unittest_params *ut_params = &unittest_params;
7150 int ret = TEST_SUCCESS;
7151 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7152 rte_cryptodev_get_sec_ctx(
7153 ts_params->valid_devs[0]);
7155 /* Verify the capabilities */
7156 struct rte_security_capability_idx sec_cap_idx;
7158 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7159 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7160 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7161 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7164 /* Generate test mbuf data */
7165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7167 /* clear mbuf payload */
7168 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7169 rte_pktmbuf_tailroom(ut_params->ibuf));
7171 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7173 memcpy(plaintext, input_vec, input_vec_len);
7175 /* Out of place support */
7178 * For out-op-place we need to alloc another mbuf
7180 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7181 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7184 /* Set crypto type as IPSEC */
7185 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7187 /* Setup Cipher Parameters */
7188 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7189 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7190 ut_params->cipher_xform.cipher.op = opc;
7191 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7192 ut_params->cipher_xform.cipher.key.length =
7193 pdcp_test_params[i].cipher_key_len;
7194 ut_params->cipher_xform.cipher.iv.length = 0;
7196 /* Setup HMAC Parameters if ICV header is required */
7197 if (pdcp_test_params[i].auth_alg != 0) {
7198 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7199 ut_params->auth_xform.next = NULL;
7200 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7201 ut_params->auth_xform.auth.op = opa;
7202 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7203 ut_params->auth_xform.auth.key.length =
7204 pdcp_test_params[i].auth_key_len;
7206 ut_params->cipher_xform.next = &ut_params->auth_xform;
7208 ut_params->cipher_xform.next = NULL;
7211 struct rte_security_session_conf sess_conf = {
7212 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7213 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7215 .bearer = pdcp_test_bearer[i],
7216 .domain = pdcp_test_params[i].domain,
7217 .pkt_dir = pdcp_test_packet_direction[i],
7218 .sn_size = pdcp_test_data_sn_size[i],
7219 .hfn = pdcp_test_hfn[i],
7220 .hfn_threshold = pdcp_test_hfn_threshold[i],
7222 .crypto_xform = &ut_params->cipher_xform
7225 /* Create security session */
7226 ut_params->sec_session = rte_security_session_create(ctx,
7227 &sess_conf, ts_params->session_priv_mpool);
7229 if (!ut_params->sec_session) {
7230 printf("TestCase %s()-%d line %d failed %s: ",
7231 __func__, i, __LINE__, "Failed to allocate session");
7236 /* Generate crypto op data structure */
7237 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7238 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7239 if (!ut_params->op) {
7240 printf("TestCase %s()-%d line %d failed %s: ",
7241 __func__, i, __LINE__,
7242 "Failed to allocate symmetric crypto operation struct");
7247 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7249 /* set crypto operation source mbuf */
7250 ut_params->op->sym->m_src = ut_params->ibuf;
7252 ut_params->op->sym->m_dst = ut_params->obuf;
7254 /* Process crypto operation */
7255 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7257 printf("TestCase %s()-%d line %d failed %s: ",
7258 __func__, i, __LINE__,
7259 "failed to process sym crypto op");
7264 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7265 printf("TestCase %s()-%d line %d failed %s: ",
7266 __func__, i, __LINE__, "crypto op processing failed");
7272 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7275 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7279 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7280 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7281 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7282 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7288 rte_crypto_op_free(ut_params->op);
7289 ut_params->op = NULL;
7291 if (ut_params->sec_session)
7292 rte_security_session_destroy(ctx, ut_params->sec_session);
7293 ut_params->sec_session = NULL;
7295 rte_pktmbuf_free(ut_params->ibuf);
7296 ut_params->ibuf = NULL;
7298 rte_pktmbuf_free(ut_params->obuf);
7299 ut_params->obuf = NULL;
7306 test_pdcp_proto_SGL(int i, int oop,
7307 enum rte_crypto_cipher_operation opc,
7308 enum rte_crypto_auth_operation opa,
7310 unsigned int input_vec_len,
7311 uint8_t *output_vec,
7312 unsigned int output_vec_len,
7314 uint32_t fragsz_oop)
7316 struct crypto_testsuite_params *ts_params = &testsuite_params;
7317 struct crypto_unittest_params *ut_params = &unittest_params;
7319 struct rte_mbuf *buf, *buf_oop = NULL;
7320 int ret = TEST_SUCCESS;
7324 unsigned int trn_data = 0;
7325 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7326 rte_cryptodev_get_sec_ctx(
7327 ts_params->valid_devs[0]);
7329 /* Verify the capabilities */
7330 struct rte_security_capability_idx sec_cap_idx;
7332 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7333 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7334 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7335 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7338 if (fragsz > input_vec_len)
7339 fragsz = input_vec_len;
7341 uint16_t plaintext_len = fragsz;
7342 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7344 if (fragsz_oop > output_vec_len)
7345 frag_size_oop = output_vec_len;
7348 if (input_vec_len % fragsz != 0) {
7349 if (input_vec_len / fragsz + 1 > 16)
7351 } else if (input_vec_len / fragsz > 16)
7354 /* Out of place support */
7357 * For out-op-place we need to alloc another mbuf
7359 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7360 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7361 buf_oop = ut_params->obuf;
7364 /* Generate test mbuf data */
7365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7367 /* clear mbuf payload */
7368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7369 rte_pktmbuf_tailroom(ut_params->ibuf));
7371 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7373 memcpy(plaintext, input_vec, plaintext_len);
7374 trn_data += plaintext_len;
7376 buf = ut_params->ibuf;
7379 * Loop until no more fragments
7382 while (trn_data < input_vec_len) {
7384 to_trn = (input_vec_len - trn_data < fragsz) ?
7385 (input_vec_len - trn_data) : fragsz;
7387 to_trn_tbl[ecx++] = to_trn;
7389 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7392 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7393 rte_pktmbuf_tailroom(buf));
7396 if (oop && !fragsz_oop) {
7398 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7399 buf_oop = buf_oop->next;
7400 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7401 0, rte_pktmbuf_tailroom(buf_oop));
7402 rte_pktmbuf_append(buf_oop, to_trn);
7405 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7408 memcpy(plaintext, input_vec + trn_data, to_trn);
7412 ut_params->ibuf->nb_segs = segs;
7415 if (fragsz_oop && oop) {
7419 trn_data = frag_size_oop;
7420 while (trn_data < output_vec_len) {
7423 (output_vec_len - trn_data <
7425 (output_vec_len - trn_data) :
7428 to_trn_tbl[ecx++] = to_trn;
7431 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7432 buf_oop = buf_oop->next;
7433 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7434 0, rte_pktmbuf_tailroom(buf_oop));
7435 rte_pktmbuf_append(buf_oop, to_trn);
7439 ut_params->obuf->nb_segs = segs;
7442 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7444 /* Setup Cipher Parameters */
7445 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7446 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7447 ut_params->cipher_xform.cipher.op = opc;
7448 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7449 ut_params->cipher_xform.cipher.key.length =
7450 pdcp_test_params[i].cipher_key_len;
7451 ut_params->cipher_xform.cipher.iv.length = 0;
7453 /* Setup HMAC Parameters if ICV header is required */
7454 if (pdcp_test_params[i].auth_alg != 0) {
7455 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7456 ut_params->auth_xform.next = NULL;
7457 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7458 ut_params->auth_xform.auth.op = opa;
7459 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7460 ut_params->auth_xform.auth.key.length =
7461 pdcp_test_params[i].auth_key_len;
7463 ut_params->cipher_xform.next = &ut_params->auth_xform;
7465 ut_params->cipher_xform.next = NULL;
7468 struct rte_security_session_conf sess_conf = {
7469 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7470 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7472 .bearer = pdcp_test_bearer[i],
7473 .domain = pdcp_test_params[i].domain,
7474 .pkt_dir = pdcp_test_packet_direction[i],
7475 .sn_size = pdcp_test_data_sn_size[i],
7476 .hfn = pdcp_test_hfn[i],
7477 .hfn_threshold = pdcp_test_hfn_threshold[i],
7479 .crypto_xform = &ut_params->cipher_xform
7482 /* Create security session */
7483 ut_params->sec_session = rte_security_session_create(ctx,
7484 &sess_conf, ts_params->session_priv_mpool);
7486 if (!ut_params->sec_session) {
7487 printf("TestCase %s()-%d line %d failed %s: ",
7488 __func__, i, __LINE__, "Failed to allocate session");
7493 /* Generate crypto op data structure */
7494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7496 if (!ut_params->op) {
7497 printf("TestCase %s()-%d line %d failed %s: ",
7498 __func__, i, __LINE__,
7499 "Failed to allocate symmetric crypto operation struct");
7504 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7506 /* set crypto operation source mbuf */
7507 ut_params->op->sym->m_src = ut_params->ibuf;
7509 ut_params->op->sym->m_dst = ut_params->obuf;
7511 /* Process crypto operation */
7512 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7514 printf("TestCase %s()-%d line %d failed %s: ",
7515 __func__, i, __LINE__,
7516 "failed to process sym crypto op");
7521 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7522 printf("TestCase %s()-%d line %d failed %s: ",
7523 __func__, i, __LINE__, "crypto op processing failed");
7529 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7532 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7536 fragsz = frag_size_oop;
7537 if (memcmp(ciphertext, output_vec, fragsz)) {
7538 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7539 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7540 rte_hexdump(stdout, "reference", output_vec, fragsz);
7545 buf = ut_params->op->sym->m_src->next;
7547 buf = ut_params->op->sym->m_dst->next;
7549 unsigned int off = fragsz;
7553 ciphertext = rte_pktmbuf_mtod(buf,
7555 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7556 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7557 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7558 rte_hexdump(stdout, "reference", output_vec + off,
7563 off += to_trn_tbl[ecx++];
7567 rte_crypto_op_free(ut_params->op);
7568 ut_params->op = NULL;
7570 if (ut_params->sec_session)
7571 rte_security_session_destroy(ctx, ut_params->sec_session);
7572 ut_params->sec_session = NULL;
7574 rte_pktmbuf_free(ut_params->ibuf);
7575 ut_params->ibuf = NULL;
7577 rte_pktmbuf_free(ut_params->obuf);
7578 ut_params->obuf = NULL;
7585 test_pdcp_proto_cplane_encap(int i)
7587 return test_pdcp_proto(i, 0,
7588 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7589 RTE_CRYPTO_AUTH_OP_GENERATE,
7590 pdcp_test_data_in[i],
7591 pdcp_test_data_in_len[i],
7592 pdcp_test_data_out[i],
7593 pdcp_test_data_in_len[i]+4);
7597 test_pdcp_proto_uplane_encap(int i)
7599 return test_pdcp_proto(i, 0,
7600 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7601 RTE_CRYPTO_AUTH_OP_GENERATE,
7602 pdcp_test_data_in[i],
7603 pdcp_test_data_in_len[i],
7604 pdcp_test_data_out[i],
7605 pdcp_test_data_in_len[i]);
7610 test_pdcp_proto_uplane_encap_with_int(int i)
7612 return test_pdcp_proto(i, 0,
7613 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7614 RTE_CRYPTO_AUTH_OP_GENERATE,
7615 pdcp_test_data_in[i],
7616 pdcp_test_data_in_len[i],
7617 pdcp_test_data_out[i],
7618 pdcp_test_data_in_len[i] + 4);
7622 test_pdcp_proto_cplane_decap(int i)
7624 return test_pdcp_proto(i, 0,
7625 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7626 RTE_CRYPTO_AUTH_OP_VERIFY,
7627 pdcp_test_data_out[i],
7628 pdcp_test_data_in_len[i] + 4,
7629 pdcp_test_data_in[i],
7630 pdcp_test_data_in_len[i]);
7634 test_pdcp_proto_uplane_decap(int i)
7636 return test_pdcp_proto(i, 0,
7637 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7638 RTE_CRYPTO_AUTH_OP_VERIFY,
7639 pdcp_test_data_out[i],
7640 pdcp_test_data_in_len[i],
7641 pdcp_test_data_in[i],
7642 pdcp_test_data_in_len[i]);
7646 test_pdcp_proto_uplane_decap_with_int(int i)
7648 return test_pdcp_proto(i, 0,
7649 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7650 RTE_CRYPTO_AUTH_OP_VERIFY,
7651 pdcp_test_data_out[i],
7652 pdcp_test_data_in_len[i] + 4,
7653 pdcp_test_data_in[i],
7654 pdcp_test_data_in_len[i]);
7658 test_PDCP_PROTO_SGL_in_place_32B(void)
7660 /* i can be used for running any PDCP case
7661 * In this case it is uplane 12-bit AES-SNOW DL encap
7663 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7664 return test_pdcp_proto_SGL(i, IN_PLACE,
7665 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7666 RTE_CRYPTO_AUTH_OP_GENERATE,
7667 pdcp_test_data_in[i],
7668 pdcp_test_data_in_len[i],
7669 pdcp_test_data_out[i],
7670 pdcp_test_data_in_len[i]+4,
7674 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7676 /* i can be used for running any PDCP case
7677 * In this case it is uplane 18-bit NULL-NULL DL encap
7679 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7680 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7681 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7682 RTE_CRYPTO_AUTH_OP_GENERATE,
7683 pdcp_test_data_in[i],
7684 pdcp_test_data_in_len[i],
7685 pdcp_test_data_out[i],
7686 pdcp_test_data_in_len[i]+4,
7690 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7692 /* i can be used for running any PDCP case
7693 * In this case it is uplane 18-bit AES DL encap
7695 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7697 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7698 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7699 RTE_CRYPTO_AUTH_OP_GENERATE,
7700 pdcp_test_data_in[i],
7701 pdcp_test_data_in_len[i],
7702 pdcp_test_data_out[i],
7703 pdcp_test_data_in_len[i],
7707 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7709 /* i can be used for running any PDCP case
7710 * In this case it is cplane 12-bit AES-ZUC DL encap
7712 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7713 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7714 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7715 RTE_CRYPTO_AUTH_OP_GENERATE,
7716 pdcp_test_data_in[i],
7717 pdcp_test_data_in_len[i],
7718 pdcp_test_data_out[i],
7719 pdcp_test_data_in_len[i]+4,
7724 test_PDCP_PROTO_all(void)
7726 struct crypto_testsuite_params *ts_params = &testsuite_params;
7727 struct rte_cryptodev_info dev_info;
7730 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7731 uint64_t feat_flags = dev_info.feature_flags;
7733 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7736 status = test_PDCP_PROTO_cplane_encap_all();
7737 status += test_PDCP_PROTO_cplane_decap_all();
7738 status += test_PDCP_PROTO_uplane_encap_all();
7739 status += test_PDCP_PROTO_uplane_decap_all();
7740 status += test_PDCP_PROTO_SGL_in_place_32B();
7741 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7742 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7743 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7748 return TEST_SUCCESS;
7753 test_AES_GCM_authenticated_encryption_test_case_1(void)
7755 return test_authenticated_encryption(&gcm_test_case_1);
7759 test_AES_GCM_authenticated_encryption_test_case_2(void)
7761 return test_authenticated_encryption(&gcm_test_case_2);
7765 test_AES_GCM_authenticated_encryption_test_case_3(void)
7767 return test_authenticated_encryption(&gcm_test_case_3);
7771 test_AES_GCM_authenticated_encryption_test_case_4(void)
7773 return test_authenticated_encryption(&gcm_test_case_4);
7777 test_AES_GCM_authenticated_encryption_test_case_5(void)
7779 return test_authenticated_encryption(&gcm_test_case_5);
7783 test_AES_GCM_authenticated_encryption_test_case_6(void)
7785 return test_authenticated_encryption(&gcm_test_case_6);
7789 test_AES_GCM_authenticated_encryption_test_case_7(void)
7791 return test_authenticated_encryption(&gcm_test_case_7);
7795 test_AES_GCM_authenticated_encryption_test_case_8(void)
7797 return test_authenticated_encryption(&gcm_test_case_8);
7801 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7803 return test_authenticated_encryption(&gcm_J0_test_case_1);
7807 test_AES_GCM_auth_encryption_test_case_192_1(void)
7809 return test_authenticated_encryption(&gcm_test_case_192_1);
7813 test_AES_GCM_auth_encryption_test_case_192_2(void)
7815 return test_authenticated_encryption(&gcm_test_case_192_2);
7819 test_AES_GCM_auth_encryption_test_case_192_3(void)
7821 return test_authenticated_encryption(&gcm_test_case_192_3);
7825 test_AES_GCM_auth_encryption_test_case_192_4(void)
7827 return test_authenticated_encryption(&gcm_test_case_192_4);
7831 test_AES_GCM_auth_encryption_test_case_192_5(void)
7833 return test_authenticated_encryption(&gcm_test_case_192_5);
7837 test_AES_GCM_auth_encryption_test_case_192_6(void)
7839 return test_authenticated_encryption(&gcm_test_case_192_6);
7843 test_AES_GCM_auth_encryption_test_case_192_7(void)
7845 return test_authenticated_encryption(&gcm_test_case_192_7);
7849 test_AES_GCM_auth_encryption_test_case_256_1(void)
7851 return test_authenticated_encryption(&gcm_test_case_256_1);
7855 test_AES_GCM_auth_encryption_test_case_256_2(void)
7857 return test_authenticated_encryption(&gcm_test_case_256_2);
7861 test_AES_GCM_auth_encryption_test_case_256_3(void)
7863 return test_authenticated_encryption(&gcm_test_case_256_3);
7867 test_AES_GCM_auth_encryption_test_case_256_4(void)
7869 return test_authenticated_encryption(&gcm_test_case_256_4);
7873 test_AES_GCM_auth_encryption_test_case_256_5(void)
7875 return test_authenticated_encryption(&gcm_test_case_256_5);
7879 test_AES_GCM_auth_encryption_test_case_256_6(void)
7881 return test_authenticated_encryption(&gcm_test_case_256_6);
7885 test_AES_GCM_auth_encryption_test_case_256_7(void)
7887 return test_authenticated_encryption(&gcm_test_case_256_7);
7891 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7893 return test_authenticated_encryption(&gcm_test_case_aad_1);
7897 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7899 return test_authenticated_encryption(&gcm_test_case_aad_2);
7903 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7905 struct aead_test_data tdata;
7908 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7909 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7910 tdata.iv.data[0] += 1;
7911 res = test_authenticated_encryption(&tdata);
7912 if (res == -ENOTSUP)
7914 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7915 return TEST_SUCCESS;
7919 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7921 struct aead_test_data tdata;
7924 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7925 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7926 tdata.plaintext.data[0] += 1;
7927 res = test_authenticated_encryption(&tdata);
7928 if (res == -ENOTSUP)
7930 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7931 return TEST_SUCCESS;
7935 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7937 struct aead_test_data tdata;
7940 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7941 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7942 tdata.ciphertext.data[0] += 1;
7943 res = test_authenticated_encryption(&tdata);
7944 if (res == -ENOTSUP)
7946 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7947 return TEST_SUCCESS;
7951 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7953 struct aead_test_data tdata;
7956 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7957 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7959 res = test_authenticated_encryption(&tdata);
7960 if (res == -ENOTSUP)
7962 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7963 return TEST_SUCCESS;
7967 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7969 struct aead_test_data tdata;
7970 uint8_t aad[gcm_test_case_7.aad.len];
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 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7977 tdata.aad.data = aad;
7978 res = test_authenticated_encryption(&tdata);
7979 if (res == -ENOTSUP)
7981 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7982 return TEST_SUCCESS;
7986 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7988 struct aead_test_data tdata;
7991 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7992 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7993 tdata.auth_tag.data[0] += 1;
7994 res = test_authenticated_encryption(&tdata);
7995 if (res == -ENOTSUP)
7997 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7998 return TEST_SUCCESS;
8002 test_authenticated_decryption(const struct aead_test_data *tdata)
8004 struct crypto_testsuite_params *ts_params = &testsuite_params;
8005 struct crypto_unittest_params *ut_params = &unittest_params;
8011 /* Verify the capabilities */
8012 struct rte_cryptodev_sym_capability_idx cap_idx;
8013 const struct rte_cryptodev_symmetric_capability *capability;
8014 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8015 cap_idx.algo.aead = tdata->algo;
8016 capability = rte_cryptodev_sym_capability_get(
8017 ts_params->valid_devs[0], &cap_idx);
8018 if (capability == NULL)
8020 if (rte_cryptodev_sym_capability_check_aead(
8021 capability, tdata->key.len, tdata->auth_tag.len,
8022 tdata->aad.len, tdata->iv.len))
8025 /* Create AEAD session */
8026 retval = create_aead_session(ts_params->valid_devs[0],
8028 RTE_CRYPTO_AEAD_OP_DECRYPT,
8029 tdata->key.data, tdata->key.len,
8030 tdata->aad.len, tdata->auth_tag.len,
8035 /* alloc mbuf and set payload */
8036 if (tdata->aad.len > MBUF_SIZE) {
8037 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8038 /* Populate full size of add data */
8039 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8040 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8042 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8044 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8045 rte_pktmbuf_tailroom(ut_params->ibuf));
8047 /* Create AEAD operation */
8048 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8052 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8054 ut_params->op->sym->m_src = ut_params->ibuf;
8056 /* Process crypto operation */
8057 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8058 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8060 TEST_ASSERT_NOT_NULL(
8061 process_crypto_request(ts_params->valid_devs[0],
8062 ut_params->op), "failed to process sym crypto op");
8064 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8065 "crypto op processing failed");
8067 if (ut_params->op->sym->m_dst)
8068 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8071 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8073 ut_params->op->sym->cipher.data.offset);
8075 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8080 tdata->plaintext.data,
8081 tdata->plaintext.len,
8082 "Plaintext data not as expected");
8084 TEST_ASSERT_EQUAL(ut_params->op->status,
8085 RTE_CRYPTO_OP_STATUS_SUCCESS,
8086 "Authentication failed");
8092 test_AES_GCM_authenticated_decryption_test_case_1(void)
8094 return test_authenticated_decryption(&gcm_test_case_1);
8098 test_AES_GCM_authenticated_decryption_test_case_2(void)
8100 return test_authenticated_decryption(&gcm_test_case_2);
8104 test_AES_GCM_authenticated_decryption_test_case_3(void)
8106 return test_authenticated_decryption(&gcm_test_case_3);
8110 test_AES_GCM_authenticated_decryption_test_case_4(void)
8112 return test_authenticated_decryption(&gcm_test_case_4);
8116 test_AES_GCM_authenticated_decryption_test_case_5(void)
8118 return test_authenticated_decryption(&gcm_test_case_5);
8122 test_AES_GCM_authenticated_decryption_test_case_6(void)
8124 return test_authenticated_decryption(&gcm_test_case_6);
8128 test_AES_GCM_authenticated_decryption_test_case_7(void)
8130 return test_authenticated_decryption(&gcm_test_case_7);
8134 test_AES_GCM_authenticated_decryption_test_case_8(void)
8136 return test_authenticated_decryption(&gcm_test_case_8);
8140 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8142 return test_authenticated_decryption(&gcm_J0_test_case_1);
8146 test_AES_GCM_auth_decryption_test_case_192_1(void)
8148 return test_authenticated_decryption(&gcm_test_case_192_1);
8152 test_AES_GCM_auth_decryption_test_case_192_2(void)
8154 return test_authenticated_decryption(&gcm_test_case_192_2);
8158 test_AES_GCM_auth_decryption_test_case_192_3(void)
8160 return test_authenticated_decryption(&gcm_test_case_192_3);
8164 test_AES_GCM_auth_decryption_test_case_192_4(void)
8166 return test_authenticated_decryption(&gcm_test_case_192_4);
8170 test_AES_GCM_auth_decryption_test_case_192_5(void)
8172 return test_authenticated_decryption(&gcm_test_case_192_5);
8176 test_AES_GCM_auth_decryption_test_case_192_6(void)
8178 return test_authenticated_decryption(&gcm_test_case_192_6);
8182 test_AES_GCM_auth_decryption_test_case_192_7(void)
8184 return test_authenticated_decryption(&gcm_test_case_192_7);
8188 test_AES_GCM_auth_decryption_test_case_256_1(void)
8190 return test_authenticated_decryption(&gcm_test_case_256_1);
8194 test_AES_GCM_auth_decryption_test_case_256_2(void)
8196 return test_authenticated_decryption(&gcm_test_case_256_2);
8200 test_AES_GCM_auth_decryption_test_case_256_3(void)
8202 return test_authenticated_decryption(&gcm_test_case_256_3);
8206 test_AES_GCM_auth_decryption_test_case_256_4(void)
8208 return test_authenticated_decryption(&gcm_test_case_256_4);
8212 test_AES_GCM_auth_decryption_test_case_256_5(void)
8214 return test_authenticated_decryption(&gcm_test_case_256_5);
8218 test_AES_GCM_auth_decryption_test_case_256_6(void)
8220 return test_authenticated_decryption(&gcm_test_case_256_6);
8224 test_AES_GCM_auth_decryption_test_case_256_7(void)
8226 return test_authenticated_decryption(&gcm_test_case_256_7);
8230 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8232 return test_authenticated_decryption(&gcm_test_case_aad_1);
8236 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8238 return test_authenticated_decryption(&gcm_test_case_aad_2);
8242 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8244 struct aead_test_data tdata;
8247 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8248 tdata.iv.data[0] += 1;
8249 res = test_authenticated_decryption(&tdata);
8250 if (res == -ENOTSUP)
8252 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8253 return TEST_SUCCESS;
8257 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8259 struct aead_test_data tdata;
8262 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8263 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8264 tdata.plaintext.data[0] += 1;
8265 res = test_authenticated_decryption(&tdata);
8266 if (res == -ENOTSUP)
8268 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8269 return TEST_SUCCESS;
8273 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8275 struct aead_test_data tdata;
8278 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8279 tdata.ciphertext.data[0] += 1;
8280 res = test_authenticated_decryption(&tdata);
8281 if (res == -ENOTSUP)
8283 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8284 return TEST_SUCCESS;
8288 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8290 struct aead_test_data tdata;
8293 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
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_aad_corrupt(void)
8305 struct aead_test_data tdata;
8306 uint8_t aad[gcm_test_case_7.aad.len];
8309 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8310 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8312 tdata.aad.data = aad;
8313 res = test_authenticated_decryption(&tdata);
8314 if (res == -ENOTSUP)
8316 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8317 return TEST_SUCCESS;
8321 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8323 struct aead_test_data tdata;
8326 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8327 tdata.auth_tag.data[0] += 1;
8328 res = test_authenticated_decryption(&tdata);
8329 if (res == -ENOTSUP)
8331 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8332 return TEST_SUCCESS;
8336 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8338 struct crypto_testsuite_params *ts_params = &testsuite_params;
8339 struct crypto_unittest_params *ut_params = &unittest_params;
8342 uint8_t *ciphertext, *auth_tag;
8343 uint16_t plaintext_pad_len;
8345 /* Verify the capabilities */
8346 struct rte_cryptodev_sym_capability_idx cap_idx;
8347 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8348 cap_idx.algo.aead = tdata->algo;
8349 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8353 /* not supported with CPU crypto */
8354 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8357 /* Create AEAD session */
8358 retval = create_aead_session(ts_params->valid_devs[0],
8360 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8361 tdata->key.data, tdata->key.len,
8362 tdata->aad.len, tdata->auth_tag.len,
8367 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8368 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8370 /* clear mbuf payload */
8371 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8372 rte_pktmbuf_tailroom(ut_params->ibuf));
8373 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8374 rte_pktmbuf_tailroom(ut_params->obuf));
8376 /* Create AEAD operation */
8377 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8381 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8383 ut_params->op->sym->m_src = ut_params->ibuf;
8384 ut_params->op->sym->m_dst = ut_params->obuf;
8386 /* Process crypto operation */
8387 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8388 ut_params->op), "failed to process sym crypto op");
8390 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8391 "crypto op processing failed");
8393 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8395 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8396 ut_params->op->sym->cipher.data.offset);
8397 auth_tag = ciphertext + plaintext_pad_len;
8399 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8400 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8403 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8405 tdata->ciphertext.data,
8406 tdata->ciphertext.len,
8407 "Ciphertext data not as expected");
8409 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8411 tdata->auth_tag.data,
8412 tdata->auth_tag.len,
8413 "Generated auth tag not as expected");
8420 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8422 return test_authenticated_encryption_oop(&gcm_test_case_5);
8426 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8428 struct crypto_testsuite_params *ts_params = &testsuite_params;
8429 struct crypto_unittest_params *ut_params = &unittest_params;
8434 /* Verify the capabilities */
8435 struct rte_cryptodev_sym_capability_idx cap_idx;
8436 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8437 cap_idx.algo.aead = tdata->algo;
8438 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8442 /* not supported with CPU crypto */
8443 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8446 /* Create AEAD session */
8447 retval = create_aead_session(ts_params->valid_devs[0],
8449 RTE_CRYPTO_AEAD_OP_DECRYPT,
8450 tdata->key.data, tdata->key.len,
8451 tdata->aad.len, tdata->auth_tag.len,
8456 /* alloc mbuf and set payload */
8457 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8458 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8461 rte_pktmbuf_tailroom(ut_params->ibuf));
8462 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8463 rte_pktmbuf_tailroom(ut_params->obuf));
8465 /* Create AEAD operation */
8466 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8470 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8472 ut_params->op->sym->m_src = ut_params->ibuf;
8473 ut_params->op->sym->m_dst = ut_params->obuf;
8475 /* Process crypto operation */
8476 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8477 ut_params->op), "failed to process sym crypto op");
8479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8480 "crypto op processing failed");
8482 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8483 ut_params->op->sym->cipher.data.offset);
8485 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8490 tdata->plaintext.data,
8491 tdata->plaintext.len,
8492 "Plaintext data not as expected");
8494 TEST_ASSERT_EQUAL(ut_params->op->status,
8495 RTE_CRYPTO_OP_STATUS_SUCCESS,
8496 "Authentication failed");
8501 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8503 return test_authenticated_decryption_oop(&gcm_test_case_5);
8507 test_authenticated_encryption_sessionless(
8508 const struct aead_test_data *tdata)
8510 struct crypto_testsuite_params *ts_params = &testsuite_params;
8511 struct crypto_unittest_params *ut_params = &unittest_params;
8514 uint8_t *ciphertext, *auth_tag;
8515 uint16_t plaintext_pad_len;
8516 uint8_t key[tdata->key.len + 1];
8517 struct rte_cryptodev_info dev_info;
8519 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8520 uint64_t feat_flags = dev_info.feature_flags;
8522 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8523 printf("Device doesn't support Sessionless ops.\n");
8527 /* not supported with CPU crypto */
8528 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8531 /* Verify the capabilities */
8532 struct rte_cryptodev_sym_capability_idx cap_idx;
8533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8534 cap_idx.algo.aead = tdata->algo;
8535 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8539 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8541 /* clear mbuf payload */
8542 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8543 rte_pktmbuf_tailroom(ut_params->ibuf));
8545 /* Create AEAD operation */
8546 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8550 /* Create GCM xform */
8551 memcpy(key, tdata->key.data, tdata->key.len);
8552 retval = create_aead_xform(ut_params->op,
8554 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8555 key, tdata->key.len,
8556 tdata->aad.len, tdata->auth_tag.len,
8561 ut_params->op->sym->m_src = ut_params->ibuf;
8563 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8564 RTE_CRYPTO_OP_SESSIONLESS,
8565 "crypto op session type not sessionless");
8567 /* Process crypto operation */
8568 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8569 ut_params->op), "failed to process sym crypto op");
8571 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8573 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8574 "crypto op status not success");
8576 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8578 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8579 ut_params->op->sym->cipher.data.offset);
8580 auth_tag = ciphertext + plaintext_pad_len;
8582 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8583 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8586 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8588 tdata->ciphertext.data,
8589 tdata->ciphertext.len,
8590 "Ciphertext data not as expected");
8592 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8594 tdata->auth_tag.data,
8595 tdata->auth_tag.len,
8596 "Generated auth tag not as expected");
8603 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8605 return test_authenticated_encryption_sessionless(
8610 test_authenticated_decryption_sessionless(
8611 const struct aead_test_data *tdata)
8613 struct crypto_testsuite_params *ts_params = &testsuite_params;
8614 struct crypto_unittest_params *ut_params = &unittest_params;
8618 uint8_t key[tdata->key.len + 1];
8619 struct rte_cryptodev_info dev_info;
8621 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8622 uint64_t feat_flags = dev_info.feature_flags;
8624 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8625 printf("Device doesn't support Sessionless ops.\n");
8629 /* not supported with CPU crypto */
8630 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8633 /* Verify the capabilities */
8634 struct rte_cryptodev_sym_capability_idx cap_idx;
8635 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8636 cap_idx.algo.aead = tdata->algo;
8637 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8641 /* alloc mbuf and set payload */
8642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8644 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8645 rte_pktmbuf_tailroom(ut_params->ibuf));
8647 /* Create AEAD operation */
8648 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8652 /* Create AEAD xform */
8653 memcpy(key, tdata->key.data, tdata->key.len);
8654 retval = create_aead_xform(ut_params->op,
8656 RTE_CRYPTO_AEAD_OP_DECRYPT,
8657 key, tdata->key.len,
8658 tdata->aad.len, tdata->auth_tag.len,
8663 ut_params->op->sym->m_src = ut_params->ibuf;
8665 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8666 RTE_CRYPTO_OP_SESSIONLESS,
8667 "crypto op session type not sessionless");
8669 /* Process crypto operation */
8670 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8671 ut_params->op), "failed to process sym crypto op");
8673 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8675 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8676 "crypto op status not success");
8678 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8679 ut_params->op->sym->cipher.data.offset);
8681 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8684 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8686 tdata->plaintext.data,
8687 tdata->plaintext.len,
8688 "Plaintext data not as expected");
8690 TEST_ASSERT_EQUAL(ut_params->op->status,
8691 RTE_CRYPTO_OP_STATUS_SUCCESS,
8692 "Authentication failed");
8697 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8699 return test_authenticated_decryption_sessionless(
8704 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8706 return test_authenticated_encryption(&ccm_test_case_128_1);
8710 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8712 return test_authenticated_encryption(&ccm_test_case_128_2);
8716 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8718 return test_authenticated_encryption(&ccm_test_case_128_3);
8722 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8724 return test_authenticated_decryption(&ccm_test_case_128_1);
8728 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8730 return test_authenticated_decryption(&ccm_test_case_128_2);
8734 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8736 return test_authenticated_decryption(&ccm_test_case_128_3);
8740 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8742 return test_authenticated_encryption(&ccm_test_case_192_1);
8746 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8748 return test_authenticated_encryption(&ccm_test_case_192_2);
8752 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8754 return test_authenticated_encryption(&ccm_test_case_192_3);
8758 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8760 return test_authenticated_decryption(&ccm_test_case_192_1);
8764 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8766 return test_authenticated_decryption(&ccm_test_case_192_2);
8770 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8772 return test_authenticated_decryption(&ccm_test_case_192_3);
8776 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8778 return test_authenticated_encryption(&ccm_test_case_256_1);
8782 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8784 return test_authenticated_encryption(&ccm_test_case_256_2);
8788 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8790 return test_authenticated_encryption(&ccm_test_case_256_3);
8794 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8796 return test_authenticated_decryption(&ccm_test_case_256_1);
8800 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8802 return test_authenticated_decryption(&ccm_test_case_256_2);
8806 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8808 return test_authenticated_decryption(&ccm_test_case_256_3);
8814 struct crypto_testsuite_params *ts_params = &testsuite_params;
8815 struct rte_cryptodev_stats stats;
8816 struct rte_cryptodev *dev;
8817 cryptodev_stats_get_t temp_pfn;
8819 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8822 /* Verify the capabilities */
8823 struct rte_cryptodev_sym_capability_idx cap_idx;
8824 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8825 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8826 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8829 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8830 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8831 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8835 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8836 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8837 &stats) == -ENODEV),
8838 "rte_cryptodev_stats_get invalid dev failed");
8839 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8840 "rte_cryptodev_stats_get invalid Param failed");
8841 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8842 temp_pfn = dev->dev_ops->stats_get;
8843 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8844 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8846 "rte_cryptodev_stats_get invalid Param failed");
8847 dev->dev_ops->stats_get = temp_pfn;
8849 /* Test expected values */
8851 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8853 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8855 "rte_cryptodev_stats_get failed");
8856 TEST_ASSERT((stats.enqueued_count == 1),
8857 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8858 TEST_ASSERT((stats.dequeued_count == 1),
8859 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8860 TEST_ASSERT((stats.enqueue_err_count == 0),
8861 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8862 TEST_ASSERT((stats.dequeue_err_count == 0),
8863 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8865 /* invalid device but should ignore and not reset device stats*/
8866 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8867 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8869 "rte_cryptodev_stats_get failed");
8870 TEST_ASSERT((stats.enqueued_count == 1),
8871 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8873 /* check that a valid reset clears stats */
8874 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8875 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8877 "rte_cryptodev_stats_get failed");
8878 TEST_ASSERT((stats.enqueued_count == 0),
8879 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8880 TEST_ASSERT((stats.dequeued_count == 0),
8881 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8883 return TEST_SUCCESS;
8886 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8887 struct crypto_unittest_params *ut_params,
8888 enum rte_crypto_auth_operation op,
8889 const struct HMAC_MD5_vector *test_case)
8893 memcpy(key, test_case->key.data, test_case->key.len);
8895 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8896 ut_params->auth_xform.next = NULL;
8897 ut_params->auth_xform.auth.op = op;
8899 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8901 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8902 ut_params->auth_xform.auth.key.length = test_case->key.len;
8903 ut_params->auth_xform.auth.key.data = key;
8905 ut_params->sess = rte_cryptodev_sym_session_create(
8906 ts_params->session_mpool);
8908 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8909 ut_params->sess, &ut_params->auth_xform,
8910 ts_params->session_priv_mpool);
8912 if (ut_params->sess == NULL)
8915 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8917 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8918 rte_pktmbuf_tailroom(ut_params->ibuf));
8923 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8924 const struct HMAC_MD5_vector *test_case,
8925 uint8_t **plaintext)
8927 uint16_t plaintext_pad_len;
8929 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8931 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8934 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8936 memcpy(*plaintext, test_case->plaintext.data,
8937 test_case->plaintext.len);
8939 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8940 ut_params->ibuf, MD5_DIGEST_LEN);
8941 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8942 "no room to append digest");
8943 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8944 ut_params->ibuf, plaintext_pad_len);
8946 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8947 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8948 test_case->auth_tag.len);
8951 sym_op->auth.data.offset = 0;
8952 sym_op->auth.data.length = test_case->plaintext.len;
8954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8955 ut_params->op->sym->m_src = ut_params->ibuf;
8961 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8963 uint16_t plaintext_pad_len;
8964 uint8_t *plaintext, *auth_tag;
8966 struct crypto_testsuite_params *ts_params = &testsuite_params;
8967 struct crypto_unittest_params *ut_params = &unittest_params;
8969 /* Verify the capabilities */
8970 struct rte_cryptodev_sym_capability_idx cap_idx;
8971 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8972 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8973 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8977 if (MD5_HMAC_create_session(ts_params, ut_params,
8978 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8981 /* Generate Crypto op data structure */
8982 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8983 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8984 TEST_ASSERT_NOT_NULL(ut_params->op,
8985 "Failed to allocate symmetric crypto operation struct");
8987 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8990 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8993 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8994 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8997 TEST_ASSERT_NOT_NULL(
8998 process_crypto_request(ts_params->valid_devs[0],
9000 "failed to process sym crypto op");
9002 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9003 "crypto op processing failed");
9005 if (ut_params->op->sym->m_dst) {
9006 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9007 uint8_t *, plaintext_pad_len);
9009 auth_tag = plaintext + plaintext_pad_len;
9012 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9014 test_case->auth_tag.data,
9015 test_case->auth_tag.len,
9016 "HMAC_MD5 generated tag not as expected");
9018 return TEST_SUCCESS;
9022 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9026 struct crypto_testsuite_params *ts_params = &testsuite_params;
9027 struct crypto_unittest_params *ut_params = &unittest_params;
9029 /* Verify the capabilities */
9030 struct rte_cryptodev_sym_capability_idx cap_idx;
9031 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9032 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9033 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9037 if (MD5_HMAC_create_session(ts_params, ut_params,
9038 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9042 /* Generate Crypto op data structure */
9043 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9044 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9045 TEST_ASSERT_NOT_NULL(ut_params->op,
9046 "Failed to allocate symmetric crypto operation struct");
9048 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9051 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9052 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9055 TEST_ASSERT_NOT_NULL(
9056 process_crypto_request(ts_params->valid_devs[0],
9058 "failed to process sym crypto op");
9060 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9061 "HMAC_MD5 crypto op processing failed");
9063 return TEST_SUCCESS;
9067 test_MD5_HMAC_generate_case_1(void)
9069 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9073 test_MD5_HMAC_verify_case_1(void)
9075 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9079 test_MD5_HMAC_generate_case_2(void)
9081 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9085 test_MD5_HMAC_verify_case_2(void)
9087 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9091 test_multi_session(void)
9093 struct crypto_testsuite_params *ts_params = &testsuite_params;
9094 struct crypto_unittest_params *ut_params = &unittest_params;
9096 struct rte_cryptodev_info dev_info;
9097 struct rte_cryptodev_sym_session **sessions;
9101 /* Verify the capabilities */
9102 struct rte_cryptodev_sym_capability_idx cap_idx;
9103 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9104 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9105 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9108 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9109 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9110 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9114 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9115 aes_cbc_key, hmac_sha512_key);
9118 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9120 sessions = rte_malloc(NULL,
9121 (sizeof(struct rte_cryptodev_sym_session *) *
9122 MAX_NB_SESSIONS) + 1, 0);
9124 /* Create multiple crypto sessions*/
9125 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9127 sessions[i] = rte_cryptodev_sym_session_create(
9128 ts_params->session_mpool);
9130 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9131 sessions[i], &ut_params->auth_xform,
9132 ts_params->session_priv_mpool);
9133 TEST_ASSERT_NOT_NULL(sessions[i],
9134 "Session creation failed at session number %u",
9137 /* Attempt to send a request on each session */
9138 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9142 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9143 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9145 "Failed to perform decrypt on request number %u.", i);
9146 /* free crypto operation structure */
9148 rte_crypto_op_free(ut_params->op);
9151 * free mbuf - both obuf and ibuf are usually the same,
9152 * so check if they point at the same address is necessary,
9153 * to avoid freeing the mbuf twice.
9155 if (ut_params->obuf) {
9156 rte_pktmbuf_free(ut_params->obuf);
9157 if (ut_params->ibuf == ut_params->obuf)
9158 ut_params->ibuf = 0;
9159 ut_params->obuf = 0;
9161 if (ut_params->ibuf) {
9162 rte_pktmbuf_free(ut_params->ibuf);
9163 ut_params->ibuf = 0;
9167 /* Next session create should fail */
9168 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9169 sessions[i], &ut_params->auth_xform,
9170 ts_params->session_priv_mpool);
9171 TEST_ASSERT_NULL(sessions[i],
9172 "Session creation succeeded unexpectedly!");
9174 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9175 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9177 rte_cryptodev_sym_session_free(sessions[i]);
9182 return TEST_SUCCESS;
9185 struct multi_session_params {
9186 struct crypto_unittest_params ut_params;
9187 uint8_t *cipher_key;
9189 const uint8_t *cipher;
9190 const uint8_t *digest;
9194 #define MB_SESSION_NUMBER 3
9197 test_multi_session_random_usage(void)
9199 struct crypto_testsuite_params *ts_params = &testsuite_params;
9200 struct rte_cryptodev_info dev_info;
9201 struct rte_cryptodev_sym_session **sessions;
9203 struct multi_session_params ut_paramz[] = {
9206 .cipher_key = ms_aes_cbc_key0,
9207 .hmac_key = ms_hmac_key0,
9208 .cipher = ms_aes_cbc_cipher0,
9209 .digest = ms_hmac_digest0,
9210 .iv = ms_aes_cbc_iv0
9213 .cipher_key = ms_aes_cbc_key1,
9214 .hmac_key = ms_hmac_key1,
9215 .cipher = ms_aes_cbc_cipher1,
9216 .digest = ms_hmac_digest1,
9217 .iv = ms_aes_cbc_iv1
9220 .cipher_key = ms_aes_cbc_key2,
9221 .hmac_key = ms_hmac_key2,
9222 .cipher = ms_aes_cbc_cipher2,
9223 .digest = ms_hmac_digest2,
9224 .iv = ms_aes_cbc_iv2
9229 /* Verify the capabilities */
9230 struct rte_cryptodev_sym_capability_idx cap_idx;
9231 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9232 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9233 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9236 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9237 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9238 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9242 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9244 sessions = rte_malloc(NULL,
9245 (sizeof(struct rte_cryptodev_sym_session *)
9246 * MAX_NB_SESSIONS) + 1, 0);
9248 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9249 sessions[i] = rte_cryptodev_sym_session_create(
9250 ts_params->session_mpool);
9252 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9253 sizeof(struct crypto_unittest_params));
9255 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9256 &ut_paramz[i].ut_params,
9257 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9259 /* Create multiple crypto sessions*/
9260 rte_cryptodev_sym_session_init(
9261 ts_params->valid_devs[0],
9263 &ut_paramz[i].ut_params.auth_xform,
9264 ts_params->session_priv_mpool);
9266 TEST_ASSERT_NOT_NULL(sessions[i],
9267 "Session creation failed at session number %u",
9273 for (i = 0; i < 40000; i++) {
9275 j = rand() % MB_SESSION_NUMBER;
9277 TEST_ASSERT_SUCCESS(
9278 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9280 &ut_paramz[j].ut_params,
9281 ts_params, ut_paramz[j].cipher,
9282 ut_paramz[j].digest,
9284 "Failed to perform decrypt on request number %u.", i);
9286 if (ut_paramz[j].ut_params.op)
9287 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9290 * free mbuf - both obuf and ibuf are usually the same,
9291 * so check if they point at the same address is necessary,
9292 * to avoid freeing the mbuf twice.
9294 if (ut_paramz[j].ut_params.obuf) {
9295 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9296 if (ut_paramz[j].ut_params.ibuf
9297 == ut_paramz[j].ut_params.obuf)
9298 ut_paramz[j].ut_params.ibuf = 0;
9299 ut_paramz[j].ut_params.obuf = 0;
9301 if (ut_paramz[j].ut_params.ibuf) {
9302 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9303 ut_paramz[j].ut_params.ibuf = 0;
9307 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9308 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9310 rte_cryptodev_sym_session_free(sessions[i]);
9315 return TEST_SUCCESS;
9319 test_null_cipher_only_operation(void)
9321 struct crypto_testsuite_params *ts_params = &testsuite_params;
9322 struct crypto_unittest_params *ut_params = &unittest_params;
9324 /* Verify the capabilities */
9325 struct rte_cryptodev_sym_capability_idx cap_idx;
9326 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9327 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9328 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9332 /* Generate test mbuf data and space for digest */
9333 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9334 catch_22_quote, QUOTE_512_BYTES, 0);
9336 /* Setup Cipher Parameters */
9337 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9338 ut_params->cipher_xform.next = NULL;
9340 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9341 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9343 ut_params->sess = rte_cryptodev_sym_session_create(
9344 ts_params->session_mpool);
9346 /* Create Crypto session*/
9347 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9349 &ut_params->cipher_xform,
9350 ts_params->session_priv_mpool);
9351 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9353 /* Generate Crypto op data structure */
9354 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9355 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9356 TEST_ASSERT_NOT_NULL(ut_params->op,
9357 "Failed to allocate symmetric crypto operation struct");
9359 /* Set crypto operation data parameters */
9360 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9362 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9364 /* set crypto operation source mbuf */
9365 sym_op->m_src = ut_params->ibuf;
9367 sym_op->cipher.data.offset = 0;
9368 sym_op->cipher.data.length = QUOTE_512_BYTES;
9370 /* Process crypto operation */
9371 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9373 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9375 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9376 "crypto operation processing failed");
9379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9380 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9383 "Ciphertext data not as expected");
9385 return TEST_SUCCESS;
9387 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9388 0xab, 0xab, 0xab, 0xab,
9389 0xab, 0xab, 0xab, 0xab,
9390 0xab, 0xab, 0xab, 0xab};
9392 test_null_auth_only_operation(void)
9394 struct crypto_testsuite_params *ts_params = &testsuite_params;
9395 struct crypto_unittest_params *ut_params = &unittest_params;
9398 /* Verify the capabilities */
9399 struct rte_cryptodev_sym_capability_idx cap_idx;
9400 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9401 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9402 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9406 /* Generate test mbuf data and space for digest */
9407 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9408 catch_22_quote, QUOTE_512_BYTES, 0);
9410 /* create a pointer for digest, but don't expect anything to be written
9411 * here in a NULL auth algo so no mbuf append done.
9413 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9415 /* prefill the memory pointed to by digest */
9416 memcpy(digest, orig_data, sizeof(orig_data));
9418 /* Setup HMAC Parameters */
9419 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9420 ut_params->auth_xform.next = NULL;
9422 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9423 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9425 ut_params->sess = rte_cryptodev_sym_session_create(
9426 ts_params->session_mpool);
9428 /* Create Crypto session*/
9429 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9430 ut_params->sess, &ut_params->auth_xform,
9431 ts_params->session_priv_mpool);
9432 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9434 /* Generate Crypto op data structure */
9435 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9436 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9437 TEST_ASSERT_NOT_NULL(ut_params->op,
9438 "Failed to allocate symmetric crypto operation struct");
9440 /* Set crypto operation data parameters */
9441 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9443 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9445 sym_op->m_src = ut_params->ibuf;
9447 sym_op->auth.data.offset = 0;
9448 sym_op->auth.data.length = QUOTE_512_BYTES;
9449 sym_op->auth.digest.data = digest;
9450 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9453 /* Process crypto operation */
9454 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9456 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9458 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9459 "crypto operation processing failed");
9460 /* Make sure memory pointed to by digest hasn't been overwritten */
9461 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9465 "Memory at digest ptr overwritten unexpectedly");
9467 return TEST_SUCCESS;
9472 test_null_cipher_auth_operation(void)
9474 struct crypto_testsuite_params *ts_params = &testsuite_params;
9475 struct crypto_unittest_params *ut_params = &unittest_params;
9478 /* Verify the capabilities */
9479 struct rte_cryptodev_sym_capability_idx cap_idx;
9480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9481 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9482 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9485 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9486 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9487 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9491 /* Generate test mbuf data and space for digest */
9492 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9493 catch_22_quote, QUOTE_512_BYTES, 0);
9495 /* create a pointer for digest, but don't expect anything to be written
9496 * here in a NULL auth algo so no mbuf append done.
9498 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9500 /* prefill the memory pointed to by digest */
9501 memcpy(digest, orig_data, sizeof(orig_data));
9503 /* Setup Cipher Parameters */
9504 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9505 ut_params->cipher_xform.next = &ut_params->auth_xform;
9507 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9508 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9510 /* Setup HMAC Parameters */
9511 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9512 ut_params->auth_xform.next = NULL;
9514 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9515 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9517 ut_params->sess = rte_cryptodev_sym_session_create(
9518 ts_params->session_mpool);
9520 /* Create Crypto session*/
9521 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9522 ut_params->sess, &ut_params->cipher_xform,
9523 ts_params->session_priv_mpool);
9524 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9526 /* Generate Crypto op data structure */
9527 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9528 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9529 TEST_ASSERT_NOT_NULL(ut_params->op,
9530 "Failed to allocate symmetric crypto operation struct");
9532 /* Set crypto operation data parameters */
9533 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9535 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9537 sym_op->m_src = ut_params->ibuf;
9539 sym_op->cipher.data.offset = 0;
9540 sym_op->cipher.data.length = QUOTE_512_BYTES;
9542 sym_op->auth.data.offset = 0;
9543 sym_op->auth.data.length = QUOTE_512_BYTES;
9544 sym_op->auth.digest.data = digest;
9545 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9548 /* Process crypto operation */
9549 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9551 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9553 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9554 "crypto operation processing failed");
9557 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9558 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9561 "Ciphertext data not as expected");
9562 /* Make sure memory pointed to by digest hasn't been overwritten */
9563 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9567 "Memory at digest ptr overwritten unexpectedly");
9569 return TEST_SUCCESS;
9573 test_null_auth_cipher_operation(void)
9575 struct crypto_testsuite_params *ts_params = &testsuite_params;
9576 struct crypto_unittest_params *ut_params = &unittest_params;
9579 /* Verify the capabilities */
9580 struct rte_cryptodev_sym_capability_idx cap_idx;
9581 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9582 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9583 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9586 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9587 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9588 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9592 /* Generate test mbuf data */
9593 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9594 catch_22_quote, QUOTE_512_BYTES, 0);
9596 /* create a pointer for digest, but don't expect anything to be written
9597 * here in a NULL auth algo so no mbuf append done.
9599 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9601 /* prefill the memory pointed to by digest */
9602 memcpy(digest, orig_data, sizeof(orig_data));
9604 /* Setup Cipher Parameters */
9605 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9606 ut_params->cipher_xform.next = NULL;
9608 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9609 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9611 /* Setup HMAC Parameters */
9612 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9613 ut_params->auth_xform.next = &ut_params->cipher_xform;
9615 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9616 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9618 ut_params->sess = rte_cryptodev_sym_session_create(
9619 ts_params->session_mpool);
9621 /* Create Crypto session*/
9622 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9623 ut_params->sess, &ut_params->cipher_xform,
9624 ts_params->session_priv_mpool);
9625 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9627 /* Generate Crypto op data structure */
9628 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9629 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9630 TEST_ASSERT_NOT_NULL(ut_params->op,
9631 "Failed to allocate symmetric crypto operation struct");
9633 /* Set crypto operation data parameters */
9634 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9636 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9638 sym_op->m_src = ut_params->ibuf;
9640 sym_op->cipher.data.offset = 0;
9641 sym_op->cipher.data.length = QUOTE_512_BYTES;
9643 sym_op->auth.data.offset = 0;
9644 sym_op->auth.data.length = QUOTE_512_BYTES;
9645 sym_op->auth.digest.data = digest;
9646 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9649 /* Process crypto operation */
9650 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9652 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9654 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9655 "crypto operation processing failed");
9658 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9659 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9662 "Ciphertext data not as expected");
9663 /* Make sure memory pointed to by digest hasn't been overwritten */
9664 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9668 "Memory at digest ptr overwritten unexpectedly");
9670 return TEST_SUCCESS;
9675 test_null_invalid_operation(void)
9677 struct crypto_testsuite_params *ts_params = &testsuite_params;
9678 struct crypto_unittest_params *ut_params = &unittest_params;
9681 /* This test is for NULL PMD only */
9682 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9683 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9686 /* Setup Cipher Parameters */
9687 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9688 ut_params->cipher_xform.next = NULL;
9690 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9691 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
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->cipher_xform,
9699 ts_params->session_priv_mpool);
9700 TEST_ASSERT(ret < 0,
9701 "Session creation succeeded unexpectedly");
9704 /* Setup HMAC Parameters */
9705 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9706 ut_params->auth_xform.next = NULL;
9708 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9709 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9711 ut_params->sess = rte_cryptodev_sym_session_create(
9712 ts_params->session_mpool);
9714 /* Create Crypto session*/
9715 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9716 ut_params->sess, &ut_params->auth_xform,
9717 ts_params->session_priv_mpool);
9718 TEST_ASSERT(ret < 0,
9719 "Session creation succeeded unexpectedly");
9721 return TEST_SUCCESS;
9725 #define NULL_BURST_LENGTH (32)
9728 test_null_burst_operation(void)
9730 struct crypto_testsuite_params *ts_params = &testsuite_params;
9731 struct crypto_unittest_params *ut_params = &unittest_params;
9733 unsigned i, burst_len = NULL_BURST_LENGTH;
9735 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9736 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9738 /* This test is for NULL PMD only */
9739 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9740 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9743 /* Setup Cipher Parameters */
9744 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9745 ut_params->cipher_xform.next = &ut_params->auth_xform;
9747 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9748 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9750 /* Setup HMAC Parameters */
9751 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9752 ut_params->auth_xform.next = NULL;
9754 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9755 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9757 ut_params->sess = rte_cryptodev_sym_session_create(
9758 ts_params->session_mpool);
9760 /* Create Crypto session*/
9761 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9762 ut_params->sess, &ut_params->cipher_xform,
9763 ts_params->session_priv_mpool);
9764 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9766 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9767 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9768 burst_len, "failed to generate burst of crypto ops");
9770 /* Generate an operation for each mbuf in burst */
9771 for (i = 0; i < burst_len; i++) {
9772 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9774 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9776 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9780 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9782 burst[i]->sym->m_src = m;
9785 /* Process crypto operation */
9786 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9787 0, burst, burst_len),
9789 "Error enqueuing burst");
9791 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9792 0, burst_dequeued, burst_len),
9794 "Error dequeuing burst");
9797 for (i = 0; i < burst_len; i++) {
9799 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9800 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9802 "data not as expected");
9804 rte_pktmbuf_free(burst[i]->sym->m_src);
9805 rte_crypto_op_free(burst[i]);
9808 return TEST_SUCCESS;
9812 generate_gmac_large_plaintext(uint8_t *data)
9816 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9817 memcpy(&data[i], &data[0], 32);
9821 create_gmac_operation(enum rte_crypto_auth_operation op,
9822 const struct gmac_test_data *tdata)
9824 struct crypto_testsuite_params *ts_params = &testsuite_params;
9825 struct crypto_unittest_params *ut_params = &unittest_params;
9826 struct rte_crypto_sym_op *sym_op;
9828 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9830 /* Generate Crypto op data structure */
9831 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9832 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9833 TEST_ASSERT_NOT_NULL(ut_params->op,
9834 "Failed to allocate symmetric crypto operation struct");
9836 sym_op = ut_params->op->sym;
9838 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9839 ut_params->ibuf, tdata->gmac_tag.len);
9840 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9841 "no room to append digest");
9843 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9844 ut_params->ibuf, plaintext_pad_len);
9846 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9847 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9848 tdata->gmac_tag.len);
9849 debug_hexdump(stdout, "digest:",
9850 sym_op->auth.digest.data,
9851 tdata->gmac_tag.len);
9854 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9855 uint8_t *, IV_OFFSET);
9857 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9859 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9861 sym_op->cipher.data.length = 0;
9862 sym_op->cipher.data.offset = 0;
9864 sym_op->auth.data.offset = 0;
9865 sym_op->auth.data.length = tdata->plaintext.len;
9870 static int create_gmac_session(uint8_t dev_id,
9871 const struct gmac_test_data *tdata,
9872 enum rte_crypto_auth_operation auth_op)
9874 uint8_t auth_key[tdata->key.len];
9876 struct crypto_testsuite_params *ts_params = &testsuite_params;
9877 struct crypto_unittest_params *ut_params = &unittest_params;
9879 memcpy(auth_key, tdata->key.data, tdata->key.len);
9881 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9882 ut_params->auth_xform.next = NULL;
9884 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9885 ut_params->auth_xform.auth.op = auth_op;
9886 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9887 ut_params->auth_xform.auth.key.length = tdata->key.len;
9888 ut_params->auth_xform.auth.key.data = auth_key;
9889 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9890 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9893 ut_params->sess = rte_cryptodev_sym_session_create(
9894 ts_params->session_mpool);
9896 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9897 &ut_params->auth_xform,
9898 ts_params->session_priv_mpool);
9900 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9906 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9908 struct crypto_testsuite_params *ts_params = &testsuite_params;
9909 struct crypto_unittest_params *ut_params = &unittest_params;
9913 uint8_t *auth_tag, *plaintext;
9914 uint16_t plaintext_pad_len;
9916 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9917 "No GMAC length in the source data");
9919 /* Verify the capabilities */
9920 struct rte_cryptodev_sym_capability_idx cap_idx;
9921 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9922 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9923 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9927 retval = create_gmac_session(ts_params->valid_devs[0],
9928 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9933 if (tdata->plaintext.len > MBUF_SIZE)
9934 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9937 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9938 "Failed to allocate input buffer in mempool");
9940 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9941 rte_pktmbuf_tailroom(ut_params->ibuf));
9943 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9945 * Runtime generate the large plain text instead of use hard code
9946 * plain text vector. It is done to avoid create huge source file
9947 * with the test vector.
9949 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9950 generate_gmac_large_plaintext(tdata->plaintext.data);
9952 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9954 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9956 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9957 debug_hexdump(stdout, "plaintext:", plaintext,
9958 tdata->plaintext.len);
9960 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9966 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9968 ut_params->op->sym->m_src = ut_params->ibuf;
9970 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9971 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9974 TEST_ASSERT_NOT_NULL(
9975 process_crypto_request(ts_params->valid_devs[0],
9976 ut_params->op), "failed to process sym crypto op");
9978 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9979 "crypto op processing failed");
9981 if (ut_params->op->sym->m_dst) {
9982 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9983 uint8_t *, plaintext_pad_len);
9985 auth_tag = plaintext + plaintext_pad_len;
9988 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9990 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9992 tdata->gmac_tag.data,
9993 tdata->gmac_tag.len,
9994 "GMAC Generated auth tag not as expected");
10000 test_AES_GMAC_authentication_test_case_1(void)
10002 return test_AES_GMAC_authentication(&gmac_test_case_1);
10006 test_AES_GMAC_authentication_test_case_2(void)
10008 return test_AES_GMAC_authentication(&gmac_test_case_2);
10012 test_AES_GMAC_authentication_test_case_3(void)
10014 return test_AES_GMAC_authentication(&gmac_test_case_3);
10018 test_AES_GMAC_authentication_test_case_4(void)
10020 return test_AES_GMAC_authentication(&gmac_test_case_4);
10024 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10026 struct crypto_testsuite_params *ts_params = &testsuite_params;
10027 struct crypto_unittest_params *ut_params = &unittest_params;
10029 uint32_t plaintext_pad_len;
10030 uint8_t *plaintext;
10032 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10033 "No GMAC length in the source data");
10035 /* Verify the capabilities */
10036 struct rte_cryptodev_sym_capability_idx cap_idx;
10037 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10038 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10039 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10043 retval = create_gmac_session(ts_params->valid_devs[0],
10044 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10049 if (tdata->plaintext.len > MBUF_SIZE)
10050 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10052 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10053 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10054 "Failed to allocate input buffer in mempool");
10056 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10057 rte_pktmbuf_tailroom(ut_params->ibuf));
10059 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10062 * Runtime generate the large plain text instead of use hard code
10063 * plain text vector. It is done to avoid create huge source file
10064 * with the test vector.
10066 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10067 generate_gmac_large_plaintext(tdata->plaintext.data);
10069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10070 plaintext_pad_len);
10071 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10073 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10074 debug_hexdump(stdout, "plaintext:", plaintext,
10075 tdata->plaintext.len);
10077 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10083 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10085 ut_params->op->sym->m_src = ut_params->ibuf;
10087 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10088 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10091 TEST_ASSERT_NOT_NULL(
10092 process_crypto_request(ts_params->valid_devs[0],
10093 ut_params->op), "failed to process sym crypto op");
10095 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10096 "crypto op processing failed");
10103 test_AES_GMAC_authentication_verify_test_case_1(void)
10105 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10109 test_AES_GMAC_authentication_verify_test_case_2(void)
10111 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10115 test_AES_GMAC_authentication_verify_test_case_3(void)
10117 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10121 test_AES_GMAC_authentication_verify_test_case_4(void)
10123 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10126 struct test_crypto_vector {
10127 enum rte_crypto_cipher_algorithm crypto_algo;
10128 unsigned int cipher_offset;
10129 unsigned int cipher_len;
10142 const uint8_t *data;
10147 const uint8_t *data;
10151 enum rte_crypto_auth_algorithm auth_algo;
10152 unsigned int auth_offset;
10160 const uint8_t *data;
10170 static const struct test_crypto_vector
10171 hmac_sha1_test_crypto_vector = {
10172 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10174 .data = plaintext_hash,
10179 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10180 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10181 0xDE, 0xF4, 0xDE, 0xAD
10187 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10188 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10189 0x3F, 0x91, 0x64, 0x59
10195 static const struct test_crypto_vector
10196 aes128_gmac_test_vector = {
10197 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10199 .data = plaintext_hash,
10204 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10205 0x08, 0x09, 0x0A, 0x0B
10211 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10212 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10218 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10219 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10225 static const struct test_crypto_vector
10226 aes128cbc_hmac_sha1_test_vector = {
10227 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10228 .cipher_offset = 0,
10232 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10233 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10239 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10240 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10245 .data = plaintext_hash,
10249 .data = ciphertext512_aes128cbc,
10252 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10256 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10257 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10258 0xDE, 0xF4, 0xDE, 0xAD
10264 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10265 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10266 0x18, 0x8C, 0x1D, 0x32
10272 static const struct test_crypto_vector
10273 aes128cbc_hmac_sha1_aad_test_vector = {
10274 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10275 .cipher_offset = 12,
10279 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10280 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10286 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10287 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10292 .data = plaintext_hash,
10296 .data = ciphertext512_aes128cbc_aad,
10299 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10303 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10304 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10305 0xDE, 0xF4, 0xDE, 0xAD
10311 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10312 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10313 0x62, 0x8D, 0x62, 0x65
10320 data_corruption(uint8_t *data)
10326 tag_corruption(uint8_t *data, unsigned int tag_offset)
10328 data[tag_offset] += 1;
10332 create_auth_session(struct crypto_unittest_params *ut_params,
10334 const struct test_crypto_vector *reference,
10335 enum rte_crypto_auth_operation auth_op)
10337 struct crypto_testsuite_params *ts_params = &testsuite_params;
10338 uint8_t auth_key[reference->auth_key.len + 1];
10340 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10342 /* Setup Authentication Parameters */
10343 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10344 ut_params->auth_xform.auth.op = auth_op;
10345 ut_params->auth_xform.next = NULL;
10346 ut_params->auth_xform.auth.algo = reference->auth_algo;
10347 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10348 ut_params->auth_xform.auth.key.data = auth_key;
10349 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10351 /* Create Crypto session*/
10352 ut_params->sess = rte_cryptodev_sym_session_create(
10353 ts_params->session_mpool);
10355 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10356 &ut_params->auth_xform,
10357 ts_params->session_priv_mpool);
10359 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10365 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10367 const struct test_crypto_vector *reference,
10368 enum rte_crypto_auth_operation auth_op,
10369 enum rte_crypto_cipher_operation cipher_op)
10371 struct crypto_testsuite_params *ts_params = &testsuite_params;
10372 uint8_t cipher_key[reference->cipher_key.len + 1];
10373 uint8_t auth_key[reference->auth_key.len + 1];
10375 memcpy(cipher_key, reference->cipher_key.data,
10376 reference->cipher_key.len);
10377 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10379 /* Setup Authentication Parameters */
10380 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10381 ut_params->auth_xform.auth.op = auth_op;
10382 ut_params->auth_xform.auth.algo = reference->auth_algo;
10383 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10384 ut_params->auth_xform.auth.key.data = auth_key;
10385 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10387 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10388 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10389 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10391 ut_params->auth_xform.next = &ut_params->cipher_xform;
10393 /* Setup Cipher Parameters */
10394 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10395 ut_params->cipher_xform.next = NULL;
10396 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10397 ut_params->cipher_xform.cipher.op = cipher_op;
10398 ut_params->cipher_xform.cipher.key.data = cipher_key;
10399 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10400 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10401 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10404 /* Create Crypto session*/
10405 ut_params->sess = rte_cryptodev_sym_session_create(
10406 ts_params->session_mpool);
10408 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10409 &ut_params->auth_xform,
10410 ts_params->session_priv_mpool);
10412 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10418 create_auth_operation(struct crypto_testsuite_params *ts_params,
10419 struct crypto_unittest_params *ut_params,
10420 const struct test_crypto_vector *reference,
10421 unsigned int auth_generate)
10423 /* Generate Crypto op data structure */
10424 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10425 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10426 TEST_ASSERT_NOT_NULL(ut_params->op,
10427 "Failed to allocate pktmbuf offload");
10429 /* Set crypto operation data parameters */
10430 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10432 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10434 /* set crypto operation source mbuf */
10435 sym_op->m_src = ut_params->ibuf;
10438 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10439 ut_params->ibuf, reference->digest.len);
10441 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10442 "no room to append auth tag");
10444 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10445 ut_params->ibuf, reference->plaintext.len);
10448 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10450 memcpy(sym_op->auth.digest.data,
10451 reference->digest.data,
10452 reference->digest.len);
10454 debug_hexdump(stdout, "digest:",
10455 sym_op->auth.digest.data,
10456 reference->digest.len);
10458 sym_op->auth.data.length = reference->plaintext.len;
10459 sym_op->auth.data.offset = 0;
10465 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10466 struct crypto_unittest_params *ut_params,
10467 const struct test_crypto_vector *reference,
10468 unsigned int auth_generate)
10470 /* Generate Crypto op data structure */
10471 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10472 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10473 TEST_ASSERT_NOT_NULL(ut_params->op,
10474 "Failed to allocate pktmbuf offload");
10476 /* Set crypto operation data parameters */
10477 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10479 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10481 /* set crypto operation source mbuf */
10482 sym_op->m_src = ut_params->ibuf;
10485 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10486 ut_params->ibuf, reference->digest.len);
10488 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10489 "no room to append auth tag");
10491 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10492 ut_params->ibuf, reference->ciphertext.len);
10495 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10497 memcpy(sym_op->auth.digest.data,
10498 reference->digest.data,
10499 reference->digest.len);
10501 debug_hexdump(stdout, "digest:",
10502 sym_op->auth.digest.data,
10503 reference->digest.len);
10505 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10506 reference->iv.data, reference->iv.len);
10508 sym_op->cipher.data.length = 0;
10509 sym_op->cipher.data.offset = 0;
10511 sym_op->auth.data.length = reference->plaintext.len;
10512 sym_op->auth.data.offset = 0;
10518 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10519 struct crypto_unittest_params *ut_params,
10520 const struct test_crypto_vector *reference,
10521 unsigned int auth_generate)
10523 /* Generate Crypto op data structure */
10524 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10525 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10526 TEST_ASSERT_NOT_NULL(ut_params->op,
10527 "Failed to allocate pktmbuf offload");
10529 /* Set crypto operation data parameters */
10530 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10532 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10534 /* set crypto operation source mbuf */
10535 sym_op->m_src = ut_params->ibuf;
10538 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10539 ut_params->ibuf, reference->digest.len);
10541 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10542 "no room to append auth tag");
10544 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10545 ut_params->ibuf, reference->ciphertext.len);
10548 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10550 memcpy(sym_op->auth.digest.data,
10551 reference->digest.data,
10552 reference->digest.len);
10554 debug_hexdump(stdout, "digest:",
10555 sym_op->auth.digest.data,
10556 reference->digest.len);
10558 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10559 reference->iv.data, reference->iv.len);
10561 sym_op->cipher.data.length = reference->cipher_len;
10562 sym_op->cipher.data.offset = reference->cipher_offset;
10564 sym_op->auth.data.length = reference->plaintext.len;
10565 sym_op->auth.data.offset = reference->auth_offset;
10571 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10572 struct crypto_unittest_params *ut_params,
10573 const struct test_crypto_vector *reference)
10575 return create_auth_operation(ts_params, ut_params, reference, 0);
10579 create_auth_verify_GMAC_operation(
10580 struct crypto_testsuite_params *ts_params,
10581 struct crypto_unittest_params *ut_params,
10582 const struct test_crypto_vector *reference)
10584 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10588 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10589 struct crypto_unittest_params *ut_params,
10590 const struct test_crypto_vector *reference)
10592 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10596 test_authentication_verify_fail_when_data_corruption(
10597 struct crypto_testsuite_params *ts_params,
10598 struct crypto_unittest_params *ut_params,
10599 const struct test_crypto_vector *reference,
10600 unsigned int data_corrupted)
10604 uint8_t *plaintext;
10606 /* Verify the capabilities */
10607 struct rte_cryptodev_sym_capability_idx cap_idx;
10608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10609 cap_idx.algo.auth = reference->auth_algo;
10610 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10614 /* Create session */
10615 retval = create_auth_session(ut_params,
10616 ts_params->valid_devs[0],
10618 RTE_CRYPTO_AUTH_OP_VERIFY);
10622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10623 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10624 "Failed to allocate input buffer in mempool");
10626 /* clear mbuf payload */
10627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10628 rte_pktmbuf_tailroom(ut_params->ibuf));
10630 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10631 reference->plaintext.len);
10632 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10633 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10635 debug_hexdump(stdout, "plaintext:", plaintext,
10636 reference->plaintext.len);
10638 /* Create operation */
10639 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10644 if (data_corrupted)
10645 data_corruption(plaintext);
10647 tag_corruption(plaintext, reference->plaintext.len);
10649 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10650 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10652 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10653 RTE_CRYPTO_OP_STATUS_SUCCESS,
10654 "authentication not failed");
10656 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10658 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10665 test_authentication_verify_GMAC_fail_when_corruption(
10666 struct crypto_testsuite_params *ts_params,
10667 struct crypto_unittest_params *ut_params,
10668 const struct test_crypto_vector *reference,
10669 unsigned int data_corrupted)
10672 uint8_t *plaintext;
10674 /* Verify the capabilities */
10675 struct rte_cryptodev_sym_capability_idx cap_idx;
10676 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10677 cap_idx.algo.auth = reference->auth_algo;
10678 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10682 /* Create session */
10683 retval = create_auth_cipher_session(ut_params,
10684 ts_params->valid_devs[0],
10686 RTE_CRYPTO_AUTH_OP_VERIFY,
10687 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10692 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10693 "Failed to allocate input buffer in mempool");
10695 /* clear mbuf payload */
10696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10697 rte_pktmbuf_tailroom(ut_params->ibuf));
10699 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10700 reference->plaintext.len);
10701 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10702 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10704 debug_hexdump(stdout, "plaintext:", plaintext,
10705 reference->plaintext.len);
10707 /* Create operation */
10708 retval = create_auth_verify_GMAC_operation(ts_params,
10715 if (data_corrupted)
10716 data_corruption(plaintext);
10718 tag_corruption(plaintext, reference->aad.len);
10720 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10721 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10723 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10724 RTE_CRYPTO_OP_STATUS_SUCCESS,
10725 "authentication not failed");
10727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10729 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10736 test_authenticated_decryption_fail_when_corruption(
10737 struct crypto_testsuite_params *ts_params,
10738 struct crypto_unittest_params *ut_params,
10739 const struct test_crypto_vector *reference,
10740 unsigned int data_corrupted)
10744 uint8_t *ciphertext;
10746 /* Verify the capabilities */
10747 struct rte_cryptodev_sym_capability_idx cap_idx;
10748 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10749 cap_idx.algo.auth = reference->auth_algo;
10750 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10753 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10754 cap_idx.algo.cipher = reference->crypto_algo;
10755 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10759 /* Create session */
10760 retval = create_auth_cipher_session(ut_params,
10761 ts_params->valid_devs[0],
10763 RTE_CRYPTO_AUTH_OP_VERIFY,
10764 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10768 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10769 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10770 "Failed to allocate input buffer in mempool");
10772 /* clear mbuf payload */
10773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10774 rte_pktmbuf_tailroom(ut_params->ibuf));
10776 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10777 reference->ciphertext.len);
10778 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10779 memcpy(ciphertext, reference->ciphertext.data,
10780 reference->ciphertext.len);
10782 /* Create operation */
10783 retval = create_cipher_auth_verify_operation(ts_params,
10790 if (data_corrupted)
10791 data_corruption(ciphertext);
10793 tag_corruption(ciphertext, reference->ciphertext.len);
10795 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10796 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10798 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10799 RTE_CRYPTO_OP_STATUS_SUCCESS,
10800 "authentication not failed");
10802 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10804 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10811 test_authenticated_encryt_with_esn(
10812 struct crypto_testsuite_params *ts_params,
10813 struct crypto_unittest_params *ut_params,
10814 const struct test_crypto_vector *reference)
10818 uint8_t *authciphertext, *plaintext, *auth_tag;
10819 uint16_t plaintext_pad_len;
10820 uint8_t cipher_key[reference->cipher_key.len + 1];
10821 uint8_t auth_key[reference->auth_key.len + 1];
10823 /* Verify the capabilities */
10824 struct rte_cryptodev_sym_capability_idx cap_idx;
10825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10826 cap_idx.algo.auth = reference->auth_algo;
10827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10830 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10831 cap_idx.algo.cipher = reference->crypto_algo;
10832 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10836 /* Create session */
10837 memcpy(cipher_key, reference->cipher_key.data,
10838 reference->cipher_key.len);
10839 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10841 /* Setup Cipher Parameters */
10842 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10843 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10844 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10845 ut_params->cipher_xform.cipher.key.data = cipher_key;
10846 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10847 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10848 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10850 ut_params->cipher_xform.next = &ut_params->auth_xform;
10852 /* Setup Authentication Parameters */
10853 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10854 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10855 ut_params->auth_xform.auth.algo = reference->auth_algo;
10856 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10857 ut_params->auth_xform.auth.key.data = auth_key;
10858 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10859 ut_params->auth_xform.next = NULL;
10861 /* Create Crypto session*/
10862 ut_params->sess = rte_cryptodev_sym_session_create(
10863 ts_params->session_mpool);
10865 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10867 &ut_params->cipher_xform,
10868 ts_params->session_priv_mpool);
10870 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10873 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10874 "Failed to allocate input buffer in mempool");
10876 /* clear mbuf payload */
10877 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10878 rte_pktmbuf_tailroom(ut_params->ibuf));
10880 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10881 reference->plaintext.len);
10882 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10883 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10885 /* Create operation */
10886 retval = create_cipher_auth_operation(ts_params,
10893 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10894 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10897 ut_params->op = process_crypto_request(
10898 ts_params->valid_devs[0], ut_params->op);
10900 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10902 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10903 "crypto op processing failed");
10905 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10907 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10908 ut_params->op->sym->auth.data.offset);
10909 auth_tag = authciphertext + plaintext_pad_len;
10910 debug_hexdump(stdout, "ciphertext:", authciphertext,
10911 reference->ciphertext.len);
10912 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10914 /* Validate obuf */
10915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10917 reference->ciphertext.data,
10918 reference->ciphertext.len,
10919 "Ciphertext data not as expected");
10921 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10923 reference->digest.data,
10924 reference->digest.len,
10925 "Generated digest not as expected");
10927 return TEST_SUCCESS;
10932 test_authenticated_decrypt_with_esn(
10933 struct crypto_testsuite_params *ts_params,
10934 struct crypto_unittest_params *ut_params,
10935 const struct test_crypto_vector *reference)
10939 uint8_t *ciphertext;
10940 uint8_t cipher_key[reference->cipher_key.len + 1];
10941 uint8_t auth_key[reference->auth_key.len + 1];
10943 /* Verify the capabilities */
10944 struct rte_cryptodev_sym_capability_idx cap_idx;
10945 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10946 cap_idx.algo.auth = reference->auth_algo;
10947 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10950 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10951 cap_idx.algo.cipher = reference->crypto_algo;
10952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10956 /* Create session */
10957 memcpy(cipher_key, reference->cipher_key.data,
10958 reference->cipher_key.len);
10959 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10961 /* Setup Authentication Parameters */
10962 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10963 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10964 ut_params->auth_xform.auth.algo = reference->auth_algo;
10965 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10966 ut_params->auth_xform.auth.key.data = auth_key;
10967 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10968 ut_params->auth_xform.next = &ut_params->cipher_xform;
10970 /* Setup Cipher Parameters */
10971 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10972 ut_params->cipher_xform.next = NULL;
10973 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10974 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10975 ut_params->cipher_xform.cipher.key.data = cipher_key;
10976 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10977 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10978 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10980 /* Create Crypto session*/
10981 ut_params->sess = rte_cryptodev_sym_session_create(
10982 ts_params->session_mpool);
10984 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10986 &ut_params->auth_xform,
10987 ts_params->session_priv_mpool);
10989 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10991 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10992 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10993 "Failed to allocate input buffer in mempool");
10995 /* clear mbuf payload */
10996 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10997 rte_pktmbuf_tailroom(ut_params->ibuf));
10999 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11000 reference->ciphertext.len);
11001 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11002 memcpy(ciphertext, reference->ciphertext.data,
11003 reference->ciphertext.len);
11005 /* Create operation */
11006 retval = create_cipher_auth_verify_operation(ts_params,
11013 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11014 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11017 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11020 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11021 TEST_ASSERT_EQUAL(ut_params->op->status,
11022 RTE_CRYPTO_OP_STATUS_SUCCESS,
11023 "crypto op processing passed");
11025 ut_params->obuf = ut_params->op->sym->m_src;
11026 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11032 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11033 const struct aead_test_data *tdata,
11034 void *digest_mem, uint64_t digest_phys)
11036 struct crypto_testsuite_params *ts_params = &testsuite_params;
11037 struct crypto_unittest_params *ut_params = &unittest_params;
11039 const unsigned int auth_tag_len = tdata->auth_tag.len;
11040 const unsigned int iv_len = tdata->iv.len;
11041 unsigned int aad_len = tdata->aad.len;
11042 unsigned int aad_len_pad = 0;
11044 /* Generate Crypto op data structure */
11045 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11046 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11047 TEST_ASSERT_NOT_NULL(ut_params->op,
11048 "Failed to allocate symmetric crypto operation struct");
11050 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11052 sym_op->aead.digest.data = digest_mem;
11054 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11055 "no room to append digest");
11057 sym_op->aead.digest.phys_addr = digest_phys;
11059 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11060 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11062 debug_hexdump(stdout, "digest:",
11063 sym_op->aead.digest.data,
11067 /* Append aad data */
11068 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11069 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11070 uint8_t *, IV_OFFSET);
11072 /* Copy IV 1 byte after the IV pointer, according to the API */
11073 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11075 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11077 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11078 ut_params->ibuf, aad_len);
11079 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11080 "no room to prepend aad");
11081 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11084 memset(sym_op->aead.aad.data, 0, aad_len);
11085 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11086 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11088 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11089 debug_hexdump(stdout, "aad:",
11090 sym_op->aead.aad.data, aad_len);
11092 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11093 uint8_t *, IV_OFFSET);
11095 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11097 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11099 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11100 ut_params->ibuf, aad_len_pad);
11101 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11102 "no room to prepend aad");
11103 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11106 memset(sym_op->aead.aad.data, 0, aad_len);
11107 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11109 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11110 debug_hexdump(stdout, "aad:",
11111 sym_op->aead.aad.data, aad_len);
11114 sym_op->aead.data.length = tdata->plaintext.len;
11115 sym_op->aead.data.offset = aad_len_pad;
11120 #define SGL_MAX_NO 16
11123 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11124 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11126 struct crypto_testsuite_params *ts_params = &testsuite_params;
11127 struct crypto_unittest_params *ut_params = &unittest_params;
11128 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11131 int to_trn_tbl[SGL_MAX_NO];
11133 unsigned int trn_data = 0;
11134 uint8_t *plaintext, *ciphertext, *auth_tag;
11135 struct rte_cryptodev_info dev_info;
11137 /* Verify the capabilities */
11138 struct rte_cryptodev_sym_capability_idx cap_idx;
11139 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11140 cap_idx.algo.aead = tdata->algo;
11141 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11145 /* OOP not supported with CPU crypto */
11146 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11149 /* Detailed check for the particular SGL support flag */
11150 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11152 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11153 if (sgl_in && (!(dev_info.feature_flags &
11154 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11157 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11158 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11159 tdata->plaintext.len;
11160 if (sgl_in && !sgl_out) {
11161 if (!(dev_info.feature_flags &
11162 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11164 } else if (!sgl_in && sgl_out) {
11165 if (!(dev_info.feature_flags &
11166 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11168 } else if (sgl_in && sgl_out) {
11169 if (!(dev_info.feature_flags &
11170 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11175 if (fragsz > tdata->plaintext.len)
11176 fragsz = tdata->plaintext.len;
11178 uint16_t plaintext_len = fragsz;
11179 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11181 if (fragsz_oop > tdata->plaintext.len)
11182 frag_size_oop = tdata->plaintext.len;
11185 void *digest_mem = NULL;
11187 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11189 if (tdata->plaintext.len % fragsz != 0) {
11190 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11193 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11198 * For out-op-place we need to alloc another mbuf
11201 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11202 rte_pktmbuf_append(ut_params->obuf,
11203 frag_size_oop + prepend_len);
11204 buf_oop = ut_params->obuf;
11207 /* Create AEAD session */
11208 retval = create_aead_session(ts_params->valid_devs[0],
11210 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11211 tdata->key.data, tdata->key.len,
11212 tdata->aad.len, tdata->auth_tag.len,
11217 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11219 /* clear mbuf payload */
11220 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11221 rte_pktmbuf_tailroom(ut_params->ibuf));
11223 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11226 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11228 trn_data += plaintext_len;
11230 buf = ut_params->ibuf;
11233 * Loop until no more fragments
11236 while (trn_data < tdata->plaintext.len) {
11238 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11239 (tdata->plaintext.len - trn_data) : fragsz;
11241 to_trn_tbl[ecx++] = to_trn;
11243 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11246 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11247 rte_pktmbuf_tailroom(buf));
11250 if (oop && !fragsz_oop) {
11251 buf_last_oop = buf_oop->next =
11252 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11253 buf_oop = buf_oop->next;
11254 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11255 0, rte_pktmbuf_tailroom(buf_oop));
11256 rte_pktmbuf_append(buf_oop, to_trn);
11259 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11262 memcpy(plaintext, tdata->plaintext.data + trn_data,
11264 trn_data += to_trn;
11265 if (trn_data == tdata->plaintext.len) {
11268 digest_mem = rte_pktmbuf_append(buf_oop,
11269 tdata->auth_tag.len);
11271 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11272 tdata->auth_tag.len);
11276 uint64_t digest_phys = 0;
11278 ut_params->ibuf->nb_segs = segs;
11281 if (fragsz_oop && oop) {
11285 if (frag_size_oop == tdata->plaintext.len) {
11286 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11287 tdata->auth_tag.len);
11289 digest_phys = rte_pktmbuf_iova_offset(
11291 tdata->plaintext.len + prepend_len);
11294 trn_data = frag_size_oop;
11295 while (trn_data < tdata->plaintext.len) {
11298 (tdata->plaintext.len - trn_data <
11300 (tdata->plaintext.len - trn_data) :
11303 to_trn_tbl[ecx++] = to_trn;
11305 buf_last_oop = buf_oop->next =
11306 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11307 buf_oop = buf_oop->next;
11308 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11309 0, rte_pktmbuf_tailroom(buf_oop));
11310 rte_pktmbuf_append(buf_oop, to_trn);
11312 trn_data += to_trn;
11314 if (trn_data == tdata->plaintext.len) {
11315 digest_mem = rte_pktmbuf_append(buf_oop,
11316 tdata->auth_tag.len);
11320 ut_params->obuf->nb_segs = segs;
11324 * Place digest at the end of the last buffer
11327 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11328 if (oop && buf_last_oop)
11329 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11331 if (!digest_mem && !oop) {
11332 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11333 + tdata->auth_tag.len);
11334 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11335 tdata->plaintext.len);
11338 /* Create AEAD operation */
11339 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11340 tdata, digest_mem, digest_phys);
11345 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11347 ut_params->op->sym->m_src = ut_params->ibuf;
11349 ut_params->op->sym->m_dst = ut_params->obuf;
11351 /* Process crypto operation */
11352 if (oop == IN_PLACE &&
11353 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11354 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11356 TEST_ASSERT_NOT_NULL(
11357 process_crypto_request(ts_params->valid_devs[0],
11358 ut_params->op), "failed to process sym crypto op");
11360 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11361 "crypto op processing failed");
11364 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11365 uint8_t *, prepend_len);
11367 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11368 uint8_t *, prepend_len);
11372 fragsz = fragsz_oop;
11374 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11376 tdata->ciphertext.data,
11378 "Ciphertext data not as expected");
11380 buf = ut_params->op->sym->m_src->next;
11382 buf = ut_params->op->sym->m_dst->next;
11384 unsigned int off = fragsz;
11388 ciphertext = rte_pktmbuf_mtod(buf,
11391 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11393 tdata->ciphertext.data + off,
11395 "Ciphertext data not as expected");
11397 off += to_trn_tbl[ecx++];
11401 auth_tag = digest_mem;
11402 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11404 tdata->auth_tag.data,
11405 tdata->auth_tag.len,
11406 "Generated auth tag not as expected");
11412 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11414 return test_authenticated_encryption_SGL(
11415 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11419 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11421 return test_authenticated_encryption_SGL(
11422 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11426 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11428 return test_authenticated_encryption_SGL(
11429 &gcm_test_case_8, OUT_OF_PLACE, 400,
11430 gcm_test_case_8.plaintext.len);
11434 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11436 /* This test is not for OPENSSL PMD */
11437 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11438 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11441 return test_authenticated_encryption_SGL(
11442 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11446 test_authentication_verify_fail_when_data_corrupted(
11447 struct crypto_testsuite_params *ts_params,
11448 struct crypto_unittest_params *ut_params,
11449 const struct test_crypto_vector *reference)
11451 return test_authentication_verify_fail_when_data_corruption(
11452 ts_params, ut_params, reference, 1);
11456 test_authentication_verify_fail_when_tag_corrupted(
11457 struct crypto_testsuite_params *ts_params,
11458 struct crypto_unittest_params *ut_params,
11459 const struct test_crypto_vector *reference)
11461 return test_authentication_verify_fail_when_data_corruption(
11462 ts_params, ut_params, reference, 0);
11466 test_authentication_verify_GMAC_fail_when_data_corrupted(
11467 struct crypto_testsuite_params *ts_params,
11468 struct crypto_unittest_params *ut_params,
11469 const struct test_crypto_vector *reference)
11471 return test_authentication_verify_GMAC_fail_when_corruption(
11472 ts_params, ut_params, reference, 1);
11476 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11477 struct crypto_testsuite_params *ts_params,
11478 struct crypto_unittest_params *ut_params,
11479 const struct test_crypto_vector *reference)
11481 return test_authentication_verify_GMAC_fail_when_corruption(
11482 ts_params, ut_params, reference, 0);
11486 test_authenticated_decryption_fail_when_data_corrupted(
11487 struct crypto_testsuite_params *ts_params,
11488 struct crypto_unittest_params *ut_params,
11489 const struct test_crypto_vector *reference)
11491 return test_authenticated_decryption_fail_when_corruption(
11492 ts_params, ut_params, reference, 1);
11496 test_authenticated_decryption_fail_when_tag_corrupted(
11497 struct crypto_testsuite_params *ts_params,
11498 struct crypto_unittest_params *ut_params,
11499 const struct test_crypto_vector *reference)
11501 return test_authenticated_decryption_fail_when_corruption(
11502 ts_params, ut_params, reference, 0);
11506 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11508 return test_authentication_verify_fail_when_data_corrupted(
11509 &testsuite_params, &unittest_params,
11510 &hmac_sha1_test_crypto_vector);
11514 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11516 return test_authentication_verify_fail_when_tag_corrupted(
11517 &testsuite_params, &unittest_params,
11518 &hmac_sha1_test_crypto_vector);
11522 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11524 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11525 &testsuite_params, &unittest_params,
11526 &aes128_gmac_test_vector);
11530 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11532 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11533 &testsuite_params, &unittest_params,
11534 &aes128_gmac_test_vector);
11538 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11540 return test_authenticated_decryption_fail_when_data_corrupted(
11543 &aes128cbc_hmac_sha1_test_vector);
11547 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11549 return test_authenticated_decryption_fail_when_tag_corrupted(
11552 &aes128cbc_hmac_sha1_test_vector);
11556 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11558 return test_authenticated_encryt_with_esn(
11561 &aes128cbc_hmac_sha1_aad_test_vector);
11565 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11567 return test_authenticated_decrypt_with_esn(
11570 &aes128cbc_hmac_sha1_aad_test_vector);
11573 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11575 /* global AESNI slave IDs for the scheduler test */
11576 uint8_t aesni_ids[2];
11579 test_scheduler_attach_slave_op(void)
11581 struct crypto_testsuite_params *ts_params = &testsuite_params;
11582 uint8_t sched_id = ts_params->valid_devs[0];
11583 uint32_t nb_devs, i, nb_devs_attached = 0;
11585 char vdev_name[32];
11587 /* create 2 AESNI_MB if necessary */
11588 nb_devs = rte_cryptodev_device_count_by_driver(
11589 rte_cryptodev_driver_id_get(
11590 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11592 for (i = nb_devs; i < 2; i++) {
11593 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11594 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11596 ret = rte_vdev_init(vdev_name, NULL);
11598 TEST_ASSERT(ret == 0,
11599 "Failed to create instance %u of"
11601 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11605 /* attach 2 AESNI_MB cdevs */
11606 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11608 struct rte_cryptodev_info info;
11609 unsigned int session_size;
11611 rte_cryptodev_info_get(i, &info);
11612 if (info.driver_id != rte_cryptodev_driver_id_get(
11613 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11616 session_size = rte_cryptodev_sym_get_private_session_size(i);
11618 * Create the session mempool again, since now there are new devices
11619 * to use the mempool.
11621 if (ts_params->session_mpool) {
11622 rte_mempool_free(ts_params->session_mpool);
11623 ts_params->session_mpool = NULL;
11625 if (ts_params->session_priv_mpool) {
11626 rte_mempool_free(ts_params->session_priv_mpool);
11627 ts_params->session_priv_mpool = NULL;
11630 if (info.sym.max_nb_sessions != 0 &&
11631 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11632 RTE_LOG(ERR, USER1,
11633 "Device does not support "
11634 "at least %u sessions\n",
11636 return TEST_FAILED;
11639 * Create mempool with maximum number of sessions,
11640 * to include the session headers
11642 if (ts_params->session_mpool == NULL) {
11643 ts_params->session_mpool =
11644 rte_cryptodev_sym_session_pool_create(
11646 MAX_NB_SESSIONS, 0, 0, 0,
11648 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11649 "session mempool allocation failed");
11653 * Create mempool with maximum number of sessions,
11654 * to include device specific session private data
11656 if (ts_params->session_priv_mpool == NULL) {
11657 ts_params->session_priv_mpool = rte_mempool_create(
11658 "test_sess_mp_priv",
11661 0, 0, NULL, NULL, NULL,
11662 NULL, SOCKET_ID_ANY,
11665 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11666 "session mempool allocation failed");
11669 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11670 ts_params->qp_conf.mp_session_private =
11671 ts_params->session_priv_mpool;
11673 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11676 TEST_ASSERT(ret == 0,
11677 "Failed to attach device %u of pmd : %s", i,
11678 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11680 aesni_ids[nb_devs_attached] = (uint8_t)i;
11682 nb_devs_attached++;
11689 test_scheduler_detach_slave_op(void)
11691 struct crypto_testsuite_params *ts_params = &testsuite_params;
11692 uint8_t sched_id = ts_params->valid_devs[0];
11696 for (i = 0; i < 2; i++) {
11697 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11699 TEST_ASSERT(ret == 0,
11700 "Failed to detach device %u", aesni_ids[i]);
11707 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11709 struct crypto_testsuite_params *ts_params = &testsuite_params;
11710 uint8_t sched_id = ts_params->valid_devs[0];
11712 return rte_cryptodev_scheduler_mode_set(sched_id,
11717 test_scheduler_mode_roundrobin_op(void)
11719 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11720 0, "Failed to set roundrobin mode");
11726 test_scheduler_mode_multicore_op(void)
11728 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11729 0, "Failed to set multicore mode");
11735 test_scheduler_mode_failover_op(void)
11737 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11738 0, "Failed to set failover mode");
11744 test_scheduler_mode_pkt_size_distr_op(void)
11746 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11747 0, "Failed to set pktsize mode");
11752 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11753 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11754 .setup = testsuite_setup,
11755 .teardown = testsuite_teardown,
11756 .unit_test_cases = {
11758 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11759 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11760 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11761 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11762 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11763 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11766 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11767 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11768 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11769 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11770 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11771 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11774 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11775 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11776 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11777 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11778 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11779 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11782 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11783 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11784 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11785 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11786 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11787 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11789 TEST_CASES_END() /**< NULL terminate unit test array */
11793 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11795 static struct unit_test_suite cryptodev_testsuite = {
11796 .suite_name = "Crypto Unit Test Suite",
11797 .setup = testsuite_setup,
11798 .teardown = testsuite_teardown,
11799 .unit_test_cases = {
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_device_configure_invalid_dev_id),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_device_configure_invalid_queue_pair_ids),
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_queue_pair_descriptor_setup),
11807 TEST_CASE_ST(ut_setup, ut_teardown,
11808 test_multi_session),
11809 TEST_CASE_ST(ut_setup, ut_teardown,
11810 test_multi_session_random_usage),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_null_invalid_operation),
11814 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11816 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11817 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11818 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11819 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11820 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11821 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11822 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11823 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11824 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11826 /** AES CCM Authenticated Encryption 128 bits key */
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_CCM_authenticated_encryption_test_case_128_1),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_CCM_authenticated_encryption_test_case_128_2),
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_CCM_authenticated_encryption_test_case_128_3),
11834 /** AES CCM Authenticated Decryption 128 bits key*/
11835 TEST_CASE_ST(ut_setup, ut_teardown,
11836 test_AES_CCM_authenticated_decryption_test_case_128_1),
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_CCM_authenticated_decryption_test_case_128_2),
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_CCM_authenticated_decryption_test_case_128_3),
11842 /** AES CCM Authenticated Encryption 192 bits key */
11843 TEST_CASE_ST(ut_setup, ut_teardown,
11844 test_AES_CCM_authenticated_encryption_test_case_192_1),
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_CCM_authenticated_encryption_test_case_192_2),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_CCM_authenticated_encryption_test_case_192_3),
11850 /** AES CCM Authenticated Decryption 192 bits key*/
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_AES_CCM_authenticated_decryption_test_case_192_1),
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_CCM_authenticated_decryption_test_case_192_2),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_CCM_authenticated_decryption_test_case_192_3),
11858 /** AES CCM Authenticated Encryption 256 bits key */
11859 TEST_CASE_ST(ut_setup, ut_teardown,
11860 test_AES_CCM_authenticated_encryption_test_case_256_1),
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_CCM_authenticated_encryption_test_case_256_2),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_CCM_authenticated_encryption_test_case_256_3),
11866 /** AES CCM Authenticated Decryption 256 bits key*/
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_CCM_authenticated_decryption_test_case_256_1),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_CCM_authenticated_decryption_test_case_256_2),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_CCM_authenticated_decryption_test_case_256_3),
11874 /** AES GCM Authenticated Encryption */
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_authenticated_encryption_test_case_1),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_authenticated_encryption_test_case_2),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_GCM_authenticated_encryption_test_case_3),
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_authenticated_encryption_test_case_4),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_authenticated_encryption_test_case_5),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_authenticated_encryption_test_case_6),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_authenticated_encryption_test_case_7),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_authenticated_encryption_test_case_8),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11902 /** AES GCM Authenticated Decryption */
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_authenticated_decryption_test_case_1),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_authenticated_decryption_test_case_2),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_AES_GCM_authenticated_decryption_test_case_3),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_authenticated_decryption_test_case_4),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_authenticated_decryption_test_case_5),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_authenticated_decryption_test_case_6),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_authenticated_decryption_test_case_7),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_authenticated_decryption_test_case_8),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11922 /** AES GCM Authenticated Encryption 192 bits key */
11923 TEST_CASE_ST(ut_setup, ut_teardown,
11924 test_AES_GCM_auth_encryption_test_case_192_1),
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_encryption_test_case_192_2),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_encryption_test_case_192_3),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_encryption_test_case_192_4),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_encryption_test_case_192_5),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_encryption_test_case_192_6),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_auth_encryption_test_case_192_7),
11938 /** AES GCM Authenticated Decryption 192 bits key */
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_AES_GCM_auth_decryption_test_case_192_1),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_auth_decryption_test_case_192_2),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_decryption_test_case_192_3),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_decryption_test_case_192_4),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_decryption_test_case_192_5),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_decryption_test_case_192_6),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GCM_auth_decryption_test_case_192_7),
11954 /** AES GCM Authenticated Encryption 256 bits key */
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_AES_GCM_auth_encryption_test_case_256_1),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GCM_auth_encryption_test_case_256_2),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_encryption_test_case_256_3),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GCM_auth_encryption_test_case_256_4),
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_AES_GCM_auth_encryption_test_case_256_5),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_encryption_test_case_256_6),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_GCM_auth_encryption_test_case_256_7),
11970 /** AES GCM Authenticated Decryption 256 bits key */
11971 TEST_CASE_ST(ut_setup, ut_teardown,
11972 test_AES_GCM_auth_decryption_test_case_256_1),
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_GCM_auth_decryption_test_case_256_2),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_GCM_auth_decryption_test_case_256_3),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_GCM_auth_decryption_test_case_256_4),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_AES_GCM_auth_decryption_test_case_256_5),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GCM_auth_decryption_test_case_256_6),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_GCM_auth_decryption_test_case_256_7),
11986 /** AES GCM Authenticated Encryption big aad size */
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GCM_auth_encryption_test_case_aad_1),
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_GCM_auth_encryption_test_case_aad_2),
11992 /** AES GCM Authenticated Decryption big aad size */
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_GCM_auth_decryption_test_case_aad_1),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_AES_GCM_auth_decryption_test_case_aad_2),
11998 /** Out of place tests */
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12004 /** Session-less tests */
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12010 /** AES GMAC Authentication */
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_AES_GMAC_authentication_test_case_1),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_AES_GMAC_authentication_verify_test_case_1),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_AES_GMAC_authentication_test_case_2),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_AES_GMAC_authentication_verify_test_case_2),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_AES_GMAC_authentication_test_case_3),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_AES_GMAC_authentication_verify_test_case_3),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_AES_GMAC_authentication_test_case_4),
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_AES_GMAC_authentication_verify_test_case_4),
12028 /** SNOW 3G encrypt only (UEA2) */
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_snow3g_encryption_test_case_1),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_snow3g_encryption_test_case_2),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_snow3g_encryption_test_case_3),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_snow3g_encryption_test_case_4),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_snow3g_encryption_test_case_5),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_encryption_test_case_1_oop),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_encryption_test_case_1_oop_sgl),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_encryption_test_case_1_offset_oop),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_decryption_test_case_1_oop),
12049 /** SNOW 3G generate auth, then encrypt (UEA2) */
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_test_case_1),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_test_case_2),
12054 TEST_CASE_ST(ut_setup, ut_teardown,
12055 test_snow3g_auth_cipher_test_case_2_oop),
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_part_digest_enc),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_auth_cipher_part_digest_enc_oop),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_auth_cipher_test_case_3_sgl),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_auth_cipher_part_digest_enc_sgl),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12069 /** SNOW 3G decrypt (UEA2), then verify auth */
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_auth_cipher_verify_test_case_1),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_auth_cipher_verify_test_case_2),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_snow3g_auth_cipher_verify_test_case_2_oop),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_auth_cipher_verify_part_digest_enc),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12089 /** SNOW 3G decrypt only (UEA2) */
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_snow3g_decryption_test_case_1),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_snow3g_decryption_test_case_2),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_snow3g_decryption_test_case_3),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_snow3g_decryption_test_case_4),
12098 TEST_CASE_ST(ut_setup, ut_teardown,
12099 test_snow3g_decryption_test_case_5),
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_snow3g_decryption_with_digest_test_case_1),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_snow3g_hash_generate_test_case_1),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_snow3g_hash_generate_test_case_2),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_snow3g_hash_generate_test_case_3),
12108 /* Tests with buffers which length is not byte-aligned */
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_snow3g_hash_generate_test_case_4),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_snow3g_hash_generate_test_case_5),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_snow3g_hash_generate_test_case_6),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_snow3g_hash_verify_test_case_1),
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_snow3g_hash_verify_test_case_2),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_snow3g_hash_verify_test_case_3),
12121 /* Tests with buffers which length is not byte-aligned */
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_snow3g_hash_verify_test_case_4),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_snow3g_hash_verify_test_case_5),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_snow3g_hash_verify_test_case_6),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_snow3g_cipher_auth_test_case_1),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_snow3g_auth_cipher_with_digest_test_case_1),
12133 /** ZUC encrypt only (EEA3) */
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_encryption_test_case_1),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_zuc_encryption_test_case_2),
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_encryption_test_case_3),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_encryption_test_case_4),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_encryption_test_case_5),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_encryption_test_case_6_sgl),
12147 /** ZUC authenticate (EIA3) */
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_hash_generate_test_case_1),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_zuc_hash_generate_test_case_2),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_zuc_hash_generate_test_case_3),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_hash_generate_test_case_4),
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_zuc_hash_generate_test_case_5),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_zuc_hash_generate_test_case_6),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_zuc_hash_generate_test_case_7),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_zuc_hash_generate_test_case_8),
12165 /** ZUC alg-chain (EEA3/EIA3) */
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_zuc_cipher_auth_test_case_1),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_zuc_cipher_auth_test_case_2),
12171 /** ZUC generate auth, then encrypt (EEA3) */
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_zuc_auth_cipher_test_case_1),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_zuc_auth_cipher_test_case_1_oop),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_zuc_auth_cipher_test_case_1_sgl),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_zuc_auth_cipher_test_case_1_oop_sgl),
12181 /** ZUC decrypt (EEA3), then verify auth */
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_zuc_auth_cipher_verify_test_case_1),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_zuc_auth_cipher_verify_test_case_1_oop),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_zuc_auth_cipher_verify_test_case_1_sgl),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12191 /** HMAC_MD5 Authentication */
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_MD5_HMAC_generate_case_1),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_MD5_HMAC_verify_case_1),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_MD5_HMAC_generate_case_2),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_MD5_HMAC_verify_case_2),
12201 /** KASUMI hash only (UIA1) */
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_kasumi_hash_generate_test_case_1),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_kasumi_hash_generate_test_case_2),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_kasumi_hash_generate_test_case_3),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_kasumi_hash_generate_test_case_4),
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_kasumi_hash_generate_test_case_5),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_kasumi_hash_generate_test_case_6),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_hash_verify_test_case_1),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_hash_verify_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_hash_verify_test_case_3),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_hash_verify_test_case_4),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_hash_verify_test_case_5),
12226 /** KASUMI encrypt only (UEA1) */
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_encryption_test_case_1),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_kasumi_encryption_test_case_1_sgl),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_encryption_test_case_1_oop),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_kasumi_encryption_test_case_1_oop_sgl),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_kasumi_encryption_test_case_2),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_kasumi_encryption_test_case_3),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_kasumi_encryption_test_case_4),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_kasumi_encryption_test_case_5),
12244 /** KASUMI decrypt only (UEA1) */
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_kasumi_decryption_test_case_1),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_kasumi_decryption_test_case_2),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_kasumi_decryption_test_case_3),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_kasumi_decryption_test_case_4),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_kasumi_decryption_test_case_5),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_kasumi_decryption_test_case_1_oop),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 test_kasumi_cipher_auth_test_case_1),
12261 /** KASUMI generate auth, then encrypt (F8) */
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_kasumi_auth_cipher_test_case_1),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_kasumi_auth_cipher_test_case_2),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_kasumi_auth_cipher_test_case_2_oop),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_kasumi_auth_cipher_test_case_2_sgl),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12273 /** KASUMI decrypt (F8), then verify auth */
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_kasumi_auth_cipher_verify_test_case_1),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_kasumi_auth_cipher_verify_test_case_2),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_kasumi_auth_cipher_verify_test_case_2_oop),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12285 /** ESN Testcase */
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12291 /** Negative tests */
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12310 TEST_CASE_ST(ut_setup, ut_teardown,
12311 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12312 TEST_CASE_ST(ut_setup, ut_teardown,
12313 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12314 TEST_CASE_ST(ut_setup, ut_teardown,
12315 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12316 TEST_CASE_ST(ut_setup, ut_teardown,
12317 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12318 TEST_CASE_ST(ut_setup, ut_teardown,
12319 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12320 TEST_CASE_ST(ut_setup, ut_teardown,
12321 authentication_verify_AES128_GMAC_fail_data_corrupt),
12322 TEST_CASE_ST(ut_setup, ut_teardown,
12323 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12329 /** Mixed CIPHER + HASH algorithms */
12330 /** AUTH AES CMAC + CIPHER AES CTR */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12348 /** AUTH ZUC + CIPHER SNOW3G */
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_auth_zuc_cipher_snow_test_case_1),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_verify_auth_zuc_cipher_snow_test_case_1),
12353 /** AUTH AES CMAC + CIPHER SNOW3G */
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_auth_aes_cmac_cipher_snow_test_case_1),
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12358 /** AUTH ZUC + CIPHER AES CTR */
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_auth_zuc_cipher_aes_ctr_test_case_1),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12363 /** AUTH SNOW3G + CIPHER AES CTR */
12364 TEST_CASE_ST(ut_setup, ut_teardown,
12365 test_auth_snow_cipher_aes_ctr_test_case_1),
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12368 /** AUTH SNOW3G + CIPHER ZUC */
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_auth_snow_cipher_zuc_test_case_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_verify_auth_snow_cipher_zuc_test_case_1),
12373 /** AUTH AES CMAC + CIPHER ZUC */
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_auth_aes_cmac_cipher_zuc_test_case_1),
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12379 /** AUTH NULL + CIPHER SNOW3G */
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_auth_null_cipher_snow_test_case_1),
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_verify_auth_null_cipher_snow_test_case_1),
12384 /** AUTH NULL + CIPHER ZUC */
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_auth_null_cipher_zuc_test_case_1),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_verify_auth_null_cipher_zuc_test_case_1),
12389 /** AUTH SNOW3G + CIPHER NULL */
12390 TEST_CASE_ST(ut_setup, ut_teardown,
12391 test_auth_snow_cipher_null_test_case_1),
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_verify_auth_snow_cipher_null_test_case_1),
12394 /** AUTH ZUC + CIPHER NULL */
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_auth_zuc_cipher_null_test_case_1),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_verify_auth_zuc_cipher_null_test_case_1),
12399 /** AUTH NULL + CIPHER AES CTR */
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_auth_null_cipher_aes_ctr_test_case_1),
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12404 /** AUTH AES CMAC + CIPHER NULL */
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_auth_aes_cmac_cipher_null_test_case_1),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12410 #ifdef RTE_LIBRTE_SECURITY
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_PDCP_PROTO_all),
12414 TEST_CASES_END() /**< NULL terminate unit test array */
12418 static struct unit_test_suite cryptodev_virtio_testsuite = {
12419 .suite_name = "Crypto VIRTIO Unit Test Suite",
12420 .setup = testsuite_setup,
12421 .teardown = testsuite_teardown,
12422 .unit_test_cases = {
12423 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12425 TEST_CASES_END() /**< NULL terminate unit test array */
12429 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12430 .suite_name = "Crypto CAAM JR Unit Test Suite",
12431 .setup = testsuite_setup,
12432 .teardown = testsuite_teardown,
12433 .unit_test_cases = {
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 test_device_configure_invalid_dev_id),
12436 TEST_CASE_ST(ut_setup, ut_teardown,
12437 test_multi_session),
12439 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12440 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12441 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12442 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12443 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12445 TEST_CASES_END() /**< NULL terminate unit test array */
12449 static struct unit_test_suite cryptodev_armv8_testsuite = {
12450 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12451 .setup = testsuite_setup,
12452 .teardown = testsuite_teardown,
12453 .unit_test_cases = {
12454 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12456 /** Negative tests */
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12462 TEST_CASES_END() /**< NULL terminate unit test array */
12466 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12467 .suite_name = "Crypto Device Marvell Component Test Suite",
12468 .setup = testsuite_setup,
12469 .teardown = testsuite_teardown,
12470 .unit_test_cases = {
12471 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_multi_session_random_usage),
12474 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12475 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12476 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12477 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12478 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12480 /** Negative tests */
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12490 TEST_CASES_END() /**< NULL terminate unit test array */
12494 static struct unit_test_suite cryptodev_ccp_testsuite = {
12495 .suite_name = "Crypto Device CCP Unit Test Suite",
12496 .setup = testsuite_setup,
12497 .teardown = testsuite_teardown,
12498 .unit_test_cases = {
12499 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_multi_session_random_usage),
12502 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12503 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12504 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12505 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12506 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12508 /** Negative tests */
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12518 TEST_CASES_END() /**< NULL terminate unit test array */
12522 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12523 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12524 .setup = testsuite_setup,
12525 .teardown = testsuite_teardown,
12526 .unit_test_cases = {
12527 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12528 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12529 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12530 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12531 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12533 /** AES GCM Authenticated Encryption */
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_AES_GCM_authenticated_encryption_test_case_1),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_authenticated_encryption_test_case_2),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_authenticated_encryption_test_case_3),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_authenticated_encryption_test_case_4),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_authenticated_encryption_test_case_5),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_authenticated_encryption_test_case_6),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_authenticated_encryption_test_case_7),
12549 /** AES GCM Authenticated Decryption */
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_authenticated_decryption_test_case_1),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_authenticated_decryption_test_case_2),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_authenticated_decryption_test_case_3),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_authenticated_decryption_test_case_4),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_authenticated_decryption_test_case_5),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 test_AES_GCM_authenticated_decryption_test_case_6),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 test_AES_GCM_authenticated_decryption_test_case_7),
12564 /** AES GMAC Authentication */
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_AES_GMAC_authentication_test_case_1),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_AES_GMAC_authentication_verify_test_case_1),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_AES_GMAC_authentication_test_case_2),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_AES_GMAC_authentication_verify_test_case_2),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_AES_GMAC_authentication_test_case_3),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_AES_GMAC_authentication_verify_test_case_3),
12578 /** SNOW 3G encrypt only (UEA2) */
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_snow3g_encryption_test_case_1),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_snow3g_encryption_test_case_2),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_snow3g_encryption_test_case_3),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_snow3g_encryption_test_case_4),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_snow3g_encryption_test_case_5),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_snow3g_encryption_test_case_1_oop),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_snow3g_decryption_test_case_1_oop),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_snow3g_encryption_test_case_1_oop_sgl),
12597 /** SNOW 3G decrypt only (UEA2) */
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_snow3g_decryption_test_case_1),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_snow3g_decryption_test_case_2),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_snow3g_decryption_test_case_3),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_snow3g_decryption_test_case_4),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_snow3g_decryption_test_case_5),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_snow3g_hash_generate_test_case_1),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_snow3g_hash_generate_test_case_2),
12613 TEST_CASE_ST(ut_setup, ut_teardown,
12614 test_snow3g_hash_generate_test_case_3),
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_snow3g_hash_verify_test_case_1),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_snow3g_hash_verify_test_case_2),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_snow3g_hash_verify_test_case_3),
12622 /** ZUC encrypt only (EEA3) */
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_zuc_encryption_test_case_1),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_zuc_encryption_test_case_2),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_zuc_encryption_test_case_3),
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_zuc_encryption_test_case_4),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_zuc_encryption_test_case_5),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_zuc_hash_generate_test_case_1),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_zuc_hash_generate_test_case_2),
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_zuc_hash_generate_test_case_3),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_zuc_hash_generate_test_case_4),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_zuc_hash_generate_test_case_5),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_zuc_encryption_test_case_6_sgl),
12646 /** KASUMI encrypt only (UEA1) */
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_kasumi_encryption_test_case_1),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 test_kasumi_encryption_test_case_2),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 test_kasumi_encryption_test_case_3),
12653 TEST_CASE_ST(ut_setup, ut_teardown,
12654 test_kasumi_encryption_test_case_4),
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 test_kasumi_encryption_test_case_5),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_kasumi_encryption_test_case_1_sgl),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_kasumi_encryption_test_case_1_oop_sgl),
12661 /** KASUMI decrypt only (UEA1) */
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 test_kasumi_decryption_test_case_1),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 test_kasumi_decryption_test_case_2),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_kasumi_decryption_test_case_3),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 test_kasumi_decryption_test_case_4),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_kasumi_decryption_test_case_5),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_kasumi_encryption_test_case_1_oop),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_kasumi_decryption_test_case_1_oop),
12678 /** KASUMI hash only (UIA1) */
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_kasumi_hash_generate_test_case_1),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_kasumi_hash_generate_test_case_2),
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 test_kasumi_hash_generate_test_case_3),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_kasumi_hash_generate_test_case_4),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_kasumi_hash_generate_test_case_5),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_kasumi_hash_generate_test_case_6),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_kasumi_hash_verify_test_case_1),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_kasumi_hash_verify_test_case_2),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_kasumi_hash_verify_test_case_3),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_kasumi_hash_verify_test_case_4),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_kasumi_hash_verify_test_case_5),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_null_cipher_only_operation),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_null_auth_only_operation),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_null_cipher_auth_operation),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_null_auth_cipher_operation),
12712 /** Negative tests */
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 authentication_verify_AES128_GMAC_fail_data_corrupt),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12725 TEST_CASES_END() /**< NULL terminate unit test array */
12729 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12730 .suite_name = "Crypto NITROX Unit Test Suite",
12731 .setup = testsuite_setup,
12732 .teardown = testsuite_teardown,
12733 .unit_test_cases = {
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_device_configure_invalid_dev_id),
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_device_configure_invalid_queue_pair_ids),
12738 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12739 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12741 TEST_CASES_END() /**< NULL terminate unit test array */
12745 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
12746 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
12747 .setup = testsuite_setup,
12748 .teardown = testsuite_teardown,
12749 .unit_test_cases = {
12750 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12751 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12752 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12753 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12754 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12756 /** AES GCM Authenticated Encryption */
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_authenticated_encryption_test_case_1),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_authenticated_encryption_test_case_2),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_authenticated_encryption_test_case_3),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_authenticated_encryption_test_case_4),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_authenticated_encryption_test_case_5),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_authenticated_encryption_test_case_6),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_authenticated_encryption_test_case_7),
12772 /** AES GCM Authenticated Decryption */
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_authenticated_decryption_test_case_1),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_GCM_authenticated_decryption_test_case_2),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_authenticated_decryption_test_case_3),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_authenticated_decryption_test_case_4),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_authenticated_decryption_test_case_5),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_authenticated_decryption_test_case_6),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_authenticated_decryption_test_case_7),
12787 /** AES GMAC Authentication */
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_AES_GMAC_authentication_test_case_1),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_AES_GMAC_authentication_verify_test_case_1),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_GMAC_authentication_test_case_2),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_AES_GMAC_authentication_verify_test_case_2),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_AES_GMAC_authentication_test_case_3),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_AES_GMAC_authentication_verify_test_case_3),
12801 /** SNOW 3G encrypt only (UEA2) */
12802 TEST_CASE_ST(ut_setup, ut_teardown,
12803 test_snow3g_encryption_test_case_1),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_snow3g_encryption_test_case_2),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_snow3g_encryption_test_case_3),
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_snow3g_encryption_test_case_4),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_snow3g_encryption_test_case_5),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_snow3g_encryption_test_case_1_oop),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_snow3g_decryption_test_case_1_oop),
12817 TEST_CASE_ST(ut_setup, ut_teardown,
12818 test_snow3g_encryption_test_case_1_oop_sgl),
12820 /** SNOW 3G decrypt only (UEA2) */
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 test_snow3g_decryption_test_case_1),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 test_snow3g_decryption_test_case_2),
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_snow3g_decryption_test_case_3),
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_snow3g_decryption_test_case_4),
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 test_snow3g_decryption_test_case_5),
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_snow3g_hash_generate_test_case_1),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_snow3g_hash_generate_test_case_2),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_snow3g_hash_generate_test_case_3),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_snow3g_hash_verify_test_case_1),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_snow3g_hash_verify_test_case_2),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_snow3g_hash_verify_test_case_3),
12845 /** ZUC encrypt only (EEA3) */
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_zuc_encryption_test_case_1),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_zuc_encryption_test_case_2),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_zuc_encryption_test_case_3),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_zuc_encryption_test_case_4),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_zuc_encryption_test_case_5),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_zuc_hash_generate_test_case_1),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_zuc_hash_generate_test_case_2),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_zuc_hash_generate_test_case_3),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_zuc_hash_generate_test_case_4),
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 test_zuc_hash_generate_test_case_5),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_zuc_encryption_test_case_6_sgl),
12869 /** KASUMI encrypt only (UEA1) */
12870 TEST_CASE_ST(ut_setup, ut_teardown,
12871 test_kasumi_encryption_test_case_1),
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_kasumi_encryption_test_case_2),
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_kasumi_encryption_test_case_3),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_kasumi_encryption_test_case_4),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_kasumi_encryption_test_case_5),
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_kasumi_encryption_test_case_1_sgl),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_kasumi_encryption_test_case_1_oop_sgl),
12884 /** KASUMI decrypt only (UEA1) */
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_kasumi_decryption_test_case_1),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_kasumi_decryption_test_case_2),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_kasumi_decryption_test_case_3),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_kasumi_decryption_test_case_4),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_kasumi_decryption_test_case_5),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_encryption_test_case_1_oop),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_decryption_test_case_1_oop),
12901 /** KASUMI hash only (UIA1) */
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_hash_generate_test_case_1),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_kasumi_hash_generate_test_case_2),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_kasumi_hash_generate_test_case_3),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_kasumi_hash_generate_test_case_4),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 test_kasumi_hash_generate_test_case_5),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_kasumi_hash_generate_test_case_6),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_kasumi_hash_verify_test_case_1),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_kasumi_hash_verify_test_case_2),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_kasumi_hash_verify_test_case_3),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_kasumi_hash_verify_test_case_4),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_kasumi_hash_verify_test_case_5),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_null_cipher_only_operation),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_null_auth_only_operation),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_null_cipher_auth_operation),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_null_auth_cipher_operation),
12935 /** Negative tests */
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12938 TEST_CASE_ST(ut_setup, ut_teardown,
12939 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 authentication_verify_AES128_GMAC_fail_data_corrupt),
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12944 TEST_CASE_ST(ut_setup, ut_teardown,
12945 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12948 TEST_CASES_END() /**< NULL terminate unit test array */
12953 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12955 gbl_driver_id = rte_cryptodev_driver_id_get(
12956 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12958 if (gbl_driver_id == -1) {
12959 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12960 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12961 "are enabled in config file to run this testsuite.\n");
12962 return TEST_SKIPPED;
12965 return unit_test_suite_runner(&cryptodev_testsuite);
12969 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12971 gbl_driver_id = rte_cryptodev_driver_id_get(
12972 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12974 if (gbl_driver_id == -1) {
12975 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12976 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12977 "in config file to run this testsuite.\n");
12978 return TEST_FAILED;
12981 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12985 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12987 gbl_driver_id = rte_cryptodev_driver_id_get(
12988 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12990 if (gbl_driver_id == -1) {
12991 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12992 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12993 "in config file to run this testsuite.\n");
12994 return TEST_SKIPPED;
12997 return unit_test_suite_runner(&cryptodev_testsuite);
13001 test_cryptodev_cpu_aesni_mb(void)
13004 enum rte_security_session_action_type at;
13006 gbl_driver_id = rte_cryptodev_driver_id_get(
13007 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13009 if (gbl_driver_id == -1) {
13010 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13011 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13012 "in config file to run this testsuite.\n");
13013 return TEST_SKIPPED;
13016 at = gbl_action_type;
13017 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13018 rc = unit_test_suite_runner(&cryptodev_testsuite);
13019 gbl_action_type = at;
13024 test_cryptodev_openssl(void)
13026 gbl_driver_id = rte_cryptodev_driver_id_get(
13027 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13029 if (gbl_driver_id == -1) {
13030 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13031 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13032 "in config file to run this testsuite.\n");
13033 return TEST_SKIPPED;
13036 return unit_test_suite_runner(&cryptodev_testsuite);
13040 test_cryptodev_aesni_gcm(void)
13042 gbl_driver_id = rte_cryptodev_driver_id_get(
13043 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13045 if (gbl_driver_id == -1) {
13046 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13047 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13048 "in config file to run this testsuite.\n");
13049 return TEST_SKIPPED;
13052 return unit_test_suite_runner(&cryptodev_testsuite);
13056 test_cryptodev_cpu_aesni_gcm(void)
13059 enum rte_security_session_action_type at;
13061 gbl_driver_id = rte_cryptodev_driver_id_get(
13062 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13064 if (gbl_driver_id == -1) {
13065 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13066 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13067 "in config file to run this testsuite.\n");
13068 return TEST_SKIPPED;
13071 at = gbl_action_type;
13072 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13073 rc = unit_test_suite_runner(&cryptodev_testsuite);
13074 gbl_action_type = at;
13079 test_cryptodev_null(void)
13081 gbl_driver_id = rte_cryptodev_driver_id_get(
13082 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13084 if (gbl_driver_id == -1) {
13085 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13086 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13087 "in config file to run this testsuite.\n");
13088 return TEST_SKIPPED;
13091 return unit_test_suite_runner(&cryptodev_testsuite);
13095 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13097 gbl_driver_id = rte_cryptodev_driver_id_get(
13098 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13100 if (gbl_driver_id == -1) {
13101 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13102 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13103 "in config file to run this testsuite.\n");
13104 return TEST_SKIPPED;
13107 return unit_test_suite_runner(&cryptodev_testsuite);
13111 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13113 gbl_driver_id = rte_cryptodev_driver_id_get(
13114 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13116 if (gbl_driver_id == -1) {
13117 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13118 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13119 "in config file to run this testsuite.\n");
13120 return TEST_SKIPPED;
13123 return unit_test_suite_runner(&cryptodev_testsuite);
13127 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13129 gbl_driver_id = rte_cryptodev_driver_id_get(
13130 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13132 if (gbl_driver_id == -1) {
13133 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13134 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13135 "in config file to run this testsuite.\n");
13136 return TEST_SKIPPED;
13139 return unit_test_suite_runner(&cryptodev_testsuite);
13143 test_cryptodev_armv8(void)
13145 gbl_driver_id = rte_cryptodev_driver_id_get(
13146 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13148 if (gbl_driver_id == -1) {
13149 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13150 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13151 "in config file to run this testsuite.\n");
13152 return TEST_SKIPPED;
13155 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13159 test_cryptodev_mrvl(void)
13161 gbl_driver_id = rte_cryptodev_driver_id_get(
13162 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13164 if (gbl_driver_id == -1) {
13165 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13166 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13167 "in config file to run this testsuite.\n");
13168 return TEST_SKIPPED;
13171 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13174 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13177 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13179 gbl_driver_id = rte_cryptodev_driver_id_get(
13180 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13182 if (gbl_driver_id == -1) {
13183 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13184 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13185 "in config file to run this testsuite.\n");
13186 return TEST_SKIPPED;
13189 if (rte_cryptodev_driver_id_get(
13190 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13191 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13192 " enabled in config file to run this testsuite.\n");
13193 return TEST_SKIPPED;
13195 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13198 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13203 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13205 gbl_driver_id = rte_cryptodev_driver_id_get(
13206 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13208 if (gbl_driver_id == -1) {
13209 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13210 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13211 "in config file to run this testsuite.\n");
13212 return TEST_SKIPPED;
13215 return unit_test_suite_runner(&cryptodev_testsuite);
13219 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13221 gbl_driver_id = rte_cryptodev_driver_id_get(
13222 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13224 if (gbl_driver_id == -1) {
13225 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13226 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13227 "in config file to run this testsuite.\n");
13228 return TEST_SKIPPED;
13231 return unit_test_suite_runner(&cryptodev_testsuite);
13235 test_cryptodev_ccp(void)
13237 gbl_driver_id = rte_cryptodev_driver_id_get(
13238 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13240 if (gbl_driver_id == -1) {
13241 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13242 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13243 "in config file to run this testsuite.\n");
13244 return TEST_FAILED;
13247 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13251 test_cryptodev_octeontx(void)
13253 gbl_driver_id = rte_cryptodev_driver_id_get(
13254 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13255 if (gbl_driver_id == -1) {
13256 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13257 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13258 "enabled in config file to run this "
13260 return TEST_FAILED;
13262 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13266 test_cryptodev_octeontx2(void)
13268 gbl_driver_id = rte_cryptodev_driver_id_get(
13269 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13270 if (gbl_driver_id == -1) {
13271 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13272 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13273 "enabled in config file to run this "
13275 return TEST_FAILED;
13277 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13281 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13283 gbl_driver_id = rte_cryptodev_driver_id_get(
13284 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13286 if (gbl_driver_id == -1) {
13287 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13288 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13289 "in config file to run this testsuite.\n");
13290 return TEST_FAILED;
13293 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13297 test_cryptodev_nitrox(void)
13299 gbl_driver_id = rte_cryptodev_driver_id_get(
13300 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13302 if (gbl_driver_id == -1) {
13303 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13304 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13305 "in config file to run this testsuite.\n");
13306 return TEST_FAILED;
13309 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13312 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13313 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13314 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13315 test_cryptodev_cpu_aesni_mb);
13316 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13317 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13318 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13319 test_cryptodev_cpu_aesni_gcm);
13320 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13321 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13322 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13323 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13324 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13325 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13326 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13327 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13328 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13329 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13330 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13331 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13332 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13333 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);