1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 static enum rte_security_session_action_type gbl_action_type =
56 RTE_SECURITY_ACTION_TYPE_NONE;
58 struct crypto_testsuite_params {
59 struct rte_mempool *mbuf_pool;
60 struct rte_mempool *large_mbuf_pool;
61 struct rte_mempool *op_mpool;
62 struct rte_mempool *session_mpool;
63 struct rte_mempool *session_priv_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
77 struct rte_cryptodev_sym_session *sess;
78 #ifdef RTE_LIBRTE_SECURITY
79 struct rte_security_session *sec_session;
82 #ifdef RTE_LIBRTE_SECURITY
83 enum rte_security_session_action_type type;
85 struct rte_crypto_op *op;
87 struct rte_mbuf *obuf, *ibuf;
92 #define ALIGN_POW2_ROUNDUP(num, align) \
93 (((num) + (align) - 1) & ~((align) - 1))
96 * Forward declarations.
99 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
100 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
104 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
105 struct crypto_unittest_params *ut_params,
106 struct crypto_testsuite_params *ts_param,
107 const uint8_t *cipher,
108 const uint8_t *digest,
111 static struct rte_mbuf *
112 setup_test_string(struct rte_mempool *mpool,
113 const char *string, size_t len, uint8_t blocksize)
115 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
116 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
118 memset(m->buf_addr, 0, m->buf_len);
120 char *dst = rte_pktmbuf_append(m, t_len);
127 rte_memcpy(dst, string, t_len);
129 memset(dst, 0, t_len);
135 /* Get number of bytes in X bits (rounding up) */
137 ceil_byte_length(uint32_t num_bits)
140 return ((num_bits >> 3) + 1);
142 return (num_bits >> 3);
146 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
150 struct rte_crypto_sym_op *sop;
151 union rte_crypto_sym_ofs ofs;
152 struct rte_crypto_sgl sgl;
153 struct rte_crypto_sym_vec symvec;
154 struct rte_crypto_vec vec[UINT8_MAX];
158 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
159 sop->aead.data.length, vec, RTE_DIM(vec));
161 if (n < 0 || n != sop->m_src->nb_segs) {
162 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
169 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
171 symvec.aad = (void **)&sop->aead.aad.data;
172 symvec.digest = (void **)&sop->aead.digest.data;
178 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
182 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
184 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
188 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
192 struct rte_crypto_sym_op *sop;
193 union rte_crypto_sym_ofs ofs;
194 struct rte_crypto_sgl sgl;
195 struct rte_crypto_sym_vec symvec;
196 struct rte_crypto_vec vec[UINT8_MAX];
200 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
201 sop->auth.data.length, vec, RTE_DIM(vec));
203 if (n < 0 || n != sop->m_src->nb_segs) {
204 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
213 symvec.aad = (void **)&sop->aead.aad.data;
214 symvec.digest = (void **)&sop->auth.digest.data;
219 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
220 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
221 (sop->cipher.data.offset + sop->cipher.data.length);
223 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
227 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
229 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
232 static struct rte_crypto_op *
233 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
236 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
239 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
245 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
248 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
249 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
256 static struct crypto_testsuite_params testsuite_params = { NULL };
257 static struct crypto_unittest_params unittest_params;
260 testsuite_setup(void)
262 struct crypto_testsuite_params *ts_params = &testsuite_params;
263 struct rte_cryptodev_info info;
264 uint32_t i = 0, nb_devs, dev_id;
268 memset(ts_params, 0, sizeof(*ts_params));
270 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
271 if (ts_params->mbuf_pool == NULL) {
272 /* Not already created so create */
273 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
275 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
277 if (ts_params->mbuf_pool == NULL) {
278 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
283 ts_params->large_mbuf_pool = rte_mempool_lookup(
284 "CRYPTO_LARGE_MBUFPOOL");
285 if (ts_params->large_mbuf_pool == NULL) {
286 /* Not already created so create */
287 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
288 "CRYPTO_LARGE_MBUFPOOL",
291 if (ts_params->large_mbuf_pool == NULL) {
293 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
298 ts_params->op_mpool = rte_crypto_op_pool_create(
299 "MBUF_CRYPTO_SYM_OP_POOL",
300 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
301 NUM_MBUFS, MBUF_CACHE_SIZE,
303 sizeof(struct rte_crypto_sym_xform) +
306 if (ts_params->op_mpool == NULL) {
307 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
311 /* Create an AESNI MB device if required */
312 if (gbl_driver_id == rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
314 nb_devs = rte_cryptodev_device_count_by_driver(
315 rte_cryptodev_driver_id_get(
316 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
319 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
321 TEST_ASSERT(ret == 0,
322 "Failed to create instance of"
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
328 /* Create an AESNI GCM device if required */
329 if (gbl_driver_id == rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
331 nb_devs = rte_cryptodev_device_count_by_driver(
332 rte_cryptodev_driver_id_get(
333 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
335 TEST_ASSERT_SUCCESS(rte_vdev_init(
336 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
337 "Failed to create instance of"
339 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
343 /* Create a SNOW 3G device if required */
344 if (gbl_driver_id == rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
346 nb_devs = rte_cryptodev_device_count_by_driver(
347 rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
350 TEST_ASSERT_SUCCESS(rte_vdev_init(
351 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
352 "Failed to create instance of"
354 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
358 /* Create a KASUMI device if required */
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
361 nb_devs = rte_cryptodev_device_count_by_driver(
362 rte_cryptodev_driver_id_get(
363 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
365 TEST_ASSERT_SUCCESS(rte_vdev_init(
366 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
367 "Failed to create instance of"
369 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
373 /* Create a ZUC device if required */
374 if (gbl_driver_id == rte_cryptodev_driver_id_get(
375 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
376 nb_devs = rte_cryptodev_device_count_by_driver(
377 rte_cryptodev_driver_id_get(
378 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
380 TEST_ASSERT_SUCCESS(rte_vdev_init(
381 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
382 "Failed to create instance of"
384 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
388 /* Create a NULL device if required */
389 if (gbl_driver_id == rte_cryptodev_driver_id_get(
390 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
396 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance of"
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
405 /* Create an OPENSSL device if required */
406 if (gbl_driver_id == rte_cryptodev_driver_id_get(
407 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
408 nb_devs = rte_cryptodev_device_count_by_driver(
409 rte_cryptodev_driver_id_get(
410 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
413 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
416 TEST_ASSERT(ret == 0, "Failed to create "
417 "instance of pmd : %s",
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
422 /* Create a ARMv8 device if required */
423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
424 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
425 nb_devs = rte_cryptodev_device_count_by_driver(
426 rte_cryptodev_driver_id_get(
427 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
430 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
433 TEST_ASSERT(ret == 0, "Failed to create "
434 "instance of pmd : %s",
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
439 /* Create a MVSAM device if required */
440 if (gbl_driver_id == rte_cryptodev_driver_id_get(
441 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
442 nb_devs = rte_cryptodev_device_count_by_driver(
443 rte_cryptodev_driver_id_get(
444 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
447 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
450 TEST_ASSERT(ret == 0, "Failed to create "
451 "instance of pmd : %s",
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
456 /* Create an CCP device if required */
457 if (gbl_driver_id == rte_cryptodev_driver_id_get(
458 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
459 nb_devs = rte_cryptodev_device_count_by_driver(
460 rte_cryptodev_driver_id_get(
461 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
464 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
467 TEST_ASSERT(ret == 0, "Failed to create "
468 "instance of pmd : %s",
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
473 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
474 char vdev_args[VDEV_ARGS_SIZE] = {""};
475 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
476 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
477 uint16_t slave_core_count = 0;
478 uint16_t socket_id = 0;
480 if (gbl_driver_id == rte_cryptodev_driver_id_get(
481 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
483 /* Identify the Slave Cores
484 * Use 2 slave cores for the device args
486 RTE_LCORE_FOREACH_SLAVE(i) {
487 if (slave_core_count > 1)
489 snprintf(vdev_args, sizeof(vdev_args),
490 "%s%d", temp_str, i);
491 strcpy(temp_str, vdev_args);
492 strlcat(temp_str, ";", sizeof(temp_str));
494 socket_id = rte_lcore_to_socket_id(i);
496 if (slave_core_count != 2) {
498 "Cryptodev scheduler test require at least "
499 "two slave cores to run. "
500 "Please use the correct coremask.\n");
503 strcpy(temp_str, vdev_args);
504 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
505 temp_str, socket_id);
506 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
507 nb_devs = rte_cryptodev_device_count_by_driver(
508 rte_cryptodev_driver_id_get(
509 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
512 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
514 TEST_ASSERT(ret == 0,
515 "Failed to create instance %u of"
517 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
520 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
522 nb_devs = rte_cryptodev_count();
524 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
528 /* Create list of valid crypto devs */
529 for (i = 0; i < nb_devs; i++) {
530 rte_cryptodev_info_get(i, &info);
531 if (info.driver_id == gbl_driver_id)
532 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
535 if (ts_params->valid_dev_count < 1)
538 /* Set up all the qps on the first of the valid devices found */
540 dev_id = ts_params->valid_devs[0];
542 rte_cryptodev_info_get(dev_id, &info);
544 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
545 ts_params->conf.socket_id = SOCKET_ID_ANY;
546 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
548 unsigned int session_size =
549 rte_cryptodev_sym_get_private_session_size(dev_id);
552 * Create mempool with maximum number of sessions * 2,
553 * to include the session headers
555 if (info.sym.max_nb_sessions != 0 &&
556 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
557 RTE_LOG(ERR, USER1, "Device does not support "
558 "at least %u sessions\n",
563 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
564 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
566 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
567 "session mempool allocation failed");
569 ts_params->session_priv_mpool = rte_mempool_create(
573 0, 0, NULL, NULL, NULL,
576 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
577 "session mempool allocation failed");
581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
583 "Failed to configure cryptodev %u with %u qps",
584 dev_id, ts_params->conf.nb_queue_pairs);
586 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
587 ts_params->qp_conf.mp_session = ts_params->session_mpool;
588 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
590 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
591 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
592 dev_id, qp_id, &ts_params->qp_conf,
593 rte_cryptodev_socket_id(dev_id)),
594 "Failed to setup queue pair %u on cryptodev %u",
602 testsuite_teardown(void)
604 struct crypto_testsuite_params *ts_params = &testsuite_params;
606 if (ts_params->mbuf_pool != NULL) {
607 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
608 rte_mempool_avail_count(ts_params->mbuf_pool));
611 if (ts_params->op_mpool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
613 rte_mempool_avail_count(ts_params->op_mpool));
616 /* Free session mempools */
617 if (ts_params->session_priv_mpool != NULL) {
618 rte_mempool_free(ts_params->session_priv_mpool);
619 ts_params->session_priv_mpool = NULL;
622 if (ts_params->session_mpool != NULL) {
623 rte_mempool_free(ts_params->session_mpool);
624 ts_params->session_mpool = NULL;
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct crypto_unittest_params *ut_params = &unittest_params;
636 /* Clear unit test parameters before running test */
637 memset(ut_params, 0, sizeof(*ut_params));
639 /* Reconfigure device to default parameters */
640 ts_params->conf.socket_id = SOCKET_ID_ANY;
641 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
642 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
643 ts_params->qp_conf.mp_session = ts_params->session_mpool;
644 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
646 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 "Failed to configure cryptodev %u",
649 ts_params->valid_devs[0]);
651 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
652 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
653 ts_params->valid_devs[0], qp_id,
655 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
656 "Failed to setup queue pair %u on cryptodev %u",
657 qp_id, ts_params->valid_devs[0]);
661 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
663 /* Start the device */
664 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
665 "Failed to start cryptodev %u",
666 ts_params->valid_devs[0]);
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 struct crypto_unittest_params *ut_params = &unittest_params;
676 struct rte_cryptodev_stats stats;
678 /* free crypto session structure */
679 #ifdef RTE_LIBRTE_SECURITY
680 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
681 if (ut_params->sec_session) {
682 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
683 (ts_params->valid_devs[0]),
684 ut_params->sec_session);
685 ut_params->sec_session = NULL;
690 if (ut_params->sess) {
691 rte_cryptodev_sym_session_clear(
692 ts_params->valid_devs[0],
694 rte_cryptodev_sym_session_free(ut_params->sess);
695 ut_params->sess = NULL;
699 /* free crypto operation structure */
701 rte_crypto_op_free(ut_params->op);
704 * free mbuf - both obuf and ibuf are usually the same,
705 * so check if they point at the same address is necessary,
706 * to avoid freeing the mbuf twice.
708 if (ut_params->obuf) {
709 rte_pktmbuf_free(ut_params->obuf);
710 if (ut_params->ibuf == ut_params->obuf)
714 if (ut_params->ibuf) {
715 rte_pktmbuf_free(ut_params->ibuf);
719 if (ts_params->mbuf_pool != NULL)
720 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
721 rte_mempool_avail_count(ts_params->mbuf_pool));
723 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
725 /* Stop the device */
726 rte_cryptodev_stop(ts_params->valid_devs[0]);
730 test_device_configure_invalid_dev_id(void)
732 struct crypto_testsuite_params *ts_params = &testsuite_params;
733 uint16_t dev_id, num_devs = 0;
735 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
736 "Need at least %d devices for test", 1);
738 /* valid dev_id values */
739 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
741 /* Stop the device in case it's started so it can be configured */
742 rte_cryptodev_stop(dev_id);
744 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
745 "Failed test for rte_cryptodev_configure: "
746 "invalid dev_num %u", dev_id);
748 /* invalid dev_id values */
751 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
752 "Failed test for rte_cryptodev_configure: "
753 "invalid dev_num %u", dev_id);
757 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
758 "Failed test for rte_cryptodev_configure:"
759 "invalid dev_num %u", dev_id);
765 test_device_configure_invalid_queue_pair_ids(void)
767 struct crypto_testsuite_params *ts_params = &testsuite_params;
768 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
770 /* Stop the device in case it's started so it can be configured */
771 rte_cryptodev_stop(ts_params->valid_devs[0]);
773 /* valid - max value queue pairs */
774 ts_params->conf.nb_queue_pairs = orig_nb_qps;
776 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
778 "Failed to configure cryptodev: dev_id %u, qp_id %u",
779 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
781 /* valid - one queue pairs */
782 ts_params->conf.nb_queue_pairs = 1;
784 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
786 "Failed to configure cryptodev: dev_id %u, qp_id %u",
787 ts_params->valid_devs[0],
788 ts_params->conf.nb_queue_pairs);
791 /* invalid - zero queue pairs */
792 ts_params->conf.nb_queue_pairs = 0;
794 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
796 "Failed test for rte_cryptodev_configure, dev_id %u,"
798 ts_params->valid_devs[0],
799 ts_params->conf.nb_queue_pairs);
802 /* invalid - max value supported by field queue pairs */
803 ts_params->conf.nb_queue_pairs = UINT16_MAX;
805 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
807 "Failed test for rte_cryptodev_configure, dev_id %u,"
809 ts_params->valid_devs[0],
810 ts_params->conf.nb_queue_pairs);
813 /* invalid - max value + 1 queue pairs */
814 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
816 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
818 "Failed test for rte_cryptodev_configure, dev_id %u,"
820 ts_params->valid_devs[0],
821 ts_params->conf.nb_queue_pairs);
823 /* revert to original testsuite value */
824 ts_params->conf.nb_queue_pairs = orig_nb_qps;
830 test_queue_pair_descriptor_setup(void)
832 struct crypto_testsuite_params *ts_params = &testsuite_params;
833 struct rte_cryptodev_info dev_info;
834 struct rte_cryptodev_qp_conf qp_conf = {
835 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
840 /* Stop the device in case it's started so it can be configured */
841 rte_cryptodev_stop(ts_params->valid_devs[0]);
843 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
845 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
847 "Failed to configure cryptodev %u",
848 ts_params->valid_devs[0]);
851 * Test various ring sizes on this device. memzones can't be
852 * freed so are re-used if ring is released and re-created.
854 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
855 qp_conf.mp_session = ts_params->session_mpool;
856 qp_conf.mp_session_private = ts_params->session_priv_mpool;
858 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
859 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
860 ts_params->valid_devs[0], qp_id, &qp_conf,
861 rte_cryptodev_socket_id(
862 ts_params->valid_devs[0])),
864 "rte_cryptodev_queue_pair_setup: num_inflights "
865 "%u on qp %u on cryptodev %u",
866 qp_conf.nb_descriptors, qp_id,
867 ts_params->valid_devs[0]);
870 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
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 = MAX_NUM_OPS_INFLIGHT; /* valid */
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 /* invalid number of descriptors - max supported + 2 */
899 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
901 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
902 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
903 ts_params->valid_devs[0], qp_id, &qp_conf,
904 rte_cryptodev_socket_id(
905 ts_params->valid_devs[0])),
906 "Unexpectedly passed test for "
907 "rte_cryptodev_queue_pair_setup:"
908 "num_inflights %u on qp %u on cryptodev %u",
909 qp_conf.nb_descriptors, qp_id,
910 ts_params->valid_devs[0]);
913 /* invalid number of descriptors - max value of parameter */
914 qp_conf.nb_descriptors = UINT32_MAX-1;
916 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
917 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
918 ts_params->valid_devs[0], qp_id, &qp_conf,
919 rte_cryptodev_socket_id(
920 ts_params->valid_devs[0])),
921 "Unexpectedly passed test for "
922 "rte_cryptodev_queue_pair_setup:"
923 "num_inflights %u on qp %u on cryptodev %u",
924 qp_conf.nb_descriptors, qp_id,
925 ts_params->valid_devs[0]);
928 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
930 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
931 TEST_ASSERT_SUCCESS(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])),
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 /* invalid number of descriptors - max supported + 1 */
943 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
945 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
946 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
947 ts_params->valid_devs[0], qp_id, &qp_conf,
948 rte_cryptodev_socket_id(
949 ts_params->valid_devs[0])),
950 "Unexpectedly passed test for "
951 "rte_cryptodev_queue_pair_setup:"
952 "num_inflights %u on qp %u on cryptodev %u",
953 qp_conf.nb_descriptors, qp_id,
954 ts_params->valid_devs[0]);
957 /* test invalid queue pair id */
958 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
960 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
962 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
963 ts_params->valid_devs[0],
965 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
966 "Failed test for rte_cryptodev_queue_pair_setup:"
967 "invalid qp %u on cryptodev %u",
968 qp_id, ts_params->valid_devs[0]);
970 qp_id = 0xffff; /*invalid*/
972 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
973 ts_params->valid_devs[0],
975 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
976 "Failed test for rte_cryptodev_queue_pair_setup:"
977 "invalid qp %u on cryptodev %u",
978 qp_id, ts_params->valid_devs[0]);
983 /* ***** Plaintext data for tests ***** */
985 const char catch_22_quote_1[] =
986 "There was only one catch and that was Catch-22, which "
987 "specified that a concern for one's safety in the face of "
988 "dangers that were real and immediate was the process of a "
989 "rational mind. Orr was crazy and could be grounded. All he "
990 "had to do was ask; and as soon as he did, he would no longer "
991 "be crazy and would have to fly more missions. Orr would be "
992 "crazy to fly more missions and sane if he didn't, but if he "
993 "was sane he had to fly them. If he flew them he was crazy "
994 "and didn't have to; but if he didn't want to he was sane and "
995 "had to. Yossarian was moved very deeply by the absolute "
996 "simplicity of this clause of Catch-22 and let out a "
997 "respectful whistle. \"That's some catch, that Catch-22\", he "
998 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1000 const char catch_22_quote[] =
1001 "What a lousy earth! He wondered how many people were "
1002 "destitute that same night even in his own prosperous country, "
1003 "how many homes were shanties, how many husbands were drunk "
1004 "and wives socked, and how many children were bullied, abused, "
1005 "or abandoned. How many families hungered for food they could "
1006 "not afford to buy? How many hearts were broken? How many "
1007 "suicides would take place that same night, how many people "
1008 "would go insane? How many cockroaches and landlords would "
1009 "triumph? How many winners were losers, successes failures, "
1010 "and rich men poor men? How many wise guys were stupid? How "
1011 "many happy endings were unhappy endings? How many honest men "
1012 "were liars, brave men cowards, loyal men traitors, how many "
1013 "sainted men were corrupt, how many people in positions of "
1014 "trust had sold their souls to bodyguards, how many had never "
1015 "had souls? How many straight-and-narrow paths were crooked "
1016 "paths? How many best families were worst families and how "
1017 "many good people were bad people? When you added them all up "
1018 "and then subtracted, you might be left with only the children, "
1019 "and perhaps with Albert Einstein and an old violinist or "
1020 "sculptor somewhere.";
1022 #define QUOTE_480_BYTES (480)
1023 #define QUOTE_512_BYTES (512)
1024 #define QUOTE_768_BYTES (768)
1025 #define QUOTE_1024_BYTES (1024)
1029 /* ***** SHA1 Hash Tests ***** */
1031 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1033 static uint8_t hmac_sha1_key[] = {
1034 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1035 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1036 0xDE, 0xF4, 0xDE, 0xAD };
1038 /* ***** SHA224 Hash Tests ***** */
1040 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1043 /* ***** AES-CBC Cipher Tests ***** */
1045 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1046 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1048 static uint8_t aes_cbc_key[] = {
1049 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1050 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1052 static uint8_t aes_cbc_iv[] = {
1053 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1054 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1057 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1059 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1060 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1061 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1062 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1063 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1064 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1065 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1066 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1067 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1068 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1069 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1070 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1071 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1072 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1073 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1074 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1075 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1076 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1077 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1078 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1079 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1080 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1081 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1082 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1083 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1084 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1085 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1086 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1087 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1088 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1089 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1090 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1091 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1092 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1093 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1094 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1095 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1096 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1097 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1098 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1099 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1100 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1101 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1102 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1103 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1104 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1105 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1106 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1107 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1108 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1109 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1110 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1111 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1112 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1113 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1114 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1115 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1116 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1117 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1118 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1119 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1120 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1121 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1122 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1123 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1126 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1127 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1128 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1129 0x18, 0x8c, 0x1d, 0x32
1133 /* Multisession Vector context Test */
1134 /*Begin Session 0 */
1135 static uint8_t ms_aes_cbc_key0[] = {
1136 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1137 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1140 static uint8_t ms_aes_cbc_iv0[] = {
1141 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1142 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1145 static const uint8_t ms_aes_cbc_cipher0[] = {
1146 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1147 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1148 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1149 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1150 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1151 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1152 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1153 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1154 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1155 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1156 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1157 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1158 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1159 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1160 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1161 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1162 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1163 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1164 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1165 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1166 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1167 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1168 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1169 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1170 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1171 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1172 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1173 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1174 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1175 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1176 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1177 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1178 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1179 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1180 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1181 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1182 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1183 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1184 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1185 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1186 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1187 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1188 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1189 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1190 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1191 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1192 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1193 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1194 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1195 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1196 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1197 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1198 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1199 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1200 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1201 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1202 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1203 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1204 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1205 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1206 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1207 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1208 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1209 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1213 static uint8_t ms_hmac_key0[] = {
1214 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1215 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1216 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1217 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1218 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1219 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1220 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1221 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1224 static const uint8_t ms_hmac_digest0[] = {
1225 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1226 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1227 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1228 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1229 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1230 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1231 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1232 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1236 /* Begin session 1 */
1238 static uint8_t ms_aes_cbc_key1[] = {
1239 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1240 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1243 static uint8_t ms_aes_cbc_iv1[] = {
1244 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1245 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1248 static const uint8_t ms_aes_cbc_cipher1[] = {
1249 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1250 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1251 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1252 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1253 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1254 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1255 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1256 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1257 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1258 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1259 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1260 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1261 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1262 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1263 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1264 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1265 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1266 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1267 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1268 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1269 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1270 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1271 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1272 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1273 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1274 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1275 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1276 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1277 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1278 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1279 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1280 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1281 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1282 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1283 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1284 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1285 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1286 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1287 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1288 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1289 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1290 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1291 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1292 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1293 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1294 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1295 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1296 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1297 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1298 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1299 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1300 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1301 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1302 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1303 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1304 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1305 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1306 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1307 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1308 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1309 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1310 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1311 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1312 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1316 static uint8_t ms_hmac_key1[] = {
1317 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1318 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1319 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1320 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1321 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1322 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1323 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1324 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1327 static const uint8_t ms_hmac_digest1[] = {
1328 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1329 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1330 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1331 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1332 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1333 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1334 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1335 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1338 /* Begin Session 2 */
1339 static uint8_t ms_aes_cbc_key2[] = {
1340 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1341 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1344 static uint8_t ms_aes_cbc_iv2[] = {
1345 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1346 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1349 static const uint8_t ms_aes_cbc_cipher2[] = {
1350 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1351 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1352 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1353 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1354 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1355 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1356 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1357 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1358 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1359 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1360 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1361 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1362 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1363 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1364 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1365 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1366 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1367 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1368 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1369 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1370 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1371 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1372 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1373 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1374 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1375 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1376 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1377 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1378 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1379 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1380 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1381 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1382 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1383 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1384 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1385 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1386 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1387 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1388 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1389 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1390 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1391 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1392 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1393 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1394 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1395 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1396 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1397 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1398 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1399 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1400 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1401 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1402 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1403 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1404 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1405 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1406 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1407 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1408 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1409 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1410 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1411 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1412 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1413 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1416 static uint8_t ms_hmac_key2[] = {
1417 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1418 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1419 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1420 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1421 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1422 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1423 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1424 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1427 static const uint8_t ms_hmac_digest2[] = {
1428 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1429 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1430 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1431 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1432 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1433 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1434 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1435 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1442 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1444 struct crypto_testsuite_params *ts_params = &testsuite_params;
1445 struct crypto_unittest_params *ut_params = &unittest_params;
1447 /* Verify the capabilities */
1448 struct rte_cryptodev_sym_capability_idx cap_idx;
1449 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1450 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1451 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1454 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1455 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1456 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1460 /* Generate test mbuf data and space for digest */
1461 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1462 catch_22_quote, QUOTE_512_BYTES, 0);
1464 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1465 DIGEST_BYTE_LENGTH_SHA1);
1466 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1468 /* Setup Cipher Parameters */
1469 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1470 ut_params->cipher_xform.next = &ut_params->auth_xform;
1472 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1473 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1474 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1475 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1476 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1477 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1479 /* Setup HMAC Parameters */
1480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1482 ut_params->auth_xform.next = NULL;
1484 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1485 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1486 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1487 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1488 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1490 ut_params->sess = rte_cryptodev_sym_session_create(
1491 ts_params->session_mpool);
1493 /* Create crypto session*/
1494 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1495 ut_params->sess, &ut_params->cipher_xform,
1496 ts_params->session_priv_mpool);
1497 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1499 /* Generate crypto op data structure */
1500 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1501 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1502 TEST_ASSERT_NOT_NULL(ut_params->op,
1503 "Failed to allocate symmetric crypto operation struct");
1505 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1507 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1509 /* set crypto operation source mbuf */
1510 sym_op->m_src = ut_params->ibuf;
1512 /* Set crypto operation authentication parameters */
1513 sym_op->auth.digest.data = ut_params->digest;
1514 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1515 ut_params->ibuf, QUOTE_512_BYTES);
1517 sym_op->auth.data.offset = 0;
1518 sym_op->auth.data.length = QUOTE_512_BYTES;
1520 /* Copy IV at the end of the crypto operation */
1521 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1522 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1524 /* Set crypto operation cipher parameters */
1525 sym_op->cipher.data.offset = 0;
1526 sym_op->cipher.data.length = QUOTE_512_BYTES;
1528 /* Process crypto operation */
1529 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1530 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1533 TEST_ASSERT_NOT_NULL(
1534 process_crypto_request(ts_params->valid_devs[0],
1536 "failed to process sym crypto op");
1538 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1539 "crypto op processing failed");
1542 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1545 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1546 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1548 "ciphertext data not as expected");
1550 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1552 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1553 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1554 gbl_driver_id == rte_cryptodev_driver_id_get(
1555 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1556 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1557 DIGEST_BYTE_LENGTH_SHA1,
1558 "Generated digest data not as expected");
1560 return TEST_SUCCESS;
1563 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1565 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1567 static uint8_t hmac_sha512_key[] = {
1568 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1569 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1570 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1571 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1572 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1573 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1574 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1575 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1577 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1578 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1579 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1580 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1581 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1582 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1583 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1584 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1585 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1590 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1591 struct crypto_unittest_params *ut_params,
1592 uint8_t *cipher_key,
1596 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1597 struct crypto_unittest_params *ut_params,
1598 struct crypto_testsuite_params *ts_params,
1599 const uint8_t *cipher,
1600 const uint8_t *digest,
1605 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1606 struct crypto_unittest_params *ut_params,
1607 uint8_t *cipher_key,
1611 /* Setup Cipher Parameters */
1612 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1613 ut_params->cipher_xform.next = NULL;
1615 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1616 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1617 ut_params->cipher_xform.cipher.key.data = cipher_key;
1618 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1619 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1620 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1622 /* Setup HMAC Parameters */
1623 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1624 ut_params->auth_xform.next = &ut_params->cipher_xform;
1626 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1627 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1628 ut_params->auth_xform.auth.key.data = hmac_key;
1629 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1630 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1632 return TEST_SUCCESS;
1637 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1638 struct crypto_unittest_params *ut_params,
1639 struct crypto_testsuite_params *ts_params,
1640 const uint8_t *cipher,
1641 const uint8_t *digest,
1644 /* Generate test mbuf data and digest */
1645 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1648 QUOTE_512_BYTES, 0);
1650 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1651 DIGEST_BYTE_LENGTH_SHA512);
1652 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1654 rte_memcpy(ut_params->digest,
1656 DIGEST_BYTE_LENGTH_SHA512);
1658 /* Generate Crypto op data structure */
1659 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1660 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1661 TEST_ASSERT_NOT_NULL(ut_params->op,
1662 "Failed to allocate symmetric crypto operation struct");
1664 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1666 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1668 /* set crypto operation source mbuf */
1669 sym_op->m_src = ut_params->ibuf;
1671 sym_op->auth.digest.data = ut_params->digest;
1672 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1673 ut_params->ibuf, QUOTE_512_BYTES);
1675 sym_op->auth.data.offset = 0;
1676 sym_op->auth.data.length = QUOTE_512_BYTES;
1678 /* Copy IV at the end of the crypto operation */
1679 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1680 iv, CIPHER_IV_LENGTH_AES_CBC);
1682 sym_op->cipher.data.offset = 0;
1683 sym_op->cipher.data.length = QUOTE_512_BYTES;
1685 /* Process crypto operation */
1686 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1687 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1690 TEST_ASSERT_NOT_NULL(
1691 process_crypto_request(ts_params->valid_devs[0],
1693 "failed to process sym crypto op");
1695 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1696 "crypto op processing failed");
1698 ut_params->obuf = ut_params->op->sym->m_src;
1701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1702 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1705 "Plaintext data not as expected");
1708 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1709 "Digest verification failed");
1711 return TEST_SUCCESS;
1715 test_blockcipher(enum blockcipher_test_type test_type)
1717 struct crypto_testsuite_params *ts_params = &testsuite_params;
1720 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1721 ts_params->op_mpool,
1722 ts_params->session_mpool, ts_params->session_priv_mpool,
1723 ts_params->valid_devs[0],
1726 if (status == -ENOTSUP)
1729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1731 return TEST_SUCCESS;
1735 test_AES_cipheronly_all(void)
1737 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1741 test_AES_docsis_all(void)
1743 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1747 test_DES_docsis_all(void)
1749 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1753 test_DES_cipheronly_all(void)
1755 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1759 test_authonly_all(void)
1761 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1765 test_AES_chain_all(void)
1767 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1771 test_3DES_chain_all(void)
1773 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1777 test_3DES_cipheronly_all(void)
1779 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1782 /* ***** SNOW 3G Tests ***** */
1784 create_wireless_algo_hash_session(uint8_t dev_id,
1785 const uint8_t *key, const uint8_t key_len,
1786 const uint8_t iv_len, const uint8_t auth_len,
1787 enum rte_crypto_auth_operation op,
1788 enum rte_crypto_auth_algorithm algo)
1790 uint8_t hash_key[key_len];
1793 struct crypto_testsuite_params *ts_params = &testsuite_params;
1794 struct crypto_unittest_params *ut_params = &unittest_params;
1796 memcpy(hash_key, key, key_len);
1798 debug_hexdump(stdout, "key:", key, key_len);
1800 /* Setup Authentication Parameters */
1801 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1802 ut_params->auth_xform.next = NULL;
1804 ut_params->auth_xform.auth.op = op;
1805 ut_params->auth_xform.auth.algo = algo;
1806 ut_params->auth_xform.auth.key.length = key_len;
1807 ut_params->auth_xform.auth.key.data = hash_key;
1808 ut_params->auth_xform.auth.digest_length = auth_len;
1809 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1810 ut_params->auth_xform.auth.iv.length = iv_len;
1811 ut_params->sess = rte_cryptodev_sym_session_create(
1812 ts_params->session_mpool);
1814 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1815 &ut_params->auth_xform,
1816 ts_params->session_priv_mpool);
1817 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1818 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1823 create_wireless_algo_cipher_session(uint8_t dev_id,
1824 enum rte_crypto_cipher_operation op,
1825 enum rte_crypto_cipher_algorithm algo,
1826 const uint8_t *key, const uint8_t key_len,
1829 uint8_t cipher_key[key_len];
1831 struct crypto_testsuite_params *ts_params = &testsuite_params;
1832 struct crypto_unittest_params *ut_params = &unittest_params;
1834 memcpy(cipher_key, key, key_len);
1836 /* Setup Cipher Parameters */
1837 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1838 ut_params->cipher_xform.next = NULL;
1840 ut_params->cipher_xform.cipher.algo = algo;
1841 ut_params->cipher_xform.cipher.op = op;
1842 ut_params->cipher_xform.cipher.key.data = cipher_key;
1843 ut_params->cipher_xform.cipher.key.length = key_len;
1844 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1845 ut_params->cipher_xform.cipher.iv.length = iv_len;
1847 debug_hexdump(stdout, "key:", key, key_len);
1849 /* Create Crypto session */
1850 ut_params->sess = rte_cryptodev_sym_session_create(
1851 ts_params->session_mpool);
1853 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1854 &ut_params->cipher_xform,
1855 ts_params->session_priv_mpool);
1856 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1857 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1862 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1863 unsigned int cipher_len,
1864 unsigned int cipher_offset)
1866 struct crypto_testsuite_params *ts_params = &testsuite_params;
1867 struct crypto_unittest_params *ut_params = &unittest_params;
1869 /* Generate Crypto op data structure */
1870 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1871 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1872 TEST_ASSERT_NOT_NULL(ut_params->op,
1873 "Failed to allocate pktmbuf offload");
1875 /* Set crypto operation data parameters */
1876 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1878 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1880 /* set crypto operation source mbuf */
1881 sym_op->m_src = ut_params->ibuf;
1884 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1886 sym_op->cipher.data.length = cipher_len;
1887 sym_op->cipher.data.offset = cipher_offset;
1892 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1893 unsigned int cipher_len,
1894 unsigned int cipher_offset)
1896 struct crypto_testsuite_params *ts_params = &testsuite_params;
1897 struct crypto_unittest_params *ut_params = &unittest_params;
1899 /* Generate Crypto op data structure */
1900 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1901 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1902 TEST_ASSERT_NOT_NULL(ut_params->op,
1903 "Failed to allocate pktmbuf offload");
1905 /* Set crypto operation data parameters */
1906 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1908 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1910 /* set crypto operation source mbuf */
1911 sym_op->m_src = ut_params->ibuf;
1912 sym_op->m_dst = ut_params->obuf;
1915 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1917 sym_op->cipher.data.length = cipher_len;
1918 sym_op->cipher.data.offset = cipher_offset;
1923 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1924 enum rte_crypto_cipher_operation cipher_op,
1925 enum rte_crypto_auth_operation auth_op,
1926 enum rte_crypto_auth_algorithm auth_algo,
1927 enum rte_crypto_cipher_algorithm cipher_algo,
1928 const uint8_t *key, uint8_t key_len,
1929 uint8_t auth_iv_len, uint8_t auth_len,
1930 uint8_t cipher_iv_len)
1933 uint8_t cipher_auth_key[key_len];
1936 struct crypto_testsuite_params *ts_params = &testsuite_params;
1937 struct crypto_unittest_params *ut_params = &unittest_params;
1939 memcpy(cipher_auth_key, key, key_len);
1941 /* Setup Authentication Parameters */
1942 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1943 ut_params->auth_xform.next = NULL;
1945 ut_params->auth_xform.auth.op = auth_op;
1946 ut_params->auth_xform.auth.algo = auth_algo;
1947 ut_params->auth_xform.auth.key.length = key_len;
1948 /* Hash key = cipher key */
1949 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1950 ut_params->auth_xform.auth.digest_length = auth_len;
1951 /* Auth IV will be after cipher IV */
1952 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1953 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1955 /* Setup Cipher Parameters */
1956 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1957 ut_params->cipher_xform.next = &ut_params->auth_xform;
1959 ut_params->cipher_xform.cipher.algo = cipher_algo;
1960 ut_params->cipher_xform.cipher.op = cipher_op;
1961 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1962 ut_params->cipher_xform.cipher.key.length = key_len;
1963 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1964 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1966 debug_hexdump(stdout, "key:", key, key_len);
1968 /* Create Crypto session*/
1969 ut_params->sess = rte_cryptodev_sym_session_create(
1970 ts_params->session_mpool);
1971 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1973 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1974 &ut_params->cipher_xform,
1975 ts_params->session_priv_mpool);
1976 if (status == -ENOTSUP)
1979 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1984 create_wireless_cipher_auth_session(uint8_t dev_id,
1985 enum rte_crypto_cipher_operation cipher_op,
1986 enum rte_crypto_auth_operation auth_op,
1987 enum rte_crypto_auth_algorithm auth_algo,
1988 enum rte_crypto_cipher_algorithm cipher_algo,
1989 const struct wireless_test_data *tdata)
1991 const uint8_t key_len = tdata->key.len;
1992 uint8_t cipher_auth_key[key_len];
1995 struct crypto_testsuite_params *ts_params = &testsuite_params;
1996 struct crypto_unittest_params *ut_params = &unittest_params;
1997 const uint8_t *key = tdata->key.data;
1998 const uint8_t auth_len = tdata->digest.len;
1999 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2000 uint8_t auth_iv_len = tdata->auth_iv.len;
2002 memcpy(cipher_auth_key, key, key_len);
2004 /* Setup Authentication Parameters */
2005 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2006 ut_params->auth_xform.next = NULL;
2008 ut_params->auth_xform.auth.op = auth_op;
2009 ut_params->auth_xform.auth.algo = auth_algo;
2010 ut_params->auth_xform.auth.key.length = key_len;
2011 /* Hash key = cipher key */
2012 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2013 ut_params->auth_xform.auth.digest_length = auth_len;
2014 /* Auth IV will be after cipher IV */
2015 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2016 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2018 /* Setup Cipher Parameters */
2019 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2020 ut_params->cipher_xform.next = &ut_params->auth_xform;
2022 ut_params->cipher_xform.cipher.algo = cipher_algo;
2023 ut_params->cipher_xform.cipher.op = cipher_op;
2024 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2025 ut_params->cipher_xform.cipher.key.length = key_len;
2026 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2027 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2030 debug_hexdump(stdout, "key:", key, key_len);
2032 /* Create Crypto session*/
2033 ut_params->sess = rte_cryptodev_sym_session_create(
2034 ts_params->session_mpool);
2036 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2037 &ut_params->cipher_xform,
2038 ts_params->session_priv_mpool);
2039 if (status == -ENOTSUP)
2042 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2043 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2048 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2049 const struct wireless_test_data *tdata)
2051 return create_wireless_cipher_auth_session(dev_id,
2052 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2053 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2054 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2058 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2059 enum rte_crypto_cipher_operation cipher_op,
2060 enum rte_crypto_auth_operation auth_op,
2061 enum rte_crypto_auth_algorithm auth_algo,
2062 enum rte_crypto_cipher_algorithm cipher_algo,
2063 const uint8_t *key, const uint8_t key_len,
2064 uint8_t auth_iv_len, uint8_t auth_len,
2065 uint8_t cipher_iv_len)
2067 uint8_t auth_cipher_key[key_len];
2069 struct crypto_testsuite_params *ts_params = &testsuite_params;
2070 struct crypto_unittest_params *ut_params = &unittest_params;
2072 memcpy(auth_cipher_key, key, key_len);
2074 /* Setup Authentication Parameters */
2075 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2076 ut_params->auth_xform.auth.op = auth_op;
2077 ut_params->auth_xform.next = &ut_params->cipher_xform;
2078 ut_params->auth_xform.auth.algo = auth_algo;
2079 ut_params->auth_xform.auth.key.length = key_len;
2080 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2081 ut_params->auth_xform.auth.digest_length = auth_len;
2082 /* Auth IV will be after cipher IV */
2083 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2084 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2086 /* Setup Cipher Parameters */
2087 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2088 ut_params->cipher_xform.next = NULL;
2089 ut_params->cipher_xform.cipher.algo = cipher_algo;
2090 ut_params->cipher_xform.cipher.op = cipher_op;
2091 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2092 ut_params->cipher_xform.cipher.key.length = key_len;
2093 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2094 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2096 debug_hexdump(stdout, "key:", key, key_len);
2098 /* Create Crypto session*/
2099 ut_params->sess = rte_cryptodev_sym_session_create(
2100 ts_params->session_mpool);
2101 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2103 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2104 ut_params->auth_xform.next = NULL;
2105 ut_params->cipher_xform.next = &ut_params->auth_xform;
2106 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2107 &ut_params->cipher_xform,
2108 ts_params->session_priv_mpool);
2111 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2112 &ut_params->auth_xform,
2113 ts_params->session_priv_mpool);
2115 if (status == -ENOTSUP)
2118 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2124 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2125 unsigned int auth_tag_len,
2126 const uint8_t *iv, unsigned int iv_len,
2127 unsigned int data_pad_len,
2128 enum rte_crypto_auth_operation op,
2129 unsigned int auth_len, unsigned int auth_offset)
2131 struct crypto_testsuite_params *ts_params = &testsuite_params;
2133 struct crypto_unittest_params *ut_params = &unittest_params;
2135 /* Generate Crypto op data structure */
2136 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2137 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2138 TEST_ASSERT_NOT_NULL(ut_params->op,
2139 "Failed to allocate pktmbuf offload");
2141 /* Set crypto operation data parameters */
2142 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2144 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2146 /* set crypto operation source mbuf */
2147 sym_op->m_src = ut_params->ibuf;
2150 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2153 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2154 ut_params->ibuf, auth_tag_len);
2156 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2157 "no room to append auth tag");
2158 ut_params->digest = sym_op->auth.digest.data;
2159 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2160 ut_params->ibuf, data_pad_len);
2161 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2162 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2164 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2166 debug_hexdump(stdout, "digest:",
2167 sym_op->auth.digest.data,
2170 sym_op->auth.data.length = auth_len;
2171 sym_op->auth.data.offset = auth_offset;
2177 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2178 enum rte_crypto_auth_operation op)
2180 struct crypto_testsuite_params *ts_params = &testsuite_params;
2181 struct crypto_unittest_params *ut_params = &unittest_params;
2183 const uint8_t *auth_tag = tdata->digest.data;
2184 const unsigned int auth_tag_len = tdata->digest.len;
2185 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2186 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2188 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2189 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2190 const uint8_t *auth_iv = tdata->auth_iv.data;
2191 const uint8_t auth_iv_len = tdata->auth_iv.len;
2192 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2193 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2195 /* Generate Crypto op data structure */
2196 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2197 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2198 TEST_ASSERT_NOT_NULL(ut_params->op,
2199 "Failed to allocate pktmbuf offload");
2200 /* Set crypto operation data parameters */
2201 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2203 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2205 /* set crypto operation source mbuf */
2206 sym_op->m_src = ut_params->ibuf;
2209 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2210 ut_params->ibuf, auth_tag_len);
2212 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2213 "no room to append auth tag");
2214 ut_params->digest = sym_op->auth.digest.data;
2215 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2216 ut_params->ibuf, data_pad_len);
2217 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2218 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2220 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2222 debug_hexdump(stdout, "digest:",
2223 sym_op->auth.digest.data,
2226 /* Copy cipher and auth IVs at the end of the crypto operation */
2227 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2229 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2230 iv_ptr += cipher_iv_len;
2231 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2233 sym_op->cipher.data.length = cipher_len;
2234 sym_op->cipher.data.offset = 0;
2235 sym_op->auth.data.length = auth_len;
2236 sym_op->auth.data.offset = 0;
2242 create_zuc_cipher_hash_generate_operation(
2243 const struct wireless_test_data *tdata)
2245 return create_wireless_cipher_hash_operation(tdata,
2246 RTE_CRYPTO_AUTH_OP_GENERATE);
2250 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2251 const unsigned auth_tag_len,
2252 const uint8_t *auth_iv, uint8_t auth_iv_len,
2253 unsigned data_pad_len,
2254 enum rte_crypto_auth_operation op,
2255 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2256 const unsigned cipher_len, const unsigned cipher_offset,
2257 const unsigned auth_len, const unsigned auth_offset)
2259 struct crypto_testsuite_params *ts_params = &testsuite_params;
2260 struct crypto_unittest_params *ut_params = &unittest_params;
2262 enum rte_crypto_cipher_algorithm cipher_algo =
2263 ut_params->cipher_xform.cipher.algo;
2264 enum rte_crypto_auth_algorithm auth_algo =
2265 ut_params->auth_xform.auth.algo;
2267 /* Generate Crypto op data structure */
2268 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2269 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2270 TEST_ASSERT_NOT_NULL(ut_params->op,
2271 "Failed to allocate pktmbuf offload");
2272 /* Set crypto operation data parameters */
2273 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2275 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2277 /* set crypto operation source mbuf */
2278 sym_op->m_src = ut_params->ibuf;
2281 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2282 ut_params->ibuf, auth_tag_len);
2284 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2285 "no room to append auth tag");
2286 ut_params->digest = sym_op->auth.digest.data;
2288 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2289 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2290 ut_params->ibuf, data_pad_len);
2292 struct rte_mbuf *m = ut_params->ibuf;
2293 unsigned int offset = data_pad_len;
2295 while (offset > m->data_len && m->next != NULL) {
2296 offset -= m->data_len;
2299 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2303 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2304 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2306 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2308 debug_hexdump(stdout, "digest:",
2309 sym_op->auth.digest.data,
2312 /* Copy cipher and auth IVs at the end of the crypto operation */
2313 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2315 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2316 iv_ptr += cipher_iv_len;
2317 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2319 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2320 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2321 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2322 sym_op->cipher.data.length = cipher_len;
2323 sym_op->cipher.data.offset = cipher_offset;
2325 sym_op->cipher.data.length = cipher_len >> 3;
2326 sym_op->cipher.data.offset = cipher_offset >> 3;
2329 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2330 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2331 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2332 sym_op->auth.data.length = auth_len;
2333 sym_op->auth.data.offset = auth_offset;
2335 sym_op->auth.data.length = auth_len >> 3;
2336 sym_op->auth.data.offset = auth_offset >> 3;
2343 create_wireless_algo_auth_cipher_operation(
2344 const uint8_t *auth_tag, unsigned int auth_tag_len,
2345 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2346 const uint8_t *auth_iv, uint8_t auth_iv_len,
2347 unsigned int data_pad_len,
2348 unsigned int cipher_len, unsigned int cipher_offset,
2349 unsigned int auth_len, unsigned int auth_offset,
2350 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2352 struct crypto_testsuite_params *ts_params = &testsuite_params;
2353 struct crypto_unittest_params *ut_params = &unittest_params;
2355 enum rte_crypto_cipher_algorithm cipher_algo =
2356 ut_params->cipher_xform.cipher.algo;
2357 enum rte_crypto_auth_algorithm auth_algo =
2358 ut_params->auth_xform.auth.algo;
2360 /* Generate Crypto op data structure */
2361 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2362 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2363 TEST_ASSERT_NOT_NULL(ut_params->op,
2364 "Failed to allocate pktmbuf offload");
2366 /* Set crypto operation data parameters */
2367 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2369 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2371 /* set crypto operation mbufs */
2372 sym_op->m_src = ut_params->ibuf;
2373 if (op_mode == OUT_OF_PLACE)
2374 sym_op->m_dst = ut_params->obuf;
2378 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2379 (op_mode == IN_PLACE ?
2380 ut_params->ibuf : ut_params->obuf),
2381 uint8_t *, data_pad_len);
2382 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2383 (op_mode == IN_PLACE ?
2384 ut_params->ibuf : ut_params->obuf),
2386 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2388 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2389 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2390 sym_op->m_src : sym_op->m_dst);
2391 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2392 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2393 sgl_buf = sgl_buf->next;
2395 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2396 uint8_t *, remaining_off);
2397 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2399 memset(sym_op->auth.digest.data, 0, remaining_off);
2400 while (sgl_buf->next != NULL) {
2401 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2402 0, rte_pktmbuf_data_len(sgl_buf));
2403 sgl_buf = sgl_buf->next;
2407 /* Copy digest for the verification */
2409 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2411 /* Copy cipher and auth IVs at the end of the crypto operation */
2412 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2413 ut_params->op, uint8_t *, IV_OFFSET);
2415 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2416 iv_ptr += cipher_iv_len;
2417 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2419 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2420 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2421 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2422 sym_op->cipher.data.length = cipher_len;
2423 sym_op->cipher.data.offset = cipher_offset;
2425 sym_op->cipher.data.length = cipher_len >> 3;
2426 sym_op->cipher.data.offset = cipher_offset >> 3;
2429 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2430 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2431 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2432 sym_op->auth.data.length = auth_len;
2433 sym_op->auth.data.offset = auth_offset;
2435 sym_op->auth.data.length = auth_len >> 3;
2436 sym_op->auth.data.offset = auth_offset >> 3;
2443 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2445 struct crypto_testsuite_params *ts_params = &testsuite_params;
2446 struct crypto_unittest_params *ut_params = &unittest_params;
2449 unsigned plaintext_pad_len;
2450 unsigned plaintext_len;
2452 struct rte_cryptodev_info dev_info;
2454 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2455 uint64_t feat_flags = dev_info.feature_flags;
2457 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2458 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2459 printf("Device doesn't support NON-Byte Aligned Data.\n");
2463 /* Verify the capabilities */
2464 struct rte_cryptodev_sym_capability_idx cap_idx;
2465 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2466 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2467 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2471 /* Create SNOW 3G session */
2472 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2473 tdata->key.data, tdata->key.len,
2474 tdata->auth_iv.len, tdata->digest.len,
2475 RTE_CRYPTO_AUTH_OP_GENERATE,
2476 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2480 /* alloc mbuf and set payload */
2481 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2484 rte_pktmbuf_tailroom(ut_params->ibuf));
2486 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2487 /* Append data which is padded to a multiple of */
2488 /* the algorithms block size */
2489 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2490 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2492 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2494 /* Create SNOW 3G operation */
2495 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2496 tdata->auth_iv.data, tdata->auth_iv.len,
2497 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2498 tdata->validAuthLenInBits.len,
2503 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2505 ut_params->obuf = ut_params->op->sym->m_src;
2506 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2507 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2508 + plaintext_pad_len;
2511 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2514 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2515 "SNOW 3G Generated auth tag not as expected");
2521 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2523 struct crypto_testsuite_params *ts_params = &testsuite_params;
2524 struct crypto_unittest_params *ut_params = &unittest_params;
2527 unsigned plaintext_pad_len;
2528 unsigned plaintext_len;
2530 struct rte_cryptodev_info dev_info;
2532 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2533 uint64_t feat_flags = dev_info.feature_flags;
2535 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2536 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2537 printf("Device doesn't support NON-Byte Aligned Data.\n");
2541 /* Verify the capabilities */
2542 struct rte_cryptodev_sym_capability_idx cap_idx;
2543 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2544 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2545 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2549 /* Create SNOW 3G session */
2550 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2551 tdata->key.data, tdata->key.len,
2552 tdata->auth_iv.len, tdata->digest.len,
2553 RTE_CRYPTO_AUTH_OP_VERIFY,
2554 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2557 /* alloc mbuf and set payload */
2558 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2560 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2561 rte_pktmbuf_tailroom(ut_params->ibuf));
2563 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2564 /* Append data which is padded to a multiple of */
2565 /* the algorithms block size */
2566 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2567 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2569 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2571 /* Create SNOW 3G operation */
2572 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2574 tdata->auth_iv.data, tdata->auth_iv.len,
2576 RTE_CRYPTO_AUTH_OP_VERIFY,
2577 tdata->validAuthLenInBits.len,
2582 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2584 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2585 ut_params->obuf = ut_params->op->sym->m_src;
2586 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2587 + plaintext_pad_len;
2590 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2599 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2601 struct crypto_testsuite_params *ts_params = &testsuite_params;
2602 struct crypto_unittest_params *ut_params = &unittest_params;
2605 unsigned plaintext_pad_len;
2606 unsigned plaintext_len;
2609 /* Verify the capabilities */
2610 struct rte_cryptodev_sym_capability_idx cap_idx;
2611 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2612 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2613 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2617 /* Create KASUMI session */
2618 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2619 tdata->key.data, tdata->key.len,
2620 0, tdata->digest.len,
2621 RTE_CRYPTO_AUTH_OP_GENERATE,
2622 RTE_CRYPTO_AUTH_KASUMI_F9);
2626 /* alloc mbuf and set payload */
2627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2629 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2630 rte_pktmbuf_tailroom(ut_params->ibuf));
2632 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2633 /* Append data which is padded to a multiple of */
2634 /* the algorithms block size */
2635 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2636 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2638 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2640 /* Create KASUMI operation */
2641 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2643 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2644 tdata->plaintext.len,
2649 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2650 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2653 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2656 ut_params->obuf = ut_params->op->sym->m_src;
2657 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2658 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2659 + plaintext_pad_len;
2662 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2665 DIGEST_BYTE_LENGTH_KASUMI_F9,
2666 "KASUMI Generated auth tag not as expected");
2672 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2674 struct crypto_testsuite_params *ts_params = &testsuite_params;
2675 struct crypto_unittest_params *ut_params = &unittest_params;
2678 unsigned plaintext_pad_len;
2679 unsigned plaintext_len;
2682 /* Verify the capabilities */
2683 struct rte_cryptodev_sym_capability_idx cap_idx;
2684 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2685 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2686 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2690 /* Create KASUMI session */
2691 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2692 tdata->key.data, tdata->key.len,
2693 0, tdata->digest.len,
2694 RTE_CRYPTO_AUTH_OP_VERIFY,
2695 RTE_CRYPTO_AUTH_KASUMI_F9);
2698 /* alloc mbuf and set payload */
2699 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2701 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2702 rte_pktmbuf_tailroom(ut_params->ibuf));
2704 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2705 /* Append data which is padded to a multiple */
2706 /* of the algorithms block size */
2707 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2708 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2710 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2712 /* Create KASUMI operation */
2713 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2717 RTE_CRYPTO_AUTH_OP_VERIFY,
2718 tdata->plaintext.len,
2723 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2725 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2726 ut_params->obuf = ut_params->op->sym->m_src;
2727 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2728 + plaintext_pad_len;
2731 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2740 test_snow3g_hash_generate_test_case_1(void)
2742 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2746 test_snow3g_hash_generate_test_case_2(void)
2748 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2752 test_snow3g_hash_generate_test_case_3(void)
2754 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2758 test_snow3g_hash_generate_test_case_4(void)
2760 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2764 test_snow3g_hash_generate_test_case_5(void)
2766 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2770 test_snow3g_hash_generate_test_case_6(void)
2772 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2776 test_snow3g_hash_verify_test_case_1(void)
2778 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2783 test_snow3g_hash_verify_test_case_2(void)
2785 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2789 test_snow3g_hash_verify_test_case_3(void)
2791 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2795 test_snow3g_hash_verify_test_case_4(void)
2797 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2801 test_snow3g_hash_verify_test_case_5(void)
2803 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2807 test_snow3g_hash_verify_test_case_6(void)
2809 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2813 test_kasumi_hash_generate_test_case_1(void)
2815 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2819 test_kasumi_hash_generate_test_case_2(void)
2821 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2825 test_kasumi_hash_generate_test_case_3(void)
2827 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2831 test_kasumi_hash_generate_test_case_4(void)
2833 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2837 test_kasumi_hash_generate_test_case_5(void)
2839 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2843 test_kasumi_hash_generate_test_case_6(void)
2845 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2849 test_kasumi_hash_verify_test_case_1(void)
2851 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2855 test_kasumi_hash_verify_test_case_2(void)
2857 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2861 test_kasumi_hash_verify_test_case_3(void)
2863 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2867 test_kasumi_hash_verify_test_case_4(void)
2869 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2873 test_kasumi_hash_verify_test_case_5(void)
2875 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2879 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2881 struct crypto_testsuite_params *ts_params = &testsuite_params;
2882 struct crypto_unittest_params *ut_params = &unittest_params;
2885 uint8_t *plaintext, *ciphertext;
2886 unsigned plaintext_pad_len;
2887 unsigned plaintext_len;
2889 /* Verify the capabilities */
2890 struct rte_cryptodev_sym_capability_idx cap_idx;
2891 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2892 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2893 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2897 /* Create KASUMI session */
2898 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2899 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2900 RTE_CRYPTO_CIPHER_KASUMI_F8,
2901 tdata->key.data, tdata->key.len,
2902 tdata->cipher_iv.len);
2906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2908 /* Clear mbuf payload */
2909 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2910 rte_pktmbuf_tailroom(ut_params->ibuf));
2912 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2913 /* Append data which is padded to a multiple */
2914 /* of the algorithms block size */
2915 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2916 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2918 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2920 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2922 /* Create KASUMI operation */
2923 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2924 tdata->cipher_iv.len,
2925 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2926 tdata->validCipherOffsetInBits.len);
2930 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2932 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2934 ut_params->obuf = ut_params->op->sym->m_dst;
2935 if (ut_params->obuf)
2936 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2938 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2940 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2942 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2943 (tdata->validCipherOffsetInBits.len >> 3);
2945 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2947 reference_ciphertext,
2948 tdata->validCipherLenInBits.len,
2949 "KASUMI Ciphertext data not as expected");
2954 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2956 struct crypto_testsuite_params *ts_params = &testsuite_params;
2957 struct crypto_unittest_params *ut_params = &unittest_params;
2961 unsigned int plaintext_pad_len;
2962 unsigned int plaintext_len;
2964 uint8_t buffer[10000];
2965 const uint8_t *ciphertext;
2967 struct rte_cryptodev_info dev_info;
2969 /* Verify the capabilities */
2970 struct rte_cryptodev_sym_capability_idx cap_idx;
2971 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2972 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2973 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2977 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2979 uint64_t feat_flags = dev_info.feature_flags;
2981 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2982 printf("Device doesn't support in-place scatter-gather. "
2987 /* Create KASUMI session */
2988 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2989 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2990 RTE_CRYPTO_CIPHER_KASUMI_F8,
2991 tdata->key.data, tdata->key.len,
2992 tdata->cipher_iv.len);
2996 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2999 /* Append data which is padded to a multiple */
3000 /* of the algorithms block size */
3001 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3003 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3004 plaintext_pad_len, 10, 0);
3006 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3008 /* Create KASUMI operation */
3009 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3010 tdata->cipher_iv.len,
3011 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3012 tdata->validCipherOffsetInBits.len);
3016 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3018 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3020 ut_params->obuf = ut_params->op->sym->m_dst;
3022 if (ut_params->obuf)
3023 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3024 plaintext_len, buffer);
3026 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3027 tdata->validCipherOffsetInBits.len >> 3,
3028 plaintext_len, buffer);
3031 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3033 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3034 (tdata->validCipherOffsetInBits.len >> 3);
3036 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3038 reference_ciphertext,
3039 tdata->validCipherLenInBits.len,
3040 "KASUMI Ciphertext data not as expected");
3045 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3047 struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 struct crypto_unittest_params *ut_params = &unittest_params;
3051 uint8_t *plaintext, *ciphertext;
3052 unsigned plaintext_pad_len;
3053 unsigned plaintext_len;
3055 /* Verify the capabilities */
3056 struct rte_cryptodev_sym_capability_idx cap_idx;
3057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3058 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3063 /* Create KASUMI session */
3064 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3065 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3066 RTE_CRYPTO_CIPHER_KASUMI_F8,
3067 tdata->key.data, tdata->key.len,
3068 tdata->cipher_iv.len);
3072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3073 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3075 /* Clear mbuf payload */
3076 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3077 rte_pktmbuf_tailroom(ut_params->ibuf));
3079 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3080 /* Append data which is padded to a multiple */
3081 /* of the algorithms block size */
3082 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3083 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3085 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3086 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3088 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3090 /* Create KASUMI operation */
3091 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3092 tdata->cipher_iv.len,
3093 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3094 tdata->validCipherOffsetInBits.len);
3098 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3100 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3102 ut_params->obuf = ut_params->op->sym->m_dst;
3103 if (ut_params->obuf)
3104 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3106 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3108 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3110 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3111 (tdata->validCipherOffsetInBits.len >> 3);
3113 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3115 reference_ciphertext,
3116 tdata->validCipherLenInBits.len,
3117 "KASUMI Ciphertext data not as expected");
3122 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3124 struct crypto_testsuite_params *ts_params = &testsuite_params;
3125 struct crypto_unittest_params *ut_params = &unittest_params;
3128 unsigned int plaintext_pad_len;
3129 unsigned int plaintext_len;
3131 const uint8_t *ciphertext;
3132 uint8_t buffer[2048];
3134 struct rte_cryptodev_info dev_info;
3136 /* Verify the capabilities */
3137 struct rte_cryptodev_sym_capability_idx cap_idx;
3138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3139 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3144 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3146 uint64_t feat_flags = dev_info.feature_flags;
3147 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3148 printf("Device doesn't support out-of-place scatter-gather "
3149 "in both input and output mbufs. "
3154 /* Create KASUMI session */
3155 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3156 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3157 RTE_CRYPTO_CIPHER_KASUMI_F8,
3158 tdata->key.data, tdata->key.len,
3159 tdata->cipher_iv.len);
3163 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3164 /* Append data which is padded to a multiple */
3165 /* of the algorithms block size */
3166 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3168 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3169 plaintext_pad_len, 10, 0);
3170 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3171 plaintext_pad_len, 3, 0);
3173 /* Append data which is padded to a multiple */
3174 /* of the algorithms block size */
3175 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3177 /* Create KASUMI operation */
3178 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3179 tdata->cipher_iv.len,
3180 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3181 tdata->validCipherOffsetInBits.len);
3185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3189 ut_params->obuf = ut_params->op->sym->m_dst;
3190 if (ut_params->obuf)
3191 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3192 plaintext_pad_len, buffer);
3194 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3195 tdata->validCipherOffsetInBits.len >> 3,
3196 plaintext_pad_len, buffer);
3198 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3199 (tdata->validCipherOffsetInBits.len >> 3);
3201 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3203 reference_ciphertext,
3204 tdata->validCipherLenInBits.len,
3205 "KASUMI Ciphertext data not as expected");
3211 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3213 struct crypto_testsuite_params *ts_params = &testsuite_params;
3214 struct crypto_unittest_params *ut_params = &unittest_params;
3217 uint8_t *ciphertext, *plaintext;
3218 unsigned ciphertext_pad_len;
3219 unsigned ciphertext_len;
3221 /* Verify the capabilities */
3222 struct rte_cryptodev_sym_capability_idx cap_idx;
3223 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3224 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3225 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3229 /* Create KASUMI session */
3230 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3231 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3232 RTE_CRYPTO_CIPHER_KASUMI_F8,
3233 tdata->key.data, tdata->key.len,
3234 tdata->cipher_iv.len);
3238 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3239 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3241 /* Clear mbuf payload */
3242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3243 rte_pktmbuf_tailroom(ut_params->ibuf));
3245 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3246 /* Append data which is padded to a multiple */
3247 /* of the algorithms block size */
3248 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3249 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3250 ciphertext_pad_len);
3251 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3252 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3254 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3256 /* Create KASUMI operation */
3257 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3258 tdata->cipher_iv.len,
3259 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3260 tdata->validCipherOffsetInBits.len);
3264 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3266 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3268 ut_params->obuf = ut_params->op->sym->m_dst;
3269 if (ut_params->obuf)
3270 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3272 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3274 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3276 const uint8_t *reference_plaintext = tdata->plaintext.data +
3277 (tdata->validCipherOffsetInBits.len >> 3);
3279 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3281 reference_plaintext,
3282 tdata->validCipherLenInBits.len,
3283 "KASUMI Plaintext data not as expected");
3288 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3290 struct crypto_testsuite_params *ts_params = &testsuite_params;
3291 struct crypto_unittest_params *ut_params = &unittest_params;
3294 uint8_t *ciphertext, *plaintext;
3295 unsigned ciphertext_pad_len;
3296 unsigned ciphertext_len;
3298 /* Verify the capabilities */
3299 struct rte_cryptodev_sym_capability_idx cap_idx;
3300 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3301 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3302 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3306 /* Create KASUMI session */
3307 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3308 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3309 RTE_CRYPTO_CIPHER_KASUMI_F8,
3310 tdata->key.data, tdata->key.len,
3311 tdata->cipher_iv.len);
3315 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3317 /* Clear mbuf payload */
3318 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3319 rte_pktmbuf_tailroom(ut_params->ibuf));
3321 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3322 /* Append data which is padded to a multiple */
3323 /* of the algorithms block size */
3324 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3325 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3326 ciphertext_pad_len);
3327 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3329 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3331 /* Create KASUMI operation */
3332 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3333 tdata->cipher_iv.len,
3334 tdata->ciphertext.len,
3335 tdata->validCipherOffsetInBits.len);
3339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3343 ut_params->obuf = ut_params->op->sym->m_dst;
3344 if (ut_params->obuf)
3345 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3347 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3349 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3351 const uint8_t *reference_plaintext = tdata->plaintext.data +
3352 (tdata->validCipherOffsetInBits.len >> 3);
3354 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3356 reference_plaintext,
3357 tdata->validCipherLenInBits.len,
3358 "KASUMI Plaintext data not as expected");
3363 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3365 struct crypto_testsuite_params *ts_params = &testsuite_params;
3366 struct crypto_unittest_params *ut_params = &unittest_params;
3369 uint8_t *plaintext, *ciphertext;
3370 unsigned plaintext_pad_len;
3371 unsigned plaintext_len;
3373 /* Verify the capabilities */
3374 struct rte_cryptodev_sym_capability_idx cap_idx;
3375 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3376 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3381 /* Create SNOW 3G session */
3382 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3383 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3384 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3385 tdata->key.data, tdata->key.len,
3386 tdata->cipher_iv.len);
3390 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3392 /* Clear mbuf payload */
3393 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3394 rte_pktmbuf_tailroom(ut_params->ibuf));
3396 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3397 /* Append data which is padded to a multiple of */
3398 /* the algorithms block size */
3399 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3400 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3402 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3404 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3406 /* Create SNOW 3G operation */
3407 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3408 tdata->cipher_iv.len,
3409 tdata->validCipherLenInBits.len,
3414 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3416 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3418 ut_params->obuf = ut_params->op->sym->m_dst;
3419 if (ut_params->obuf)
3420 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3422 ciphertext = plaintext;
3424 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3429 tdata->ciphertext.data,
3430 tdata->validDataLenInBits.len,
3431 "SNOW 3G Ciphertext data not as expected");
3437 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3439 struct crypto_testsuite_params *ts_params = &testsuite_params;
3440 struct crypto_unittest_params *ut_params = &unittest_params;
3441 uint8_t *plaintext, *ciphertext;
3444 unsigned plaintext_pad_len;
3445 unsigned plaintext_len;
3447 /* Verify the capabilities */
3448 struct rte_cryptodev_sym_capability_idx cap_idx;
3449 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3450 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3451 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3455 /* Create SNOW 3G session */
3456 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3457 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3458 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3459 tdata->key.data, tdata->key.len,
3460 tdata->cipher_iv.len);
3464 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3465 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3467 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3468 "Failed to allocate input buffer in mempool");
3469 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3470 "Failed to allocate output buffer in mempool");
3472 /* Clear mbuf payload */
3473 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3474 rte_pktmbuf_tailroom(ut_params->ibuf));
3476 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3477 /* Append data which is padded to a multiple of */
3478 /* the algorithms block size */
3479 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3480 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3482 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3483 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3485 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3487 /* Create SNOW 3G operation */
3488 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3489 tdata->cipher_iv.len,
3490 tdata->validCipherLenInBits.len,
3495 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3497 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3499 ut_params->obuf = ut_params->op->sym->m_dst;
3500 if (ut_params->obuf)
3501 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3503 ciphertext = plaintext;
3505 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3508 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3510 tdata->ciphertext.data,
3511 tdata->validDataLenInBits.len,
3512 "SNOW 3G Ciphertext data not as expected");
3517 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3519 struct crypto_testsuite_params *ts_params = &testsuite_params;
3520 struct crypto_unittest_params *ut_params = &unittest_params;
3523 unsigned int plaintext_pad_len;
3524 unsigned int plaintext_len;
3525 uint8_t buffer[10000];
3526 const uint8_t *ciphertext;
3528 struct rte_cryptodev_info dev_info;
3530 /* Verify the capabilities */
3531 struct rte_cryptodev_sym_capability_idx cap_idx;
3532 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3533 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3534 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3538 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3540 uint64_t feat_flags = dev_info.feature_flags;
3542 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3543 printf("Device doesn't support out-of-place scatter-gather "
3544 "in both input and output mbufs. "
3549 /* Create SNOW 3G session */
3550 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3551 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3552 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3553 tdata->key.data, tdata->key.len,
3554 tdata->cipher_iv.len);
3558 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3559 /* Append data which is padded to a multiple of */
3560 /* the algorithms block size */
3561 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3563 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3564 plaintext_pad_len, 10, 0);
3565 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3566 plaintext_pad_len, 3, 0);
3568 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3569 "Failed to allocate input buffer in mempool");
3570 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3571 "Failed to allocate output buffer in mempool");
3573 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3575 /* Create SNOW 3G operation */
3576 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3577 tdata->cipher_iv.len,
3578 tdata->validCipherLenInBits.len,
3583 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3585 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3587 ut_params->obuf = ut_params->op->sym->m_dst;
3588 if (ut_params->obuf)
3589 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3590 plaintext_len, buffer);
3592 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3593 plaintext_len, buffer);
3595 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3598 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3600 tdata->ciphertext.data,
3601 tdata->validDataLenInBits.len,
3602 "SNOW 3G Ciphertext data not as expected");
3607 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3609 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3611 uint8_t curr_byte, prev_byte;
3612 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3613 uint8_t lower_byte_mask = (1 << offset) - 1;
3616 prev_byte = buffer[0];
3617 buffer[0] >>= offset;
3619 for (i = 1; i < length_in_bytes; i++) {
3620 curr_byte = buffer[i];
3621 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3622 (curr_byte >> offset);
3623 prev_byte = curr_byte;
3628 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3630 struct crypto_testsuite_params *ts_params = &testsuite_params;
3631 struct crypto_unittest_params *ut_params = &unittest_params;
3632 uint8_t *plaintext, *ciphertext;
3634 uint32_t plaintext_len;
3635 uint32_t plaintext_pad_len;
3636 uint8_t extra_offset = 4;
3637 uint8_t *expected_ciphertext_shifted;
3638 struct rte_cryptodev_info dev_info;
3640 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3641 uint64_t feat_flags = dev_info.feature_flags;
3643 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3644 ((tdata->validDataLenInBits.len % 8) != 0)) {
3645 printf("Device doesn't support NON-Byte Aligned Data.\n");
3649 /* Verify the capabilities */
3650 struct rte_cryptodev_sym_capability_idx cap_idx;
3651 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3652 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3653 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3657 /* Create SNOW 3G session */
3658 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3659 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3660 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3661 tdata->key.data, tdata->key.len,
3662 tdata->cipher_iv.len);
3666 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3667 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3669 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3670 "Failed to allocate input buffer in mempool");
3671 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3672 "Failed to allocate output buffer in mempool");
3674 /* Clear mbuf payload */
3675 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3676 rte_pktmbuf_tailroom(ut_params->ibuf));
3678 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3680 * Append data which is padded to a
3681 * multiple of the algorithms block size
3683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3685 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3688 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3690 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3691 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3693 #ifdef RTE_APP_TEST_DEBUG
3694 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3696 /* Create SNOW 3G operation */
3697 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3698 tdata->cipher_iv.len,
3699 tdata->validCipherLenInBits.len,
3704 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3706 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3708 ut_params->obuf = ut_params->op->sym->m_dst;
3709 if (ut_params->obuf)
3710 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3712 ciphertext = plaintext;
3714 #ifdef RTE_APP_TEST_DEBUG
3715 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3718 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3720 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3721 "failed to reserve memory for ciphertext shifted\n");
3723 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3724 ceil_byte_length(tdata->ciphertext.len));
3725 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3728 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3730 expected_ciphertext_shifted,
3731 tdata->validDataLenInBits.len,
3733 "SNOW 3G Ciphertext data not as expected");
3737 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3739 struct crypto_testsuite_params *ts_params = &testsuite_params;
3740 struct crypto_unittest_params *ut_params = &unittest_params;
3744 uint8_t *plaintext, *ciphertext;
3745 unsigned ciphertext_pad_len;
3746 unsigned ciphertext_len;
3748 /* Verify the capabilities */
3749 struct rte_cryptodev_sym_capability_idx cap_idx;
3750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3751 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3752 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3756 /* Create SNOW 3G session */
3757 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3758 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3759 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3760 tdata->key.data, tdata->key.len,
3761 tdata->cipher_iv.len);
3765 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3767 /* Clear mbuf payload */
3768 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3769 rte_pktmbuf_tailroom(ut_params->ibuf));
3771 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3772 /* Append data which is padded to a multiple of */
3773 /* the algorithms block size */
3774 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3775 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3776 ciphertext_pad_len);
3777 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3779 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3781 /* Create SNOW 3G operation */
3782 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3783 tdata->cipher_iv.len,
3784 tdata->validCipherLenInBits.len,
3785 tdata->cipher.offset_bits);
3789 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3791 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3792 ut_params->obuf = ut_params->op->sym->m_dst;
3793 if (ut_params->obuf)
3794 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3796 plaintext = ciphertext;
3798 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3801 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3802 tdata->plaintext.data,
3803 tdata->validDataLenInBits.len,
3804 "SNOW 3G Plaintext data not as expected");
3808 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3810 struct crypto_testsuite_params *ts_params = &testsuite_params;
3811 struct crypto_unittest_params *ut_params = &unittest_params;
3815 uint8_t *plaintext, *ciphertext;
3816 unsigned ciphertext_pad_len;
3817 unsigned ciphertext_len;
3819 /* Verify the capabilities */
3820 struct rte_cryptodev_sym_capability_idx cap_idx;
3821 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3822 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3823 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3827 /* Create SNOW 3G session */
3828 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3830 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831 tdata->key.data, tdata->key.len,
3832 tdata->cipher_iv.len);
3836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3839 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3840 "Failed to allocate input buffer");
3841 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3842 "Failed to allocate output buffer");
3844 /* Clear mbuf payload */
3845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846 rte_pktmbuf_tailroom(ut_params->ibuf));
3848 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3849 rte_pktmbuf_tailroom(ut_params->obuf));
3851 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3852 /* Append data which is padded to a multiple of */
3853 /* the algorithms block size */
3854 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3855 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3856 ciphertext_pad_len);
3857 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3858 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3860 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3862 /* Create SNOW 3G operation */
3863 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3864 tdata->cipher_iv.len,
3865 tdata->validCipherLenInBits.len,
3870 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3872 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3873 ut_params->obuf = ut_params->op->sym->m_dst;
3874 if (ut_params->obuf)
3875 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3877 plaintext = ciphertext;
3879 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3882 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3883 tdata->plaintext.data,
3884 tdata->validDataLenInBits.len,
3885 "SNOW 3G Plaintext data not as expected");
3890 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3892 struct crypto_testsuite_params *ts_params = &testsuite_params;
3893 struct crypto_unittest_params *ut_params = &unittest_params;
3897 uint8_t *plaintext, *ciphertext;
3898 unsigned int plaintext_pad_len;
3899 unsigned int plaintext_len;
3901 struct rte_cryptodev_info dev_info;
3902 struct rte_cryptodev_sym_capability_idx cap_idx;
3904 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3905 uint64_t feat_flags = dev_info.feature_flags;
3907 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3908 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3909 (tdata->validDataLenInBits.len % 8 != 0))) {
3910 printf("Device doesn't support NON-Byte Aligned Data.\n");
3914 /* Check if device supports ZUC EEA3 */
3915 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3916 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3918 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3922 /* Check if device supports ZUC EIA3 */
3923 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3924 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3926 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3930 /* Create ZUC session */
3931 retval = create_zuc_cipher_auth_encrypt_generate_session(
3932 ts_params->valid_devs[0],
3936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3938 /* clear mbuf payload */
3939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3940 rte_pktmbuf_tailroom(ut_params->ibuf));
3942 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3943 /* Append data which is padded to a multiple of */
3944 /* the algorithms block size */
3945 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3946 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3948 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3950 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3952 /* Create ZUC operation */
3953 retval = create_zuc_cipher_hash_generate_operation(tdata);
3957 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3959 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3960 ut_params->obuf = ut_params->op->sym->m_src;
3961 if (ut_params->obuf)
3962 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3964 ciphertext = plaintext;
3966 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3968 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3970 tdata->ciphertext.data,
3971 tdata->validDataLenInBits.len,
3972 "ZUC Ciphertext data not as expected");
3974 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3975 + plaintext_pad_len;
3978 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3982 "ZUC Generated auth tag not as expected");
3987 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3989 struct crypto_testsuite_params *ts_params = &testsuite_params;
3990 struct crypto_unittest_params *ut_params = &unittest_params;
3994 uint8_t *plaintext, *ciphertext;
3995 unsigned plaintext_pad_len;
3996 unsigned plaintext_len;
3998 /* Verify the capabilities */
3999 struct rte_cryptodev_sym_capability_idx cap_idx;
4000 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4001 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4002 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4006 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4007 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4011 /* Create SNOW 3G session */
4012 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4013 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4014 RTE_CRYPTO_AUTH_OP_GENERATE,
4015 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4016 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4017 tdata->key.data, tdata->key.len,
4018 tdata->auth_iv.len, tdata->digest.len,
4019 tdata->cipher_iv.len);
4022 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4024 /* clear mbuf payload */
4025 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4026 rte_pktmbuf_tailroom(ut_params->ibuf));
4028 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4029 /* Append data which is padded to a multiple of */
4030 /* the algorithms block size */
4031 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4032 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4034 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4036 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4038 /* Create SNOW 3G operation */
4039 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4040 tdata->digest.len, tdata->auth_iv.data,
4042 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4043 tdata->cipher_iv.data, tdata->cipher_iv.len,
4044 tdata->validCipherLenInBits.len,
4046 tdata->validAuthLenInBits.len,
4052 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4054 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4055 ut_params->obuf = ut_params->op->sym->m_src;
4056 if (ut_params->obuf)
4057 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4059 ciphertext = plaintext;
4061 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4063 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4065 tdata->ciphertext.data,
4066 tdata->validDataLenInBits.len,
4067 "SNOW 3G Ciphertext data not as expected");
4069 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4070 + plaintext_pad_len;
4073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4076 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4077 "SNOW 3G Generated auth tag not as expected");
4082 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4083 uint8_t op_mode, uint8_t verify)
4085 struct crypto_testsuite_params *ts_params = &testsuite_params;
4086 struct crypto_unittest_params *ut_params = &unittest_params;
4090 uint8_t *plaintext = NULL, *ciphertext = NULL;
4091 unsigned int plaintext_pad_len;
4092 unsigned int plaintext_len;
4093 unsigned int ciphertext_pad_len;
4094 unsigned int ciphertext_len;
4096 struct rte_cryptodev_info dev_info;
4098 /* Verify the capabilities */
4099 struct rte_cryptodev_sym_capability_idx cap_idx;
4100 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4101 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4102 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4106 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4111 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4113 uint64_t feat_flags = dev_info.feature_flags;
4115 if (op_mode == OUT_OF_PLACE) {
4116 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4117 printf("Device doesn't support digest encrypted.\n");
4122 /* Create SNOW 3G session */
4123 retval = create_wireless_algo_auth_cipher_session(
4124 ts_params->valid_devs[0],
4125 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4126 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4127 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4128 : RTE_CRYPTO_AUTH_OP_GENERATE),
4129 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4130 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4131 tdata->key.data, tdata->key.len,
4132 tdata->auth_iv.len, tdata->digest.len,
4133 tdata->cipher_iv.len);
4138 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4139 if (op_mode == OUT_OF_PLACE)
4140 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4142 /* clear mbuf payload */
4143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4144 rte_pktmbuf_tailroom(ut_params->ibuf));
4145 if (op_mode == OUT_OF_PLACE)
4146 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4147 rte_pktmbuf_tailroom(ut_params->obuf));
4149 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4150 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4151 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4155 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4156 ciphertext_pad_len);
4157 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4158 if (op_mode == OUT_OF_PLACE)
4159 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4160 debug_hexdump(stdout, "ciphertext:", ciphertext,
4163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4166 if (op_mode == OUT_OF_PLACE)
4167 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4168 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4171 /* Create SNOW 3G operation */
4172 retval = create_wireless_algo_auth_cipher_operation(
4173 tdata->digest.data, tdata->digest.len,
4174 tdata->cipher_iv.data, tdata->cipher_iv.len,
4175 tdata->auth_iv.data, tdata->auth_iv.len,
4176 (tdata->digest.offset_bytes == 0 ?
4177 (verify ? ciphertext_pad_len : plaintext_pad_len)
4178 : tdata->digest.offset_bytes),
4179 tdata->validCipherLenInBits.len,
4180 tdata->cipher.offset_bits,
4181 tdata->validAuthLenInBits.len,
4182 tdata->auth.offset_bits,
4183 op_mode, 0, verify);
4188 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4193 ut_params->obuf = (op_mode == IN_PLACE ?
4194 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4197 if (ut_params->obuf)
4198 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4201 plaintext = ciphertext +
4202 (tdata->cipher.offset_bits >> 3);
4204 debug_hexdump(stdout, "plaintext:", plaintext,
4205 (tdata->plaintext.len >> 3) - tdata->digest.len);
4206 debug_hexdump(stdout, "plaintext expected:",
4207 tdata->plaintext.data,
4208 (tdata->plaintext.len >> 3) - tdata->digest.len);
4210 if (ut_params->obuf)
4211 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4214 ciphertext = plaintext;
4216 debug_hexdump(stdout, "ciphertext:", ciphertext,
4218 debug_hexdump(stdout, "ciphertext expected:",
4219 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4221 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4222 + (tdata->digest.offset_bytes == 0 ?
4223 plaintext_pad_len : tdata->digest.offset_bytes);
4225 debug_hexdump(stdout, "digest:", ut_params->digest,
4227 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4235 tdata->plaintext.data,
4236 tdata->plaintext.len >> 3,
4237 "SNOW 3G Plaintext data not as expected");
4239 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4241 tdata->ciphertext.data,
4242 tdata->validDataLenInBits.len,
4243 "SNOW 3G Ciphertext data not as expected");
4245 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4248 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4249 "SNOW 3G Generated auth tag not as expected");
4255 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4256 uint8_t op_mode, uint8_t verify)
4258 struct crypto_testsuite_params *ts_params = &testsuite_params;
4259 struct crypto_unittest_params *ut_params = &unittest_params;
4263 const uint8_t *plaintext = NULL;
4264 const uint8_t *ciphertext = NULL;
4265 const uint8_t *digest = NULL;
4266 unsigned int plaintext_pad_len;
4267 unsigned int plaintext_len;
4268 unsigned int ciphertext_pad_len;
4269 unsigned int ciphertext_len;
4270 uint8_t buffer[10000];
4271 uint8_t digest_buffer[10000];
4273 struct rte_cryptodev_info dev_info;
4275 /* Verify the capabilities */
4276 struct rte_cryptodev_sym_capability_idx cap_idx;
4277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4278 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4279 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4282 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4283 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4284 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4288 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4290 uint64_t feat_flags = dev_info.feature_flags;
4292 if (op_mode == IN_PLACE) {
4293 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4294 printf("Device doesn't support in-place scatter-gather "
4295 "in both input and output mbufs.\n");
4299 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4300 printf("Device doesn't support out-of-place scatter-gather "
4301 "in both input and output mbufs.\n");
4304 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4305 printf("Device doesn't support digest encrypted.\n");
4310 /* Create SNOW 3G session */
4311 retval = create_wireless_algo_auth_cipher_session(
4312 ts_params->valid_devs[0],
4313 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4314 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4315 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4316 : RTE_CRYPTO_AUTH_OP_GENERATE),
4317 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4318 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4319 tdata->key.data, tdata->key.len,
4320 tdata->auth_iv.len, tdata->digest.len,
4321 tdata->cipher_iv.len);
4326 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4327 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4328 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4329 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4331 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4332 plaintext_pad_len, 15, 0);
4333 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4334 "Failed to allocate input buffer in mempool");
4336 if (op_mode == OUT_OF_PLACE) {
4337 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4338 plaintext_pad_len, 15, 0);
4339 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4340 "Failed to allocate output buffer in mempool");
4344 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4345 tdata->ciphertext.data);
4346 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4347 ciphertext_len, buffer);
4348 debug_hexdump(stdout, "ciphertext:", ciphertext,
4351 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4352 tdata->plaintext.data);
4353 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4354 plaintext_len, buffer);
4355 debug_hexdump(stdout, "plaintext:", plaintext,
4358 memset(buffer, 0, sizeof(buffer));
4360 /* Create SNOW 3G operation */
4361 retval = create_wireless_algo_auth_cipher_operation(
4362 tdata->digest.data, tdata->digest.len,
4363 tdata->cipher_iv.data, tdata->cipher_iv.len,
4364 tdata->auth_iv.data, tdata->auth_iv.len,
4365 (tdata->digest.offset_bytes == 0 ?
4366 (verify ? ciphertext_pad_len : plaintext_pad_len)
4367 : tdata->digest.offset_bytes),
4368 tdata->validCipherLenInBits.len,
4369 tdata->cipher.offset_bits,
4370 tdata->validAuthLenInBits.len,
4371 tdata->auth.offset_bits,
4372 op_mode, 1, verify);
4377 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4380 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4382 ut_params->obuf = (op_mode == IN_PLACE ?
4383 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4386 if (ut_params->obuf)
4387 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4388 plaintext_len, buffer);
4390 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4391 plaintext_len, buffer);
4393 debug_hexdump(stdout, "plaintext:", plaintext,
4394 (tdata->plaintext.len >> 3) - tdata->digest.len);
4395 debug_hexdump(stdout, "plaintext expected:",
4396 tdata->plaintext.data,
4397 (tdata->plaintext.len >> 3) - tdata->digest.len);
4399 if (ut_params->obuf)
4400 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4401 ciphertext_len, buffer);
4403 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4404 ciphertext_len, buffer);
4406 debug_hexdump(stdout, "ciphertext:", ciphertext,
4408 debug_hexdump(stdout, "ciphertext expected:",
4409 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4411 if (ut_params->obuf)
4412 digest = rte_pktmbuf_read(ut_params->obuf,
4413 (tdata->digest.offset_bytes == 0 ?
4414 plaintext_pad_len : tdata->digest.offset_bytes),
4415 tdata->digest.len, digest_buffer);
4417 digest = rte_pktmbuf_read(ut_params->ibuf,
4418 (tdata->digest.offset_bytes == 0 ?
4419 plaintext_pad_len : tdata->digest.offset_bytes),
4420 tdata->digest.len, digest_buffer);
4422 debug_hexdump(stdout, "digest:", digest,
4424 debug_hexdump(stdout, "digest expected:",
4425 tdata->digest.data, tdata->digest.len);
4430 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4432 tdata->plaintext.data,
4433 tdata->plaintext.len >> 3,
4434 "SNOW 3G Plaintext data not as expected");
4436 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4438 tdata->ciphertext.data,
4439 tdata->validDataLenInBits.len,
4440 "SNOW 3G Ciphertext data not as expected");
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4445 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4446 "SNOW 3G Generated auth tag not as expected");
4452 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4453 uint8_t op_mode, uint8_t verify)
4455 struct crypto_testsuite_params *ts_params = &testsuite_params;
4456 struct crypto_unittest_params *ut_params = &unittest_params;
4460 uint8_t *plaintext = NULL, *ciphertext = NULL;
4461 unsigned int plaintext_pad_len;
4462 unsigned int plaintext_len;
4463 unsigned int ciphertext_pad_len;
4464 unsigned int ciphertext_len;
4466 struct rte_cryptodev_info dev_info;
4468 /* Verify the capabilities */
4469 struct rte_cryptodev_sym_capability_idx cap_idx;
4470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4471 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4472 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4475 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4476 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4477 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4483 uint64_t feat_flags = dev_info.feature_flags;
4485 if (op_mode == OUT_OF_PLACE) {
4486 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4487 printf("Device doesn't support digest encrypted.\n");
4492 /* Create KASUMI session */
4493 retval = create_wireless_algo_auth_cipher_session(
4494 ts_params->valid_devs[0],
4495 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4496 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4497 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4498 : RTE_CRYPTO_AUTH_OP_GENERATE),
4499 RTE_CRYPTO_AUTH_KASUMI_F9,
4500 RTE_CRYPTO_CIPHER_KASUMI_F8,
4501 tdata->key.data, tdata->key.len,
4502 0, tdata->digest.len,
4503 tdata->cipher_iv.len);
4508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4509 if (op_mode == OUT_OF_PLACE)
4510 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4512 /* clear mbuf payload */
4513 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4514 rte_pktmbuf_tailroom(ut_params->ibuf));
4515 if (op_mode == OUT_OF_PLACE)
4516 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4517 rte_pktmbuf_tailroom(ut_params->obuf));
4519 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4520 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4521 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4522 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4525 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4526 ciphertext_pad_len);
4527 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4528 if (op_mode == OUT_OF_PLACE)
4529 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4530 debug_hexdump(stdout, "ciphertext:", ciphertext,
4533 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4535 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4536 if (op_mode == OUT_OF_PLACE)
4537 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4538 debug_hexdump(stdout, "plaintext:", plaintext,
4542 /* Create KASUMI operation */
4543 retval = create_wireless_algo_auth_cipher_operation(
4544 tdata->digest.data, tdata->digest.len,
4545 tdata->cipher_iv.data, tdata->cipher_iv.len,
4547 (tdata->digest.offset_bytes == 0 ?
4548 (verify ? ciphertext_pad_len : plaintext_pad_len)
4549 : tdata->digest.offset_bytes),
4550 tdata->validCipherLenInBits.len,
4551 tdata->validCipherOffsetInBits.len,
4552 tdata->validAuthLenInBits.len,
4554 op_mode, 0, verify);
4559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4562 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4564 ut_params->obuf = (op_mode == IN_PLACE ?
4565 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4569 if (ut_params->obuf)
4570 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4573 plaintext = ciphertext;
4575 debug_hexdump(stdout, "plaintext:", plaintext,
4576 (tdata->plaintext.len >> 3) - tdata->digest.len);
4577 debug_hexdump(stdout, "plaintext expected:",
4578 tdata->plaintext.data,
4579 (tdata->plaintext.len >> 3) - tdata->digest.len);
4581 if (ut_params->obuf)
4582 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4585 ciphertext = plaintext;
4587 debug_hexdump(stdout, "ciphertext:", ciphertext,
4589 debug_hexdump(stdout, "ciphertext expected:",
4590 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4592 ut_params->digest = rte_pktmbuf_mtod(
4593 ut_params->obuf, uint8_t *) +
4594 (tdata->digest.offset_bytes == 0 ?
4595 plaintext_pad_len : tdata->digest.offset_bytes);
4597 debug_hexdump(stdout, "digest:", ut_params->digest,
4599 debug_hexdump(stdout, "digest expected:",
4600 tdata->digest.data, tdata->digest.len);
4605 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4607 tdata->plaintext.data,
4608 tdata->plaintext.len >> 3,
4609 "KASUMI Plaintext data not as expected");
4611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4613 tdata->ciphertext.data,
4614 tdata->ciphertext.len >> 3,
4615 "KASUMI Ciphertext data not as expected");
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4620 DIGEST_BYTE_LENGTH_KASUMI_F9,
4621 "KASUMI Generated auth tag not as expected");
4627 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4628 uint8_t op_mode, uint8_t verify)
4630 struct crypto_testsuite_params *ts_params = &testsuite_params;
4631 struct crypto_unittest_params *ut_params = &unittest_params;
4635 const uint8_t *plaintext = NULL;
4636 const uint8_t *ciphertext = NULL;
4637 const uint8_t *digest = NULL;
4638 unsigned int plaintext_pad_len;
4639 unsigned int plaintext_len;
4640 unsigned int ciphertext_pad_len;
4641 unsigned int ciphertext_len;
4642 uint8_t buffer[10000];
4643 uint8_t digest_buffer[10000];
4645 struct rte_cryptodev_info dev_info;
4647 /* Verify the capabilities */
4648 struct rte_cryptodev_sym_capability_idx cap_idx;
4649 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4650 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4651 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4655 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4656 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4660 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4662 uint64_t feat_flags = dev_info.feature_flags;
4664 if (op_mode == IN_PLACE) {
4665 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4666 printf("Device doesn't support in-place scatter-gather "
4667 "in both input and output mbufs.\n");
4671 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4672 printf("Device doesn't support out-of-place scatter-gather "
4673 "in both input and output mbufs.\n");
4676 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4677 printf("Device doesn't support digest encrypted.\n");
4682 /* Create KASUMI session */
4683 retval = create_wireless_algo_auth_cipher_session(
4684 ts_params->valid_devs[0],
4685 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4686 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4687 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4688 : RTE_CRYPTO_AUTH_OP_GENERATE),
4689 RTE_CRYPTO_AUTH_KASUMI_F9,
4690 RTE_CRYPTO_CIPHER_KASUMI_F8,
4691 tdata->key.data, tdata->key.len,
4692 0, tdata->digest.len,
4693 tdata->cipher_iv.len);
4698 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4699 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4700 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4701 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4703 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4704 plaintext_pad_len, 15, 0);
4705 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4706 "Failed to allocate input buffer in mempool");
4708 if (op_mode == OUT_OF_PLACE) {
4709 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4710 plaintext_pad_len, 15, 0);
4711 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4712 "Failed to allocate output buffer in mempool");
4716 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4717 tdata->ciphertext.data);
4718 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4719 ciphertext_len, buffer);
4720 debug_hexdump(stdout, "ciphertext:", ciphertext,
4723 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4724 tdata->plaintext.data);
4725 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4726 plaintext_len, buffer);
4727 debug_hexdump(stdout, "plaintext:", plaintext,
4730 memset(buffer, 0, sizeof(buffer));
4732 /* Create KASUMI operation */
4733 retval = create_wireless_algo_auth_cipher_operation(
4734 tdata->digest.data, tdata->digest.len,
4735 tdata->cipher_iv.data, tdata->cipher_iv.len,
4737 (tdata->digest.offset_bytes == 0 ?
4738 (verify ? ciphertext_pad_len : plaintext_pad_len)
4739 : tdata->digest.offset_bytes),
4740 tdata->validCipherLenInBits.len,
4741 tdata->validCipherOffsetInBits.len,
4742 tdata->validAuthLenInBits.len,
4744 op_mode, 1, verify);
4749 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4752 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4754 ut_params->obuf = (op_mode == IN_PLACE ?
4755 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4758 if (ut_params->obuf)
4759 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4760 plaintext_len, buffer);
4762 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4763 plaintext_len, buffer);
4765 debug_hexdump(stdout, "plaintext:", plaintext,
4766 (tdata->plaintext.len >> 3) - tdata->digest.len);
4767 debug_hexdump(stdout, "plaintext expected:",
4768 tdata->plaintext.data,
4769 (tdata->plaintext.len >> 3) - tdata->digest.len);
4771 if (ut_params->obuf)
4772 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4773 ciphertext_len, buffer);
4775 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4776 ciphertext_len, buffer);
4778 debug_hexdump(stdout, "ciphertext:", ciphertext,
4780 debug_hexdump(stdout, "ciphertext expected:",
4781 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4783 if (ut_params->obuf)
4784 digest = rte_pktmbuf_read(ut_params->obuf,
4785 (tdata->digest.offset_bytes == 0 ?
4786 plaintext_pad_len : tdata->digest.offset_bytes),
4787 tdata->digest.len, digest_buffer);
4789 digest = rte_pktmbuf_read(ut_params->ibuf,
4790 (tdata->digest.offset_bytes == 0 ?
4791 plaintext_pad_len : tdata->digest.offset_bytes),
4792 tdata->digest.len, digest_buffer);
4794 debug_hexdump(stdout, "digest:", digest,
4796 debug_hexdump(stdout, "digest expected:",
4797 tdata->digest.data, tdata->digest.len);
4802 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4804 tdata->plaintext.data,
4805 tdata->plaintext.len >> 3,
4806 "KASUMI Plaintext data not as expected");
4808 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4810 tdata->ciphertext.data,
4811 tdata->validDataLenInBits.len,
4812 "KASUMI Ciphertext data not as expected");
4814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4817 DIGEST_BYTE_LENGTH_KASUMI_F9,
4818 "KASUMI Generated auth tag not as expected");
4824 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4826 struct crypto_testsuite_params *ts_params = &testsuite_params;
4827 struct crypto_unittest_params *ut_params = &unittest_params;
4831 uint8_t *plaintext, *ciphertext;
4832 unsigned plaintext_pad_len;
4833 unsigned plaintext_len;
4835 /* Verify the capabilities */
4836 struct rte_cryptodev_sym_capability_idx cap_idx;
4837 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4838 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4839 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4842 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4843 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4844 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4848 /* Create KASUMI session */
4849 retval = create_wireless_algo_cipher_auth_session(
4850 ts_params->valid_devs[0],
4851 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4852 RTE_CRYPTO_AUTH_OP_GENERATE,
4853 RTE_CRYPTO_AUTH_KASUMI_F9,
4854 RTE_CRYPTO_CIPHER_KASUMI_F8,
4855 tdata->key.data, tdata->key.len,
4856 0, tdata->digest.len,
4857 tdata->cipher_iv.len);
4861 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4863 /* clear mbuf payload */
4864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4865 rte_pktmbuf_tailroom(ut_params->ibuf));
4867 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4868 /* Append data which is padded to a multiple of */
4869 /* the algorithms block size */
4870 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4873 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4875 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4877 /* Create KASUMI operation */
4878 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4879 tdata->digest.len, NULL, 0,
4880 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4881 tdata->cipher_iv.data, tdata->cipher_iv.len,
4882 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4883 tdata->validCipherOffsetInBits.len,
4884 tdata->validAuthLenInBits.len,
4890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4894 if (ut_params->op->sym->m_dst)
4895 ut_params->obuf = ut_params->op->sym->m_dst;
4897 ut_params->obuf = ut_params->op->sym->m_src;
4899 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4900 tdata->validCipherOffsetInBits.len >> 3);
4902 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4903 + plaintext_pad_len;
4905 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4906 (tdata->validCipherOffsetInBits.len >> 3);
4908 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4910 reference_ciphertext,
4911 tdata->validCipherLenInBits.len,
4912 "KASUMI Ciphertext data not as expected");
4915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4918 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4919 "KASUMI Generated auth tag not as expected");
4924 test_zuc_encryption(const struct wireless_test_data *tdata)
4926 struct crypto_testsuite_params *ts_params = &testsuite_params;
4927 struct crypto_unittest_params *ut_params = &unittest_params;
4930 uint8_t *plaintext, *ciphertext;
4931 unsigned plaintext_pad_len;
4932 unsigned plaintext_len;
4934 struct rte_cryptodev_sym_capability_idx cap_idx;
4936 /* Check if device supports ZUC EEA3 */
4937 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4938 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4944 /* Create ZUC session */
4945 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4946 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4947 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4948 tdata->key.data, tdata->key.len,
4949 tdata->cipher_iv.len);
4953 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4955 /* Clear mbuf payload */
4956 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4957 rte_pktmbuf_tailroom(ut_params->ibuf));
4959 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4960 /* Append data which is padded to a multiple */
4961 /* of the algorithms block size */
4962 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4963 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4965 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4967 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4969 /* Create ZUC operation */
4970 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4971 tdata->cipher_iv.len,
4972 tdata->plaintext.len,
4977 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4979 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4981 ut_params->obuf = ut_params->op->sym->m_dst;
4982 if (ut_params->obuf)
4983 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4985 ciphertext = plaintext;
4987 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4990 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4992 tdata->ciphertext.data,
4993 tdata->validCipherLenInBits.len,
4994 "ZUC Ciphertext data not as expected");
4999 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5001 struct crypto_testsuite_params *ts_params = &testsuite_params;
5002 struct crypto_unittest_params *ut_params = &unittest_params;
5006 unsigned int plaintext_pad_len;
5007 unsigned int plaintext_len;
5008 const uint8_t *ciphertext;
5009 uint8_t ciphertext_buffer[2048];
5010 struct rte_cryptodev_info dev_info;
5012 struct rte_cryptodev_sym_capability_idx cap_idx;
5014 /* Check if device supports ZUC EEA3 */
5015 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5016 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5018 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5022 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5024 uint64_t feat_flags = dev_info.feature_flags;
5026 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5027 printf("Device doesn't support in-place scatter-gather. "
5032 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5034 /* Append data which is padded to a multiple */
5035 /* of the algorithms block size */
5036 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5038 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5039 plaintext_pad_len, 10, 0);
5041 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5042 tdata->plaintext.data);
5044 /* Create ZUC session */
5045 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5046 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5047 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5048 tdata->key.data, tdata->key.len,
5049 tdata->cipher_iv.len);
5053 /* Clear mbuf payload */
5055 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5057 /* Create ZUC operation */
5058 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5059 tdata->cipher_iv.len, tdata->plaintext.len,
5064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5066 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5068 ut_params->obuf = ut_params->op->sym->m_dst;
5069 if (ut_params->obuf)
5070 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5071 0, plaintext_len, ciphertext_buffer);
5073 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5074 0, plaintext_len, ciphertext_buffer);
5077 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5080 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5082 tdata->ciphertext.data,
5083 tdata->validCipherLenInBits.len,
5084 "ZUC Ciphertext data not as expected");
5090 test_zuc_authentication(const struct wireless_test_data *tdata)
5092 struct crypto_testsuite_params *ts_params = &testsuite_params;
5093 struct crypto_unittest_params *ut_params = &unittest_params;
5096 unsigned plaintext_pad_len;
5097 unsigned plaintext_len;
5100 struct rte_cryptodev_sym_capability_idx cap_idx;
5101 struct rte_cryptodev_info dev_info;
5103 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5104 uint64_t feat_flags = dev_info.feature_flags;
5106 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5107 (tdata->validAuthLenInBits.len % 8 != 0)) {
5108 printf("Device doesn't support NON-Byte Aligned Data.\n");
5112 /* Check if device supports ZUC EIA3 */
5113 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5114 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5116 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5120 /* Create ZUC session */
5121 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5122 tdata->key.data, tdata->key.len,
5123 tdata->auth_iv.len, tdata->digest.len,
5124 RTE_CRYPTO_AUTH_OP_GENERATE,
5125 RTE_CRYPTO_AUTH_ZUC_EIA3);
5129 /* alloc mbuf and set payload */
5130 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5133 rte_pktmbuf_tailroom(ut_params->ibuf));
5135 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5136 /* Append data which is padded to a multiple of */
5137 /* the algorithms block size */
5138 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5139 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5141 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5143 /* Create ZUC operation */
5144 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5145 tdata->auth_iv.data, tdata->auth_iv.len,
5146 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5147 tdata->validAuthLenInBits.len,
5152 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5154 ut_params->obuf = ut_params->op->sym->m_src;
5155 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5156 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5157 + plaintext_pad_len;
5160 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5164 "ZUC Generated auth tag not as expected");
5170 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5171 uint8_t op_mode, uint8_t verify)
5173 struct crypto_testsuite_params *ts_params = &testsuite_params;
5174 struct crypto_unittest_params *ut_params = &unittest_params;
5178 uint8_t *plaintext = NULL, *ciphertext = NULL;
5179 unsigned int plaintext_pad_len;
5180 unsigned int plaintext_len;
5181 unsigned int ciphertext_pad_len;
5182 unsigned int ciphertext_len;
5184 struct rte_cryptodev_info dev_info;
5185 struct rte_cryptodev_sym_capability_idx cap_idx;
5187 /* Check if device supports ZUC EIA3 */
5188 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5189 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5191 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5195 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5197 uint64_t feat_flags = dev_info.feature_flags;
5199 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5200 printf("Device doesn't support digest encrypted.\n");
5203 if (op_mode == IN_PLACE) {
5204 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5205 printf("Device doesn't support in-place scatter-gather "
5206 "in both input and output mbufs.\n");
5210 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5211 printf("Device doesn't support out-of-place scatter-gather "
5212 "in both input and output mbufs.\n");
5217 /* Create ZUC session */
5218 retval = create_wireless_algo_auth_cipher_session(
5219 ts_params->valid_devs[0],
5220 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5221 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5222 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5223 : RTE_CRYPTO_AUTH_OP_GENERATE),
5224 RTE_CRYPTO_AUTH_ZUC_EIA3,
5225 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5226 tdata->key.data, tdata->key.len,
5227 tdata->auth_iv.len, tdata->digest.len,
5228 tdata->cipher_iv.len);
5233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5234 if (op_mode == OUT_OF_PLACE)
5235 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5237 /* clear mbuf payload */
5238 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5239 rte_pktmbuf_tailroom(ut_params->ibuf));
5240 if (op_mode == OUT_OF_PLACE)
5241 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5242 rte_pktmbuf_tailroom(ut_params->obuf));
5244 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5245 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5246 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5247 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5250 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5251 ciphertext_pad_len);
5252 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5253 if (op_mode == OUT_OF_PLACE)
5254 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5255 debug_hexdump(stdout, "ciphertext:", ciphertext,
5258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5261 if (op_mode == OUT_OF_PLACE)
5262 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5263 debug_hexdump(stdout, "plaintext:", plaintext,
5267 /* Create ZUC operation */
5268 retval = create_wireless_algo_auth_cipher_operation(
5269 tdata->digest.data, tdata->digest.len,
5270 tdata->cipher_iv.data, tdata->cipher_iv.len,
5271 tdata->auth_iv.data, tdata->auth_iv.len,
5272 (tdata->digest.offset_bytes == 0 ?
5273 (verify ? ciphertext_pad_len : plaintext_pad_len)
5274 : tdata->digest.offset_bytes),
5275 tdata->validCipherLenInBits.len,
5276 tdata->validCipherOffsetInBits.len,
5277 tdata->validAuthLenInBits.len,
5279 op_mode, 0, verify);
5284 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5287 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5289 ut_params->obuf = (op_mode == IN_PLACE ?
5290 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5294 if (ut_params->obuf)
5295 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5298 plaintext = ciphertext;
5300 debug_hexdump(stdout, "plaintext:", plaintext,
5301 (tdata->plaintext.len >> 3) - tdata->digest.len);
5302 debug_hexdump(stdout, "plaintext expected:",
5303 tdata->plaintext.data,
5304 (tdata->plaintext.len >> 3) - tdata->digest.len);
5306 if (ut_params->obuf)
5307 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5310 ciphertext = plaintext;
5312 debug_hexdump(stdout, "ciphertext:", ciphertext,
5314 debug_hexdump(stdout, "ciphertext expected:",
5315 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5317 ut_params->digest = rte_pktmbuf_mtod(
5318 ut_params->obuf, uint8_t *) +
5319 (tdata->digest.offset_bytes == 0 ?
5320 plaintext_pad_len : tdata->digest.offset_bytes);
5322 debug_hexdump(stdout, "digest:", ut_params->digest,
5324 debug_hexdump(stdout, "digest expected:",
5325 tdata->digest.data, tdata->digest.len);
5330 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5332 tdata->plaintext.data,
5333 tdata->plaintext.len >> 3,
5334 "ZUC Plaintext data not as expected");
5336 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5338 tdata->ciphertext.data,
5339 tdata->ciphertext.len >> 3,
5340 "ZUC Ciphertext data not as expected");
5342 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5345 DIGEST_BYTE_LENGTH_KASUMI_F9,
5346 "ZUC Generated auth tag not as expected");
5352 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5353 uint8_t op_mode, uint8_t verify)
5355 struct crypto_testsuite_params *ts_params = &testsuite_params;
5356 struct crypto_unittest_params *ut_params = &unittest_params;
5360 const uint8_t *plaintext = NULL;
5361 const uint8_t *ciphertext = NULL;
5362 const uint8_t *digest = NULL;
5363 unsigned int plaintext_pad_len;
5364 unsigned int plaintext_len;
5365 unsigned int ciphertext_pad_len;
5366 unsigned int ciphertext_len;
5367 uint8_t buffer[10000];
5368 uint8_t digest_buffer[10000];
5370 struct rte_cryptodev_info dev_info;
5371 struct rte_cryptodev_sym_capability_idx cap_idx;
5373 /* Check if device supports ZUC EIA3 */
5374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5375 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5381 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5383 uint64_t feat_flags = dev_info.feature_flags;
5385 if (op_mode == IN_PLACE) {
5386 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5387 printf("Device doesn't support in-place scatter-gather "
5388 "in both input and output mbufs.\n");
5392 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5393 printf("Device doesn't support out-of-place scatter-gather "
5394 "in both input and output mbufs.\n");
5397 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5398 printf("Device doesn't support digest encrypted.\n");
5403 /* Create ZUC session */
5404 retval = create_wireless_algo_auth_cipher_session(
5405 ts_params->valid_devs[0],
5406 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5407 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5408 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5409 : RTE_CRYPTO_AUTH_OP_GENERATE),
5410 RTE_CRYPTO_AUTH_ZUC_EIA3,
5411 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5412 tdata->key.data, tdata->key.len,
5413 tdata->auth_iv.len, tdata->digest.len,
5414 tdata->cipher_iv.len);
5419 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5420 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5421 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5422 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5424 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5425 plaintext_pad_len, 15, 0);
5426 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5427 "Failed to allocate input buffer in mempool");
5429 if (op_mode == OUT_OF_PLACE) {
5430 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5431 plaintext_pad_len, 15, 0);
5432 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5433 "Failed to allocate output buffer in mempool");
5437 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5438 tdata->ciphertext.data);
5439 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5440 ciphertext_len, buffer);
5441 debug_hexdump(stdout, "ciphertext:", ciphertext,
5444 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5445 tdata->plaintext.data);
5446 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5447 plaintext_len, buffer);
5448 debug_hexdump(stdout, "plaintext:", plaintext,
5451 memset(buffer, 0, sizeof(buffer));
5453 /* Create ZUC operation */
5454 retval = create_wireless_algo_auth_cipher_operation(
5455 tdata->digest.data, tdata->digest.len,
5456 tdata->cipher_iv.data, tdata->cipher_iv.len,
5458 (tdata->digest.offset_bytes == 0 ?
5459 (verify ? ciphertext_pad_len : plaintext_pad_len)
5460 : tdata->digest.offset_bytes),
5461 tdata->validCipherLenInBits.len,
5462 tdata->validCipherOffsetInBits.len,
5463 tdata->validAuthLenInBits.len,
5465 op_mode, 1, verify);
5470 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5473 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5475 ut_params->obuf = (op_mode == IN_PLACE ?
5476 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5479 if (ut_params->obuf)
5480 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5481 plaintext_len, buffer);
5483 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5484 plaintext_len, buffer);
5486 debug_hexdump(stdout, "plaintext:", plaintext,
5487 (tdata->plaintext.len >> 3) - tdata->digest.len);
5488 debug_hexdump(stdout, "plaintext expected:",
5489 tdata->plaintext.data,
5490 (tdata->plaintext.len >> 3) - tdata->digest.len);
5492 if (ut_params->obuf)
5493 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5494 ciphertext_len, buffer);
5496 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5497 ciphertext_len, buffer);
5499 debug_hexdump(stdout, "ciphertext:", ciphertext,
5501 debug_hexdump(stdout, "ciphertext expected:",
5502 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5504 if (ut_params->obuf)
5505 digest = rte_pktmbuf_read(ut_params->obuf,
5506 (tdata->digest.offset_bytes == 0 ?
5507 plaintext_pad_len : tdata->digest.offset_bytes),
5508 tdata->digest.len, digest_buffer);
5510 digest = rte_pktmbuf_read(ut_params->ibuf,
5511 (tdata->digest.offset_bytes == 0 ?
5512 plaintext_pad_len : tdata->digest.offset_bytes),
5513 tdata->digest.len, digest_buffer);
5515 debug_hexdump(stdout, "digest:", digest,
5517 debug_hexdump(stdout, "digest expected:",
5518 tdata->digest.data, tdata->digest.len);
5523 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5525 tdata->plaintext.data,
5526 tdata->plaintext.len >> 3,
5527 "ZUC Plaintext data not as expected");
5529 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5531 tdata->ciphertext.data,
5532 tdata->validDataLenInBits.len,
5533 "ZUC Ciphertext data not as expected");
5535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5538 DIGEST_BYTE_LENGTH_KASUMI_F9,
5539 "ZUC Generated auth tag not as expected");
5545 test_kasumi_encryption_test_case_1(void)
5547 return test_kasumi_encryption(&kasumi_test_case_1);
5551 test_kasumi_encryption_test_case_1_sgl(void)
5553 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5557 test_kasumi_encryption_test_case_1_oop(void)
5559 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5563 test_kasumi_encryption_test_case_1_oop_sgl(void)
5565 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5569 test_kasumi_encryption_test_case_2(void)
5571 return test_kasumi_encryption(&kasumi_test_case_2);
5575 test_kasumi_encryption_test_case_3(void)
5577 return test_kasumi_encryption(&kasumi_test_case_3);
5581 test_kasumi_encryption_test_case_4(void)
5583 return test_kasumi_encryption(&kasumi_test_case_4);
5587 test_kasumi_encryption_test_case_5(void)
5589 return test_kasumi_encryption(&kasumi_test_case_5);
5593 test_kasumi_decryption_test_case_1(void)
5595 return test_kasumi_decryption(&kasumi_test_case_1);
5599 test_kasumi_decryption_test_case_1_oop(void)
5601 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5605 test_kasumi_decryption_test_case_2(void)
5607 return test_kasumi_decryption(&kasumi_test_case_2);
5611 test_kasumi_decryption_test_case_3(void)
5613 return test_kasumi_decryption(&kasumi_test_case_3);
5617 test_kasumi_decryption_test_case_4(void)
5619 return test_kasumi_decryption(&kasumi_test_case_4);
5623 test_kasumi_decryption_test_case_5(void)
5625 return test_kasumi_decryption(&kasumi_test_case_5);
5628 test_snow3g_encryption_test_case_1(void)
5630 return test_snow3g_encryption(&snow3g_test_case_1);
5634 test_snow3g_encryption_test_case_1_oop(void)
5636 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5640 test_snow3g_encryption_test_case_1_oop_sgl(void)
5642 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5647 test_snow3g_encryption_test_case_1_offset_oop(void)
5649 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5653 test_snow3g_encryption_test_case_2(void)
5655 return test_snow3g_encryption(&snow3g_test_case_2);
5659 test_snow3g_encryption_test_case_3(void)
5661 return test_snow3g_encryption(&snow3g_test_case_3);
5665 test_snow3g_encryption_test_case_4(void)
5667 return test_snow3g_encryption(&snow3g_test_case_4);
5671 test_snow3g_encryption_test_case_5(void)
5673 return test_snow3g_encryption(&snow3g_test_case_5);
5677 test_snow3g_decryption_test_case_1(void)
5679 return test_snow3g_decryption(&snow3g_test_case_1);
5683 test_snow3g_decryption_test_case_1_oop(void)
5685 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5689 test_snow3g_decryption_test_case_2(void)
5691 return test_snow3g_decryption(&snow3g_test_case_2);
5695 test_snow3g_decryption_test_case_3(void)
5697 return test_snow3g_decryption(&snow3g_test_case_3);
5701 test_snow3g_decryption_test_case_4(void)
5703 return test_snow3g_decryption(&snow3g_test_case_4);
5707 test_snow3g_decryption_test_case_5(void)
5709 return test_snow3g_decryption(&snow3g_test_case_5);
5713 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5714 * Pattern digest from snow3g_test_data must be allocated as
5715 * 4 last bytes in plaintext.
5718 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5719 struct snow3g_hash_test_data *output)
5721 if ((pattern != NULL) && (output != NULL)) {
5722 output->key.len = pattern->key.len;
5724 memcpy(output->key.data,
5725 pattern->key.data, pattern->key.len);
5727 output->auth_iv.len = pattern->auth_iv.len;
5729 memcpy(output->auth_iv.data,
5730 pattern->auth_iv.data, pattern->auth_iv.len);
5732 output->plaintext.len = pattern->plaintext.len;
5734 memcpy(output->plaintext.data,
5735 pattern->plaintext.data, pattern->plaintext.len >> 3);
5737 output->digest.len = pattern->digest.len;
5739 memcpy(output->digest.data,
5740 &pattern->plaintext.data[pattern->digest.offset_bytes],
5741 pattern->digest.len);
5743 output->validAuthLenInBits.len =
5744 pattern->validAuthLenInBits.len;
5749 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5752 test_snow3g_decryption_with_digest_test_case_1(void)
5754 struct snow3g_hash_test_data snow3g_hash_data;
5757 * Function prepare data for hash veryfication test case.
5758 * Digest is allocated in 4 last bytes in plaintext, pattern.
5760 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5762 return test_snow3g_decryption(&snow3g_test_case_7) &
5763 test_snow3g_authentication_verify(&snow3g_hash_data);
5767 test_snow3g_cipher_auth_test_case_1(void)
5769 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5773 test_snow3g_auth_cipher_test_case_1(void)
5775 return test_snow3g_auth_cipher(
5776 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5780 test_snow3g_auth_cipher_test_case_2(void)
5782 return test_snow3g_auth_cipher(
5783 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5787 test_snow3g_auth_cipher_test_case_2_oop(void)
5789 return test_snow3g_auth_cipher(
5790 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5794 test_snow3g_auth_cipher_part_digest_enc(void)
5796 return test_snow3g_auth_cipher(
5797 &snow3g_auth_cipher_partial_digest_encryption,
5802 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5804 return test_snow3g_auth_cipher(
5805 &snow3g_auth_cipher_partial_digest_encryption,
5810 test_snow3g_auth_cipher_test_case_3_sgl(void)
5812 return test_snow3g_auth_cipher_sgl(
5813 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5817 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5819 return test_snow3g_auth_cipher_sgl(
5820 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5824 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5826 return test_snow3g_auth_cipher_sgl(
5827 &snow3g_auth_cipher_partial_digest_encryption,
5832 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5834 return test_snow3g_auth_cipher_sgl(
5835 &snow3g_auth_cipher_partial_digest_encryption,
5840 test_snow3g_auth_cipher_verify_test_case_1(void)
5842 return test_snow3g_auth_cipher(
5843 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5847 test_snow3g_auth_cipher_verify_test_case_2(void)
5849 return test_snow3g_auth_cipher(
5850 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5854 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5856 return test_snow3g_auth_cipher(
5857 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5861 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5863 return test_snow3g_auth_cipher(
5864 &snow3g_auth_cipher_partial_digest_encryption,
5869 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5871 return test_snow3g_auth_cipher(
5872 &snow3g_auth_cipher_partial_digest_encryption,
5877 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5879 return test_snow3g_auth_cipher_sgl(
5880 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5884 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5886 return test_snow3g_auth_cipher_sgl(
5887 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5891 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5893 return test_snow3g_auth_cipher_sgl(
5894 &snow3g_auth_cipher_partial_digest_encryption,
5899 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5901 return test_snow3g_auth_cipher_sgl(
5902 &snow3g_auth_cipher_partial_digest_encryption,
5907 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5909 return test_snow3g_auth_cipher(
5910 &snow3g_test_case_7, IN_PLACE, 0);
5914 test_kasumi_auth_cipher_test_case_1(void)
5916 return test_kasumi_auth_cipher(
5917 &kasumi_test_case_3, IN_PLACE, 0);
5921 test_kasumi_auth_cipher_test_case_2(void)
5923 return test_kasumi_auth_cipher(
5924 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5928 test_kasumi_auth_cipher_test_case_2_oop(void)
5930 return test_kasumi_auth_cipher(
5931 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5935 test_kasumi_auth_cipher_test_case_2_sgl(void)
5937 return test_kasumi_auth_cipher_sgl(
5938 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5942 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5944 return test_kasumi_auth_cipher_sgl(
5945 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5949 test_kasumi_auth_cipher_verify_test_case_1(void)
5951 return test_kasumi_auth_cipher(
5952 &kasumi_test_case_3, IN_PLACE, 1);
5956 test_kasumi_auth_cipher_verify_test_case_2(void)
5958 return test_kasumi_auth_cipher(
5959 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5963 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5965 return test_kasumi_auth_cipher(
5966 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5970 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5972 return test_kasumi_auth_cipher_sgl(
5973 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5977 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5979 return test_kasumi_auth_cipher_sgl(
5980 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5984 test_kasumi_cipher_auth_test_case_1(void)
5986 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5990 test_zuc_encryption_test_case_1(void)
5992 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5996 test_zuc_encryption_test_case_2(void)
5998 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6002 test_zuc_encryption_test_case_3(void)
6004 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6008 test_zuc_encryption_test_case_4(void)
6010 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6014 test_zuc_encryption_test_case_5(void)
6016 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6020 test_zuc_encryption_test_case_6_sgl(void)
6022 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6026 test_zuc_hash_generate_test_case_1(void)
6028 return test_zuc_authentication(&zuc_test_case_auth_1b);
6032 test_zuc_hash_generate_test_case_2(void)
6034 return test_zuc_authentication(&zuc_test_case_auth_90b);
6038 test_zuc_hash_generate_test_case_3(void)
6040 return test_zuc_authentication(&zuc_test_case_auth_577b);
6044 test_zuc_hash_generate_test_case_4(void)
6046 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6050 test_zuc_hash_generate_test_case_5(void)
6052 return test_zuc_authentication(&zuc_test_auth_5670b);
6056 test_zuc_hash_generate_test_case_6(void)
6058 return test_zuc_authentication(&zuc_test_case_auth_128b);
6062 test_zuc_hash_generate_test_case_7(void)
6064 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6068 test_zuc_hash_generate_test_case_8(void)
6070 return test_zuc_authentication(&zuc_test_case_auth_584b);
6074 test_zuc_cipher_auth_test_case_1(void)
6076 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6080 test_zuc_cipher_auth_test_case_2(void)
6082 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6086 test_zuc_auth_cipher_test_case_1(void)
6088 return test_zuc_auth_cipher(
6089 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6093 test_zuc_auth_cipher_test_case_1_oop(void)
6095 return test_zuc_auth_cipher(
6096 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6100 test_zuc_auth_cipher_test_case_1_sgl(void)
6102 return test_zuc_auth_cipher_sgl(
6103 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6107 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6109 return test_zuc_auth_cipher_sgl(
6110 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6114 test_zuc_auth_cipher_verify_test_case_1(void)
6116 return test_zuc_auth_cipher(
6117 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6121 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6123 return test_zuc_auth_cipher(
6124 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6128 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6130 return test_zuc_auth_cipher_sgl(
6131 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6135 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6137 return test_zuc_auth_cipher_sgl(
6138 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6142 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6144 uint8_t dev_id = testsuite_params.valid_devs[0];
6146 struct rte_cryptodev_sym_capability_idx cap_idx;
6148 /* Check if device supports particular cipher algorithm */
6149 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6150 cap_idx.algo.cipher = tdata->cipher_algo;
6151 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6154 /* Check if device supports particular hash algorithm */
6155 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6156 cap_idx.algo.auth = tdata->auth_algo;
6157 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6164 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6165 uint8_t op_mode, uint8_t verify)
6167 struct crypto_testsuite_params *ts_params = &testsuite_params;
6168 struct crypto_unittest_params *ut_params = &unittest_params;
6172 uint8_t *plaintext = NULL, *ciphertext = NULL;
6173 unsigned int plaintext_pad_len;
6174 unsigned int plaintext_len;
6175 unsigned int ciphertext_pad_len;
6176 unsigned int ciphertext_len;
6178 struct rte_cryptodev_info dev_info;
6179 struct rte_crypto_op *op;
6181 /* Check if device supports particular algorithms separately */
6182 if (test_mixed_check_if_unsupported(tdata))
6185 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6187 uint64_t feat_flags = dev_info.feature_flags;
6189 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6190 printf("Device doesn't support digest encrypted.\n");
6194 /* Create the session */
6196 retval = create_wireless_algo_cipher_auth_session(
6197 ts_params->valid_devs[0],
6198 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6199 RTE_CRYPTO_AUTH_OP_VERIFY,
6202 tdata->auth_key.data, tdata->auth_key.len,
6203 tdata->auth_iv.len, tdata->digest_enc.len,
6204 tdata->cipher_iv.len);
6206 retval = create_wireless_algo_auth_cipher_session(
6207 ts_params->valid_devs[0],
6208 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6209 RTE_CRYPTO_AUTH_OP_GENERATE,
6212 tdata->auth_key.data, tdata->auth_key.len,
6213 tdata->auth_iv.len, tdata->digest_enc.len,
6214 tdata->cipher_iv.len);
6218 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6219 if (op_mode == OUT_OF_PLACE)
6220 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6222 /* clear mbuf payload */
6223 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6224 rte_pktmbuf_tailroom(ut_params->ibuf));
6225 if (op_mode == OUT_OF_PLACE)
6226 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6227 rte_pktmbuf_tailroom(ut_params->obuf));
6229 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6230 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6231 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6232 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6235 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6236 ciphertext_pad_len);
6237 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6238 if (op_mode == OUT_OF_PLACE)
6239 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6240 debug_hexdump(stdout, "ciphertext:", ciphertext,
6243 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6245 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6246 if (op_mode == OUT_OF_PLACE)
6247 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6248 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6251 /* Create the operation */
6252 retval = create_wireless_algo_auth_cipher_operation(
6253 tdata->digest_enc.data, tdata->digest_enc.len,
6254 tdata->cipher_iv.data, tdata->cipher_iv.len,
6255 tdata->auth_iv.data, tdata->auth_iv.len,
6256 (tdata->digest_enc.offset == 0 ?
6258 : tdata->digest_enc.offset),
6259 tdata->validCipherLen.len_bits,
6260 tdata->cipher.offset_bits,
6261 tdata->validAuthLen.len_bits,
6262 tdata->auth.offset_bits,
6263 op_mode, 0, verify);
6268 op = process_crypto_request(ts_params->valid_devs[0],
6271 /* Check if the op failed because the device doesn't */
6272 /* support this particular combination of algorithms */
6273 if (op == NULL && ut_params->op->status ==
6274 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6275 printf("Device doesn't support this mixed combination. "
6281 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6283 ut_params->obuf = (op_mode == IN_PLACE ?
6284 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6287 if (ut_params->obuf)
6288 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6291 plaintext = ciphertext +
6292 (tdata->cipher.offset_bits >> 3);
6294 debug_hexdump(stdout, "plaintext:", plaintext,
6295 tdata->plaintext.len_bits >> 3);
6296 debug_hexdump(stdout, "plaintext expected:",
6297 tdata->plaintext.data,
6298 tdata->plaintext.len_bits >> 3);
6300 if (ut_params->obuf)
6301 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6304 ciphertext = plaintext;
6306 debug_hexdump(stdout, "ciphertext:", ciphertext,
6308 debug_hexdump(stdout, "ciphertext expected:",
6309 tdata->ciphertext.data,
6310 tdata->ciphertext.len_bits >> 3);
6312 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6313 + (tdata->digest_enc.offset == 0 ?
6314 plaintext_pad_len : tdata->digest_enc.offset);
6316 debug_hexdump(stdout, "digest:", ut_params->digest,
6317 tdata->digest_enc.len);
6318 debug_hexdump(stdout, "digest expected:",
6319 tdata->digest_enc.data,
6320 tdata->digest_enc.len);
6325 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6327 tdata->plaintext.data,
6328 tdata->plaintext.len_bits >> 3,
6329 "Plaintext data not as expected");
6331 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6333 tdata->ciphertext.data,
6334 tdata->validDataLen.len_bits,
6335 "Ciphertext data not as expected");
6337 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6339 tdata->digest_enc.data,
6340 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6341 "Generated auth tag not as expected");
6344 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6345 "crypto op processing failed");
6351 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6352 uint8_t op_mode, uint8_t verify)
6354 struct crypto_testsuite_params *ts_params = &testsuite_params;
6355 struct crypto_unittest_params *ut_params = &unittest_params;
6359 const uint8_t *plaintext = NULL;
6360 const uint8_t *ciphertext = NULL;
6361 const uint8_t *digest = NULL;
6362 unsigned int plaintext_pad_len;
6363 unsigned int plaintext_len;
6364 unsigned int ciphertext_pad_len;
6365 unsigned int ciphertext_len;
6366 uint8_t buffer[10000];
6367 uint8_t digest_buffer[10000];
6369 struct rte_cryptodev_info dev_info;
6370 struct rte_crypto_op *op;
6372 /* Check if device supports particular algorithms */
6373 if (test_mixed_check_if_unsupported(tdata))
6376 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6378 uint64_t feat_flags = dev_info.feature_flags;
6380 if (op_mode == IN_PLACE) {
6381 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6382 printf("Device doesn't support in-place scatter-gather "
6383 "in both input and output mbufs.\n");
6387 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6388 printf("Device doesn't support out-of-place scatter-gather "
6389 "in both input and output mbufs.\n");
6392 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6393 printf("Device doesn't support digest encrypted.\n");
6398 /* Create the session */
6400 retval = create_wireless_algo_cipher_auth_session(
6401 ts_params->valid_devs[0],
6402 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6403 RTE_CRYPTO_AUTH_OP_VERIFY,
6406 tdata->auth_key.data, tdata->auth_key.len,
6407 tdata->auth_iv.len, tdata->digest_enc.len,
6408 tdata->cipher_iv.len);
6410 retval = create_wireless_algo_auth_cipher_session(
6411 ts_params->valid_devs[0],
6412 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6413 RTE_CRYPTO_AUTH_OP_GENERATE,
6416 tdata->auth_key.data, tdata->auth_key.len,
6417 tdata->auth_iv.len, tdata->digest_enc.len,
6418 tdata->cipher_iv.len);
6422 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6423 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6424 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6425 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6427 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6428 ciphertext_pad_len, 15, 0);
6429 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6430 "Failed to allocate input buffer in mempool");
6432 if (op_mode == OUT_OF_PLACE) {
6433 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6434 plaintext_pad_len, 15, 0);
6435 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6436 "Failed to allocate output buffer in mempool");
6440 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6441 tdata->ciphertext.data);
6442 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6443 ciphertext_len, buffer);
6444 debug_hexdump(stdout, "ciphertext:", ciphertext,
6447 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6448 tdata->plaintext.data);
6449 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6450 plaintext_len, buffer);
6451 debug_hexdump(stdout, "plaintext:", plaintext,
6454 memset(buffer, 0, sizeof(buffer));
6456 /* Create the operation */
6457 retval = create_wireless_algo_auth_cipher_operation(
6458 tdata->digest_enc.data, tdata->digest_enc.len,
6459 tdata->cipher_iv.data, tdata->cipher_iv.len,
6460 tdata->auth_iv.data, tdata->auth_iv.len,
6461 (tdata->digest_enc.offset == 0 ?
6463 : tdata->digest_enc.offset),
6464 tdata->validCipherLen.len_bits,
6465 tdata->cipher.offset_bits,
6466 tdata->validAuthLen.len_bits,
6467 tdata->auth.offset_bits,
6468 op_mode, 1, verify);
6473 op = process_crypto_request(ts_params->valid_devs[0],
6476 /* Check if the op failed because the device doesn't */
6477 /* support this particular combination of algorithms */
6478 if (op == NULL && ut_params->op->status ==
6479 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6480 printf("Device doesn't support this mixed combination. "
6487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6489 ut_params->obuf = (op_mode == IN_PLACE ?
6490 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6493 if (ut_params->obuf)
6494 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6495 plaintext_len, buffer);
6497 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6498 plaintext_len, buffer);
6500 debug_hexdump(stdout, "plaintext:", plaintext,
6501 (tdata->plaintext.len_bits >> 3) -
6502 tdata->digest_enc.len);
6503 debug_hexdump(stdout, "plaintext expected:",
6504 tdata->plaintext.data,
6505 (tdata->plaintext.len_bits >> 3) -
6506 tdata->digest_enc.len);
6508 if (ut_params->obuf)
6509 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6510 ciphertext_len, buffer);
6512 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6513 ciphertext_len, buffer);
6515 debug_hexdump(stdout, "ciphertext:", ciphertext,
6517 debug_hexdump(stdout, "ciphertext expected:",
6518 tdata->ciphertext.data,
6519 tdata->ciphertext.len_bits >> 3);
6521 if (ut_params->obuf)
6522 digest = rte_pktmbuf_read(ut_params->obuf,
6523 (tdata->digest_enc.offset == 0 ?
6525 tdata->digest_enc.offset),
6526 tdata->digest_enc.len, digest_buffer);
6528 digest = rte_pktmbuf_read(ut_params->ibuf,
6529 (tdata->digest_enc.offset == 0 ?
6531 tdata->digest_enc.offset),
6532 tdata->digest_enc.len, digest_buffer);
6534 debug_hexdump(stdout, "digest:", digest,
6535 tdata->digest_enc.len);
6536 debug_hexdump(stdout, "digest expected:",
6537 tdata->digest_enc.data, tdata->digest_enc.len);
6542 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6544 tdata->plaintext.data,
6545 tdata->plaintext.len_bits >> 3,
6546 "Plaintext data not as expected");
6548 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6550 tdata->ciphertext.data,
6551 tdata->validDataLen.len_bits,
6552 "Ciphertext data not as expected");
6553 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6555 tdata->digest_enc.data,
6556 tdata->digest_enc.len,
6557 "Generated auth tag not as expected");
6560 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6561 "crypto op processing failed");
6566 /** AUTH AES CMAC + CIPHER AES CTR */
6569 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6571 return test_mixed_auth_cipher(
6572 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6576 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6578 return test_mixed_auth_cipher(
6579 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6583 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6585 return test_mixed_auth_cipher_sgl(
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_sgl(void)
6592 return test_mixed_auth_cipher_sgl(
6593 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6597 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6599 return test_mixed_auth_cipher(
6600 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6604 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6606 return test_mixed_auth_cipher(
6607 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6611 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6613 return test_mixed_auth_cipher_sgl(
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_sgl(void)
6620 return test_mixed_auth_cipher_sgl(
6621 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6624 /** MIXED AUTH + CIPHER */
6627 test_auth_zuc_cipher_snow_test_case_1(void)
6629 return test_mixed_auth_cipher(
6630 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6634 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6636 return test_mixed_auth_cipher(
6637 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6641 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6643 return test_mixed_auth_cipher(
6644 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6648 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6650 return test_mixed_auth_cipher(
6651 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6655 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6657 return test_mixed_auth_cipher(
6658 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6662 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6664 return test_mixed_auth_cipher(
6665 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6669 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6671 return test_mixed_auth_cipher(
6672 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6676 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6678 return test_mixed_auth_cipher(
6679 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6683 test_auth_snow_cipher_zuc_test_case_1(void)
6685 return test_mixed_auth_cipher(
6686 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6690 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6692 return test_mixed_auth_cipher(
6693 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6697 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6699 return test_mixed_auth_cipher(
6700 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6704 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6706 return test_mixed_auth_cipher(
6707 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6711 test_auth_null_cipher_snow_test_case_1(void)
6713 return test_mixed_auth_cipher(
6714 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6718 test_verify_auth_null_cipher_snow_test_case_1(void)
6720 return test_mixed_auth_cipher(
6721 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6725 test_auth_null_cipher_zuc_test_case_1(void)
6727 return test_mixed_auth_cipher(
6728 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6732 test_verify_auth_null_cipher_zuc_test_case_1(void)
6734 return test_mixed_auth_cipher(
6735 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6739 test_auth_snow_cipher_null_test_case_1(void)
6741 return test_mixed_auth_cipher(
6742 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6746 test_verify_auth_snow_cipher_null_test_case_1(void)
6748 return test_mixed_auth_cipher(
6749 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6753 test_auth_zuc_cipher_null_test_case_1(void)
6755 return test_mixed_auth_cipher(
6756 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6760 test_verify_auth_zuc_cipher_null_test_case_1(void)
6762 return test_mixed_auth_cipher(
6763 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6767 test_auth_null_cipher_aes_ctr_test_case_1(void)
6769 return test_mixed_auth_cipher(
6770 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6774 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6776 return test_mixed_auth_cipher(
6777 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6781 test_auth_aes_cmac_cipher_null_test_case_1(void)
6783 return test_mixed_auth_cipher(
6784 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6788 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6790 return test_mixed_auth_cipher(
6791 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6794 /* ***** AEAD algorithm Tests ***** */
6797 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6798 enum rte_crypto_aead_operation op,
6799 const uint8_t *key, const uint8_t key_len,
6800 const uint16_t aad_len, const uint8_t auth_len,
6803 uint8_t aead_key[key_len];
6805 struct crypto_testsuite_params *ts_params = &testsuite_params;
6806 struct crypto_unittest_params *ut_params = &unittest_params;
6808 memcpy(aead_key, key, key_len);
6810 /* Setup AEAD Parameters */
6811 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6812 ut_params->aead_xform.next = NULL;
6813 ut_params->aead_xform.aead.algo = algo;
6814 ut_params->aead_xform.aead.op = op;
6815 ut_params->aead_xform.aead.key.data = aead_key;
6816 ut_params->aead_xform.aead.key.length = key_len;
6817 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6818 ut_params->aead_xform.aead.iv.length = iv_len;
6819 ut_params->aead_xform.aead.digest_length = auth_len;
6820 ut_params->aead_xform.aead.aad_length = aad_len;
6822 debug_hexdump(stdout, "key:", key, key_len);
6824 /* Create Crypto session*/
6825 ut_params->sess = rte_cryptodev_sym_session_create(
6826 ts_params->session_mpool);
6828 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6829 &ut_params->aead_xform,
6830 ts_params->session_priv_mpool);
6832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6838 create_aead_xform(struct rte_crypto_op *op,
6839 enum rte_crypto_aead_algorithm algo,
6840 enum rte_crypto_aead_operation aead_op,
6841 uint8_t *key, const uint8_t key_len,
6842 const uint8_t aad_len, const uint8_t auth_len,
6845 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6846 "failed to allocate space for crypto transform");
6848 struct rte_crypto_sym_op *sym_op = op->sym;
6850 /* Setup AEAD Parameters */
6851 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6852 sym_op->xform->next = NULL;
6853 sym_op->xform->aead.algo = algo;
6854 sym_op->xform->aead.op = aead_op;
6855 sym_op->xform->aead.key.data = key;
6856 sym_op->xform->aead.key.length = key_len;
6857 sym_op->xform->aead.iv.offset = IV_OFFSET;
6858 sym_op->xform->aead.iv.length = iv_len;
6859 sym_op->xform->aead.digest_length = auth_len;
6860 sym_op->xform->aead.aad_length = aad_len;
6862 debug_hexdump(stdout, "key:", key, key_len);
6868 create_aead_operation(enum rte_crypto_aead_operation op,
6869 const struct aead_test_data *tdata)
6871 struct crypto_testsuite_params *ts_params = &testsuite_params;
6872 struct crypto_unittest_params *ut_params = &unittest_params;
6874 uint8_t *plaintext, *ciphertext;
6875 unsigned int aad_pad_len, plaintext_pad_len;
6877 /* Generate Crypto op data structure */
6878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6880 TEST_ASSERT_NOT_NULL(ut_params->op,
6881 "Failed to allocate symmetric crypto operation struct");
6883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6885 /* Append aad data */
6886 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6887 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6888 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6890 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6891 "no room to append aad");
6893 sym_op->aead.aad.phys_addr =
6894 rte_pktmbuf_iova(ut_params->ibuf);
6895 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6896 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6897 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6900 /* Append IV at the end of the crypto operation*/
6901 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6902 uint8_t *, IV_OFFSET);
6904 /* Copy IV 1 byte after the IV pointer, according to the API */
6905 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6906 debug_hexdump(stdout, "iv:", iv_ptr,
6909 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6910 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6912 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6913 "no room to append aad");
6915 sym_op->aead.aad.phys_addr =
6916 rte_pktmbuf_iova(ut_params->ibuf);
6917 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6918 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6921 /* Append IV at the end of the crypto operation*/
6922 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6923 uint8_t *, IV_OFFSET);
6925 if (tdata->iv.len == 0) {
6926 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6927 debug_hexdump(stdout, "iv:", iv_ptr,
6930 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6931 debug_hexdump(stdout, "iv:", iv_ptr,
6936 /* Append plaintext/ciphertext */
6937 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6938 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6939 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6941 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6943 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6944 debug_hexdump(stdout, "plaintext:", plaintext,
6945 tdata->plaintext.len);
6947 if (ut_params->obuf) {
6948 ciphertext = (uint8_t *)rte_pktmbuf_append(
6950 plaintext_pad_len + aad_pad_len);
6951 TEST_ASSERT_NOT_NULL(ciphertext,
6952 "no room to append ciphertext");
6954 memset(ciphertext + aad_pad_len, 0,
6955 tdata->ciphertext.len);
6958 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6959 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6961 TEST_ASSERT_NOT_NULL(ciphertext,
6962 "no room to append ciphertext");
6964 memcpy(ciphertext, tdata->ciphertext.data,
6965 tdata->ciphertext.len);
6966 debug_hexdump(stdout, "ciphertext:", ciphertext,
6967 tdata->ciphertext.len);
6969 if (ut_params->obuf) {
6970 plaintext = (uint8_t *)rte_pktmbuf_append(
6972 plaintext_pad_len + aad_pad_len);
6973 TEST_ASSERT_NOT_NULL(plaintext,
6974 "no room to append plaintext");
6976 memset(plaintext + aad_pad_len, 0,
6977 tdata->plaintext.len);
6981 /* Append digest data */
6982 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6983 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6984 ut_params->obuf ? ut_params->obuf :
6986 tdata->auth_tag.len);
6987 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6988 "no room to append digest");
6989 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6990 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6991 ut_params->obuf ? ut_params->obuf :
6996 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6997 ut_params->ibuf, tdata->auth_tag.len);
6998 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6999 "no room to append digest");
7000 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7002 plaintext_pad_len + aad_pad_len);
7004 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7005 tdata->auth_tag.len);
7006 debug_hexdump(stdout, "digest:",
7007 sym_op->aead.digest.data,
7008 tdata->auth_tag.len);
7011 sym_op->aead.data.length = tdata->plaintext.len;
7012 sym_op->aead.data.offset = aad_pad_len;
7018 test_authenticated_encryption(const struct aead_test_data *tdata)
7020 struct crypto_testsuite_params *ts_params = &testsuite_params;
7021 struct crypto_unittest_params *ut_params = &unittest_params;
7024 uint8_t *ciphertext, *auth_tag;
7025 uint16_t plaintext_pad_len;
7028 /* Verify the capabilities */
7029 struct rte_cryptodev_sym_capability_idx cap_idx;
7030 const struct rte_cryptodev_symmetric_capability *capability;
7031 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7032 cap_idx.algo.aead = tdata->algo;
7033 capability = rte_cryptodev_sym_capability_get(
7034 ts_params->valid_devs[0], &cap_idx);
7035 if (capability == NULL)
7037 if (rte_cryptodev_sym_capability_check_aead(
7038 capability, tdata->key.len, tdata->auth_tag.len,
7039 tdata->aad.len, tdata->iv.len))
7042 /* Create AEAD session */
7043 retval = create_aead_session(ts_params->valid_devs[0],
7045 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7046 tdata->key.data, tdata->key.len,
7047 tdata->aad.len, tdata->auth_tag.len,
7052 if (tdata->aad.len > MBUF_SIZE) {
7053 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7054 /* Populate full size of add data */
7055 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7056 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7060 /* clear mbuf payload */
7061 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7062 rte_pktmbuf_tailroom(ut_params->ibuf));
7064 /* Create AEAD operation */
7065 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7069 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7071 ut_params->op->sym->m_src = ut_params->ibuf;
7073 /* Process crypto operation */
7074 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7075 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7077 TEST_ASSERT_NOT_NULL(
7078 process_crypto_request(ts_params->valid_devs[0],
7079 ut_params->op), "failed to process sym crypto op");
7081 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7082 "crypto op processing failed");
7084 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7086 if (ut_params->op->sym->m_dst) {
7087 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7089 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7090 uint8_t *, plaintext_pad_len);
7092 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7094 ut_params->op->sym->cipher.data.offset);
7095 auth_tag = ciphertext + plaintext_pad_len;
7098 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7099 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7102 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7104 tdata->ciphertext.data,
7105 tdata->ciphertext.len,
7106 "Ciphertext data not as expected");
7108 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7110 tdata->auth_tag.data,
7111 tdata->auth_tag.len,
7112 "Generated auth tag not as expected");
7118 #ifdef RTE_LIBRTE_SECURITY
7119 /* Basic algorithm run function for async inplace mode.
7120 * Creates a session from input parameters and runs one operation
7121 * on input_vec. Checks the output of the crypto operation against
7125 test_pdcp_proto(int i, int oop,
7126 enum rte_crypto_cipher_operation opc,
7127 enum rte_crypto_auth_operation opa,
7129 unsigned int input_vec_len,
7130 uint8_t *output_vec,
7131 unsigned int output_vec_len)
7133 struct crypto_testsuite_params *ts_params = &testsuite_params;
7134 struct crypto_unittest_params *ut_params = &unittest_params;
7136 int ret = TEST_SUCCESS;
7137 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7138 rte_cryptodev_get_sec_ctx(
7139 ts_params->valid_devs[0]);
7141 /* Verify the capabilities */
7142 struct rte_security_capability_idx sec_cap_idx;
7144 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7145 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7146 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7147 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7150 /* Generate test mbuf data */
7151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7153 /* clear mbuf payload */
7154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7155 rte_pktmbuf_tailroom(ut_params->ibuf));
7157 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7159 memcpy(plaintext, input_vec, input_vec_len);
7161 /* Out of place support */
7164 * For out-op-place we need to alloc another mbuf
7166 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7167 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7170 /* Set crypto type as IPSEC */
7171 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7173 /* Setup Cipher Parameters */
7174 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7175 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7176 ut_params->cipher_xform.cipher.op = opc;
7177 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7178 ut_params->cipher_xform.cipher.key.length =
7179 pdcp_test_params[i].cipher_key_len;
7180 ut_params->cipher_xform.cipher.iv.length = 0;
7182 /* Setup HMAC Parameters if ICV header is required */
7183 if (pdcp_test_params[i].auth_alg != 0) {
7184 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7185 ut_params->auth_xform.next = NULL;
7186 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7187 ut_params->auth_xform.auth.op = opa;
7188 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7189 ut_params->auth_xform.auth.key.length =
7190 pdcp_test_params[i].auth_key_len;
7192 ut_params->cipher_xform.next = &ut_params->auth_xform;
7194 ut_params->cipher_xform.next = NULL;
7197 struct rte_security_session_conf sess_conf = {
7198 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7199 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7201 .bearer = pdcp_test_bearer[i],
7202 .domain = pdcp_test_params[i].domain,
7203 .pkt_dir = pdcp_test_packet_direction[i],
7204 .sn_size = pdcp_test_data_sn_size[i],
7205 .hfn = pdcp_test_hfn[i],
7206 .hfn_threshold = pdcp_test_hfn_threshold[i],
7208 .crypto_xform = &ut_params->cipher_xform
7211 /* Create security session */
7212 ut_params->sec_session = rte_security_session_create(ctx,
7213 &sess_conf, ts_params->session_priv_mpool);
7215 if (!ut_params->sec_session) {
7216 printf("TestCase %s()-%d line %d failed %s: ",
7217 __func__, i, __LINE__, "Failed to allocate session");
7222 /* Generate crypto op data structure */
7223 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7224 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7225 if (!ut_params->op) {
7226 printf("TestCase %s()-%d line %d failed %s: ",
7227 __func__, i, __LINE__,
7228 "Failed to allocate symmetric crypto operation struct");
7233 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7235 /* set crypto operation source mbuf */
7236 ut_params->op->sym->m_src = ut_params->ibuf;
7238 ut_params->op->sym->m_dst = ut_params->obuf;
7240 /* Process crypto operation */
7241 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7243 printf("TestCase %s()-%d line %d failed %s: ",
7244 __func__, i, __LINE__,
7245 "failed to process sym crypto op");
7250 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7251 printf("TestCase %s()-%d line %d failed %s: ",
7252 __func__, i, __LINE__, "crypto op processing failed");
7258 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7261 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7265 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7266 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7267 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7268 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7274 rte_crypto_op_free(ut_params->op);
7275 ut_params->op = NULL;
7277 if (ut_params->sec_session)
7278 rte_security_session_destroy(ctx, ut_params->sec_session);
7279 ut_params->sec_session = NULL;
7281 rte_pktmbuf_free(ut_params->ibuf);
7282 ut_params->ibuf = NULL;
7284 rte_pktmbuf_free(ut_params->obuf);
7285 ut_params->obuf = NULL;
7292 test_pdcp_proto_SGL(int i, int oop,
7293 enum rte_crypto_cipher_operation opc,
7294 enum rte_crypto_auth_operation opa,
7296 unsigned int input_vec_len,
7297 uint8_t *output_vec,
7298 unsigned int output_vec_len,
7300 uint32_t fragsz_oop)
7302 struct crypto_testsuite_params *ts_params = &testsuite_params;
7303 struct crypto_unittest_params *ut_params = &unittest_params;
7305 struct rte_mbuf *buf, *buf_oop = NULL;
7306 int ret = TEST_SUCCESS;
7310 unsigned int trn_data = 0;
7311 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7312 rte_cryptodev_get_sec_ctx(
7313 ts_params->valid_devs[0]);
7315 /* Verify the capabilities */
7316 struct rte_security_capability_idx sec_cap_idx;
7318 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7319 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7320 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7321 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7324 if (fragsz > input_vec_len)
7325 fragsz = input_vec_len;
7327 uint16_t plaintext_len = fragsz;
7328 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7330 if (fragsz_oop > output_vec_len)
7331 frag_size_oop = output_vec_len;
7334 if (input_vec_len % fragsz != 0) {
7335 if (input_vec_len / fragsz + 1 > 16)
7337 } else if (input_vec_len / fragsz > 16)
7340 /* Out of place support */
7343 * For out-op-place we need to alloc another mbuf
7345 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7346 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7347 buf_oop = ut_params->obuf;
7350 /* Generate test mbuf data */
7351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7353 /* clear mbuf payload */
7354 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7355 rte_pktmbuf_tailroom(ut_params->ibuf));
7357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7359 memcpy(plaintext, input_vec, plaintext_len);
7360 trn_data += plaintext_len;
7362 buf = ut_params->ibuf;
7365 * Loop until no more fragments
7368 while (trn_data < input_vec_len) {
7370 to_trn = (input_vec_len - trn_data < fragsz) ?
7371 (input_vec_len - trn_data) : fragsz;
7373 to_trn_tbl[ecx++] = to_trn;
7375 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7378 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7379 rte_pktmbuf_tailroom(buf));
7382 if (oop && !fragsz_oop) {
7384 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7385 buf_oop = buf_oop->next;
7386 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7387 0, rte_pktmbuf_tailroom(buf_oop));
7388 rte_pktmbuf_append(buf_oop, to_trn);
7391 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7394 memcpy(plaintext, input_vec + trn_data, to_trn);
7398 ut_params->ibuf->nb_segs = segs;
7401 if (fragsz_oop && oop) {
7405 trn_data = frag_size_oop;
7406 while (trn_data < output_vec_len) {
7409 (output_vec_len - trn_data <
7411 (output_vec_len - trn_data) :
7414 to_trn_tbl[ecx++] = to_trn;
7417 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7418 buf_oop = buf_oop->next;
7419 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7420 0, rte_pktmbuf_tailroom(buf_oop));
7421 rte_pktmbuf_append(buf_oop, to_trn);
7425 ut_params->obuf->nb_segs = segs;
7428 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7430 /* Setup Cipher Parameters */
7431 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7432 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7433 ut_params->cipher_xform.cipher.op = opc;
7434 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7435 ut_params->cipher_xform.cipher.key.length =
7436 pdcp_test_params[i].cipher_key_len;
7437 ut_params->cipher_xform.cipher.iv.length = 0;
7439 /* Setup HMAC Parameters if ICV header is required */
7440 if (pdcp_test_params[i].auth_alg != 0) {
7441 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7442 ut_params->auth_xform.next = NULL;
7443 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7444 ut_params->auth_xform.auth.op = opa;
7445 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7446 ut_params->auth_xform.auth.key.length =
7447 pdcp_test_params[i].auth_key_len;
7449 ut_params->cipher_xform.next = &ut_params->auth_xform;
7451 ut_params->cipher_xform.next = NULL;
7454 struct rte_security_session_conf sess_conf = {
7455 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7456 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7458 .bearer = pdcp_test_bearer[i],
7459 .domain = pdcp_test_params[i].domain,
7460 .pkt_dir = pdcp_test_packet_direction[i],
7461 .sn_size = pdcp_test_data_sn_size[i],
7462 .hfn = pdcp_test_hfn[i],
7463 .hfn_threshold = pdcp_test_hfn_threshold[i],
7465 .crypto_xform = &ut_params->cipher_xform
7468 /* Create security session */
7469 ut_params->sec_session = rte_security_session_create(ctx,
7470 &sess_conf, ts_params->session_priv_mpool);
7472 if (!ut_params->sec_session) {
7473 printf("TestCase %s()-%d line %d failed %s: ",
7474 __func__, i, __LINE__, "Failed to allocate session");
7479 /* Generate crypto op data structure */
7480 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7481 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7482 if (!ut_params->op) {
7483 printf("TestCase %s()-%d line %d failed %s: ",
7484 __func__, i, __LINE__,
7485 "Failed to allocate symmetric crypto operation struct");
7490 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7492 /* set crypto operation source mbuf */
7493 ut_params->op->sym->m_src = ut_params->ibuf;
7495 ut_params->op->sym->m_dst = ut_params->obuf;
7497 /* Process crypto operation */
7498 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7500 printf("TestCase %s()-%d line %d failed %s: ",
7501 __func__, i, __LINE__,
7502 "failed to process sym crypto op");
7507 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7508 printf("TestCase %s()-%d line %d failed %s: ",
7509 __func__, i, __LINE__, "crypto op processing failed");
7515 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7518 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7522 fragsz = frag_size_oop;
7523 if (memcmp(ciphertext, output_vec, fragsz)) {
7524 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7525 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7526 rte_hexdump(stdout, "reference", output_vec, fragsz);
7531 buf = ut_params->op->sym->m_src->next;
7533 buf = ut_params->op->sym->m_dst->next;
7535 unsigned int off = fragsz;
7539 ciphertext = rte_pktmbuf_mtod(buf,
7541 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7542 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7543 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7544 rte_hexdump(stdout, "reference", output_vec + off,
7549 off += to_trn_tbl[ecx++];
7553 rte_crypto_op_free(ut_params->op);
7554 ut_params->op = NULL;
7556 if (ut_params->sec_session)
7557 rte_security_session_destroy(ctx, ut_params->sec_session);
7558 ut_params->sec_session = NULL;
7560 rte_pktmbuf_free(ut_params->ibuf);
7561 ut_params->ibuf = NULL;
7563 rte_pktmbuf_free(ut_params->obuf);
7564 ut_params->obuf = NULL;
7571 test_pdcp_proto_cplane_encap(int i)
7573 return test_pdcp_proto(i, 0,
7574 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7575 RTE_CRYPTO_AUTH_OP_GENERATE,
7576 pdcp_test_data_in[i],
7577 pdcp_test_data_in_len[i],
7578 pdcp_test_data_out[i],
7579 pdcp_test_data_in_len[i]+4);
7583 test_pdcp_proto_uplane_encap(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7587 RTE_CRYPTO_AUTH_OP_GENERATE,
7588 pdcp_test_data_in[i],
7589 pdcp_test_data_in_len[i],
7590 pdcp_test_data_out[i],
7591 pdcp_test_data_in_len[i]);
7596 test_pdcp_proto_uplane_encap_with_int(int i)
7598 return test_pdcp_proto(i, 0,
7599 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7600 RTE_CRYPTO_AUTH_OP_GENERATE,
7601 pdcp_test_data_in[i],
7602 pdcp_test_data_in_len[i],
7603 pdcp_test_data_out[i],
7604 pdcp_test_data_in_len[i] + 4);
7608 test_pdcp_proto_cplane_decap(int i)
7610 return test_pdcp_proto(i, 0,
7611 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7612 RTE_CRYPTO_AUTH_OP_VERIFY,
7613 pdcp_test_data_out[i],
7614 pdcp_test_data_in_len[i] + 4,
7615 pdcp_test_data_in[i],
7616 pdcp_test_data_in_len[i]);
7620 test_pdcp_proto_uplane_decap(int i)
7622 return test_pdcp_proto(i, 0,
7623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7624 RTE_CRYPTO_AUTH_OP_VERIFY,
7625 pdcp_test_data_out[i],
7626 pdcp_test_data_in_len[i],
7627 pdcp_test_data_in[i],
7628 pdcp_test_data_in_len[i]);
7632 test_pdcp_proto_uplane_decap_with_int(int i)
7634 return test_pdcp_proto(i, 0,
7635 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7636 RTE_CRYPTO_AUTH_OP_VERIFY,
7637 pdcp_test_data_out[i],
7638 pdcp_test_data_in_len[i] + 4,
7639 pdcp_test_data_in[i],
7640 pdcp_test_data_in_len[i]);
7644 test_PDCP_PROTO_SGL_in_place_32B(void)
7646 /* i can be used for running any PDCP case
7647 * In this case it is uplane 12-bit AES-SNOW DL encap
7649 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7650 return test_pdcp_proto_SGL(i, IN_PLACE,
7651 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7652 RTE_CRYPTO_AUTH_OP_GENERATE,
7653 pdcp_test_data_in[i],
7654 pdcp_test_data_in_len[i],
7655 pdcp_test_data_out[i],
7656 pdcp_test_data_in_len[i]+4,
7660 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7662 /* i can be used for running any PDCP case
7663 * In this case it is uplane 18-bit NULL-NULL DL encap
7665 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7666 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7667 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7668 RTE_CRYPTO_AUTH_OP_GENERATE,
7669 pdcp_test_data_in[i],
7670 pdcp_test_data_in_len[i],
7671 pdcp_test_data_out[i],
7672 pdcp_test_data_in_len[i]+4,
7676 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7678 /* i can be used for running any PDCP case
7679 * In this case it is uplane 18-bit AES DL encap
7681 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7683 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7684 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7685 RTE_CRYPTO_AUTH_OP_GENERATE,
7686 pdcp_test_data_in[i],
7687 pdcp_test_data_in_len[i],
7688 pdcp_test_data_out[i],
7689 pdcp_test_data_in_len[i],
7693 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7695 /* i can be used for running any PDCP case
7696 * In this case it is cplane 12-bit AES-ZUC DL encap
7698 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7699 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7700 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7701 RTE_CRYPTO_AUTH_OP_GENERATE,
7702 pdcp_test_data_in[i],
7703 pdcp_test_data_in_len[i],
7704 pdcp_test_data_out[i],
7705 pdcp_test_data_in_len[i]+4,
7710 test_PDCP_PROTO_all(void)
7712 struct crypto_testsuite_params *ts_params = &testsuite_params;
7713 struct rte_cryptodev_info dev_info;
7716 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7717 uint64_t feat_flags = dev_info.feature_flags;
7719 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7722 status = test_PDCP_PROTO_cplane_encap_all();
7723 status += test_PDCP_PROTO_cplane_decap_all();
7724 status += test_PDCP_PROTO_uplane_encap_all();
7725 status += test_PDCP_PROTO_uplane_decap_all();
7726 status += test_PDCP_PROTO_SGL_in_place_32B();
7727 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7728 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7729 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7734 return TEST_SUCCESS;
7739 test_AES_GCM_authenticated_encryption_test_case_1(void)
7741 return test_authenticated_encryption(&gcm_test_case_1);
7745 test_AES_GCM_authenticated_encryption_test_case_2(void)
7747 return test_authenticated_encryption(&gcm_test_case_2);
7751 test_AES_GCM_authenticated_encryption_test_case_3(void)
7753 return test_authenticated_encryption(&gcm_test_case_3);
7757 test_AES_GCM_authenticated_encryption_test_case_4(void)
7759 return test_authenticated_encryption(&gcm_test_case_4);
7763 test_AES_GCM_authenticated_encryption_test_case_5(void)
7765 return test_authenticated_encryption(&gcm_test_case_5);
7769 test_AES_GCM_authenticated_encryption_test_case_6(void)
7771 return test_authenticated_encryption(&gcm_test_case_6);
7775 test_AES_GCM_authenticated_encryption_test_case_7(void)
7777 return test_authenticated_encryption(&gcm_test_case_7);
7781 test_AES_GCM_authenticated_encryption_test_case_8(void)
7783 return test_authenticated_encryption(&gcm_test_case_8);
7787 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
7789 return test_authenticated_encryption(&gcm_J0_test_case_1);
7793 test_AES_GCM_auth_encryption_test_case_192_1(void)
7795 return test_authenticated_encryption(&gcm_test_case_192_1);
7799 test_AES_GCM_auth_encryption_test_case_192_2(void)
7801 return test_authenticated_encryption(&gcm_test_case_192_2);
7805 test_AES_GCM_auth_encryption_test_case_192_3(void)
7807 return test_authenticated_encryption(&gcm_test_case_192_3);
7811 test_AES_GCM_auth_encryption_test_case_192_4(void)
7813 return test_authenticated_encryption(&gcm_test_case_192_4);
7817 test_AES_GCM_auth_encryption_test_case_192_5(void)
7819 return test_authenticated_encryption(&gcm_test_case_192_5);
7823 test_AES_GCM_auth_encryption_test_case_192_6(void)
7825 return test_authenticated_encryption(&gcm_test_case_192_6);
7829 test_AES_GCM_auth_encryption_test_case_192_7(void)
7831 return test_authenticated_encryption(&gcm_test_case_192_7);
7835 test_AES_GCM_auth_encryption_test_case_256_1(void)
7837 return test_authenticated_encryption(&gcm_test_case_256_1);
7841 test_AES_GCM_auth_encryption_test_case_256_2(void)
7843 return test_authenticated_encryption(&gcm_test_case_256_2);
7847 test_AES_GCM_auth_encryption_test_case_256_3(void)
7849 return test_authenticated_encryption(&gcm_test_case_256_3);
7853 test_AES_GCM_auth_encryption_test_case_256_4(void)
7855 return test_authenticated_encryption(&gcm_test_case_256_4);
7859 test_AES_GCM_auth_encryption_test_case_256_5(void)
7861 return test_authenticated_encryption(&gcm_test_case_256_5);
7865 test_AES_GCM_auth_encryption_test_case_256_6(void)
7867 return test_authenticated_encryption(&gcm_test_case_256_6);
7871 test_AES_GCM_auth_encryption_test_case_256_7(void)
7873 return test_authenticated_encryption(&gcm_test_case_256_7);
7877 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7879 return test_authenticated_encryption(&gcm_test_case_aad_1);
7883 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7885 return test_authenticated_encryption(&gcm_test_case_aad_2);
7889 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7891 struct aead_test_data tdata;
7894 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7895 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7896 tdata.iv.data[0] += 1;
7897 res = test_authenticated_encryption(&tdata);
7898 if (res == -ENOTSUP)
7900 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7901 return TEST_SUCCESS;
7905 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7907 struct aead_test_data tdata;
7910 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7911 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7912 tdata.plaintext.data[0] += 1;
7913 res = test_authenticated_encryption(&tdata);
7914 if (res == -ENOTSUP)
7916 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7917 return TEST_SUCCESS;
7921 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7923 struct aead_test_data tdata;
7926 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7927 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7928 tdata.ciphertext.data[0] += 1;
7929 res = test_authenticated_encryption(&tdata);
7930 if (res == -ENOTSUP)
7932 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7933 return TEST_SUCCESS;
7937 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7939 struct aead_test_data tdata;
7942 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7943 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7945 res = test_authenticated_encryption(&tdata);
7946 if (res == -ENOTSUP)
7948 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7949 return TEST_SUCCESS;
7953 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7955 struct aead_test_data tdata;
7956 uint8_t aad[gcm_test_case_7.aad.len];
7959 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7960 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7961 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7963 tdata.aad.data = aad;
7964 res = test_authenticated_encryption(&tdata);
7965 if (res == -ENOTSUP)
7967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7968 return TEST_SUCCESS;
7972 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7974 struct aead_test_data tdata;
7977 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7978 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7979 tdata.auth_tag.data[0] += 1;
7980 res = test_authenticated_encryption(&tdata);
7981 if (res == -ENOTSUP)
7983 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7984 return TEST_SUCCESS;
7988 test_authenticated_decryption(const struct aead_test_data *tdata)
7990 struct crypto_testsuite_params *ts_params = &testsuite_params;
7991 struct crypto_unittest_params *ut_params = &unittest_params;
7997 /* Verify the capabilities */
7998 struct rte_cryptodev_sym_capability_idx cap_idx;
7999 const struct rte_cryptodev_symmetric_capability *capability;
8000 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8001 cap_idx.algo.aead = tdata->algo;
8002 capability = rte_cryptodev_sym_capability_get(
8003 ts_params->valid_devs[0], &cap_idx);
8004 if (capability == NULL)
8006 if (rte_cryptodev_sym_capability_check_aead(
8007 capability, tdata->key.len, tdata->auth_tag.len,
8008 tdata->aad.len, tdata->iv.len))
8011 /* Create AEAD session */
8012 retval = create_aead_session(ts_params->valid_devs[0],
8014 RTE_CRYPTO_AEAD_OP_DECRYPT,
8015 tdata->key.data, tdata->key.len,
8016 tdata->aad.len, tdata->auth_tag.len,
8021 /* alloc mbuf and set payload */
8022 if (tdata->aad.len > MBUF_SIZE) {
8023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8024 /* Populate full size of add data */
8025 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8026 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8030 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8031 rte_pktmbuf_tailroom(ut_params->ibuf));
8033 /* Create AEAD operation */
8034 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8038 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8040 ut_params->op->sym->m_src = ut_params->ibuf;
8042 /* Process crypto operation */
8043 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8044 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8046 TEST_ASSERT_NOT_NULL(
8047 process_crypto_request(ts_params->valid_devs[0],
8048 ut_params->op), "failed to process sym crypto op");
8050 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8051 "crypto op processing failed");
8053 if (ut_params->op->sym->m_dst)
8054 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8057 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8059 ut_params->op->sym->cipher.data.offset);
8061 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8064 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8066 tdata->plaintext.data,
8067 tdata->plaintext.len,
8068 "Plaintext data not as expected");
8070 TEST_ASSERT_EQUAL(ut_params->op->status,
8071 RTE_CRYPTO_OP_STATUS_SUCCESS,
8072 "Authentication failed");
8078 test_AES_GCM_authenticated_decryption_test_case_1(void)
8080 return test_authenticated_decryption(&gcm_test_case_1);
8084 test_AES_GCM_authenticated_decryption_test_case_2(void)
8086 return test_authenticated_decryption(&gcm_test_case_2);
8090 test_AES_GCM_authenticated_decryption_test_case_3(void)
8092 return test_authenticated_decryption(&gcm_test_case_3);
8096 test_AES_GCM_authenticated_decryption_test_case_4(void)
8098 return test_authenticated_decryption(&gcm_test_case_4);
8102 test_AES_GCM_authenticated_decryption_test_case_5(void)
8104 return test_authenticated_decryption(&gcm_test_case_5);
8108 test_AES_GCM_authenticated_decryption_test_case_6(void)
8110 return test_authenticated_decryption(&gcm_test_case_6);
8114 test_AES_GCM_authenticated_decryption_test_case_7(void)
8116 return test_authenticated_decryption(&gcm_test_case_7);
8120 test_AES_GCM_authenticated_decryption_test_case_8(void)
8122 return test_authenticated_decryption(&gcm_test_case_8);
8126 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8128 return test_authenticated_decryption(&gcm_J0_test_case_1);
8132 test_AES_GCM_auth_decryption_test_case_192_1(void)
8134 return test_authenticated_decryption(&gcm_test_case_192_1);
8138 test_AES_GCM_auth_decryption_test_case_192_2(void)
8140 return test_authenticated_decryption(&gcm_test_case_192_2);
8144 test_AES_GCM_auth_decryption_test_case_192_3(void)
8146 return test_authenticated_decryption(&gcm_test_case_192_3);
8150 test_AES_GCM_auth_decryption_test_case_192_4(void)
8152 return test_authenticated_decryption(&gcm_test_case_192_4);
8156 test_AES_GCM_auth_decryption_test_case_192_5(void)
8158 return test_authenticated_decryption(&gcm_test_case_192_5);
8162 test_AES_GCM_auth_decryption_test_case_192_6(void)
8164 return test_authenticated_decryption(&gcm_test_case_192_6);
8168 test_AES_GCM_auth_decryption_test_case_192_7(void)
8170 return test_authenticated_decryption(&gcm_test_case_192_7);
8174 test_AES_GCM_auth_decryption_test_case_256_1(void)
8176 return test_authenticated_decryption(&gcm_test_case_256_1);
8180 test_AES_GCM_auth_decryption_test_case_256_2(void)
8182 return test_authenticated_decryption(&gcm_test_case_256_2);
8186 test_AES_GCM_auth_decryption_test_case_256_3(void)
8188 return test_authenticated_decryption(&gcm_test_case_256_3);
8192 test_AES_GCM_auth_decryption_test_case_256_4(void)
8194 return test_authenticated_decryption(&gcm_test_case_256_4);
8198 test_AES_GCM_auth_decryption_test_case_256_5(void)
8200 return test_authenticated_decryption(&gcm_test_case_256_5);
8204 test_AES_GCM_auth_decryption_test_case_256_6(void)
8206 return test_authenticated_decryption(&gcm_test_case_256_6);
8210 test_AES_GCM_auth_decryption_test_case_256_7(void)
8212 return test_authenticated_decryption(&gcm_test_case_256_7);
8216 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8218 return test_authenticated_decryption(&gcm_test_case_aad_1);
8222 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8224 return test_authenticated_decryption(&gcm_test_case_aad_2);
8228 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8230 struct aead_test_data tdata;
8233 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8234 tdata.iv.data[0] += 1;
8235 res = test_authenticated_decryption(&tdata);
8236 if (res == -ENOTSUP)
8238 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8239 return TEST_SUCCESS;
8243 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8245 struct aead_test_data tdata;
8248 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8249 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8250 tdata.plaintext.data[0] += 1;
8251 res = test_authenticated_decryption(&tdata);
8252 if (res == -ENOTSUP)
8254 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8255 return TEST_SUCCESS;
8259 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8261 struct aead_test_data tdata;
8264 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8265 tdata.ciphertext.data[0] += 1;
8266 res = test_authenticated_decryption(&tdata);
8267 if (res == -ENOTSUP)
8269 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8270 return TEST_SUCCESS;
8274 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8276 struct aead_test_data tdata;
8279 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8281 res = test_authenticated_decryption(&tdata);
8282 if (res == -ENOTSUP)
8284 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8285 return TEST_SUCCESS;
8289 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8291 struct aead_test_data tdata;
8292 uint8_t aad[gcm_test_case_7.aad.len];
8295 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8296 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8298 tdata.aad.data = aad;
8299 res = test_authenticated_decryption(&tdata);
8300 if (res == -ENOTSUP)
8302 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8303 return TEST_SUCCESS;
8307 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8309 struct aead_test_data tdata;
8312 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8313 tdata.auth_tag.data[0] += 1;
8314 res = test_authenticated_decryption(&tdata);
8315 if (res == -ENOTSUP)
8317 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8318 return TEST_SUCCESS;
8322 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8324 struct crypto_testsuite_params *ts_params = &testsuite_params;
8325 struct crypto_unittest_params *ut_params = &unittest_params;
8328 uint8_t *ciphertext, *auth_tag;
8329 uint16_t plaintext_pad_len;
8331 /* Verify the capabilities */
8332 struct rte_cryptodev_sym_capability_idx cap_idx;
8333 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8334 cap_idx.algo.aead = tdata->algo;
8335 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8339 /* not supported with CPU crypto */
8340 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8343 /* Create AEAD session */
8344 retval = create_aead_session(ts_params->valid_devs[0],
8346 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8347 tdata->key.data, tdata->key.len,
8348 tdata->aad.len, tdata->auth_tag.len,
8353 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8354 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8356 /* clear mbuf payload */
8357 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8358 rte_pktmbuf_tailroom(ut_params->ibuf));
8359 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8360 rte_pktmbuf_tailroom(ut_params->obuf));
8362 /* Create AEAD operation */
8363 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8367 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8369 ut_params->op->sym->m_src = ut_params->ibuf;
8370 ut_params->op->sym->m_dst = ut_params->obuf;
8372 /* Process crypto operation */
8373 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8374 ut_params->op), "failed to process sym crypto op");
8376 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8377 "crypto op processing failed");
8379 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8381 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8382 ut_params->op->sym->cipher.data.offset);
8383 auth_tag = ciphertext + plaintext_pad_len;
8385 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8386 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8389 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8391 tdata->ciphertext.data,
8392 tdata->ciphertext.len,
8393 "Ciphertext data not as expected");
8395 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8397 tdata->auth_tag.data,
8398 tdata->auth_tag.len,
8399 "Generated auth tag not as expected");
8406 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8408 return test_authenticated_encryption_oop(&gcm_test_case_5);
8412 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8414 struct crypto_testsuite_params *ts_params = &testsuite_params;
8415 struct crypto_unittest_params *ut_params = &unittest_params;
8420 /* Verify the capabilities */
8421 struct rte_cryptodev_sym_capability_idx cap_idx;
8422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8423 cap_idx.algo.aead = tdata->algo;
8424 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8428 /* not supported with CPU crypto */
8429 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8432 /* Create AEAD session */
8433 retval = create_aead_session(ts_params->valid_devs[0],
8435 RTE_CRYPTO_AEAD_OP_DECRYPT,
8436 tdata->key.data, tdata->key.len,
8437 tdata->aad.len, tdata->auth_tag.len,
8442 /* alloc mbuf and set payload */
8443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8444 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8446 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8447 rte_pktmbuf_tailroom(ut_params->ibuf));
8448 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8449 rte_pktmbuf_tailroom(ut_params->obuf));
8451 /* Create AEAD operation */
8452 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8456 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8458 ut_params->op->sym->m_src = ut_params->ibuf;
8459 ut_params->op->sym->m_dst = ut_params->obuf;
8461 /* Process crypto operation */
8462 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8463 ut_params->op), "failed to process sym crypto op");
8465 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8466 "crypto op processing failed");
8468 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8469 ut_params->op->sym->cipher.data.offset);
8471 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8474 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8476 tdata->plaintext.data,
8477 tdata->plaintext.len,
8478 "Plaintext data not as expected");
8480 TEST_ASSERT_EQUAL(ut_params->op->status,
8481 RTE_CRYPTO_OP_STATUS_SUCCESS,
8482 "Authentication failed");
8487 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8489 return test_authenticated_decryption_oop(&gcm_test_case_5);
8493 test_authenticated_encryption_sessionless(
8494 const struct aead_test_data *tdata)
8496 struct crypto_testsuite_params *ts_params = &testsuite_params;
8497 struct crypto_unittest_params *ut_params = &unittest_params;
8500 uint8_t *ciphertext, *auth_tag;
8501 uint16_t plaintext_pad_len;
8502 uint8_t key[tdata->key.len + 1];
8503 struct rte_cryptodev_info dev_info;
8505 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8506 uint64_t feat_flags = dev_info.feature_flags;
8508 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8509 printf("Device doesn't support Sessionless ops.\n");
8513 /* not supported with CPU crypto */
8514 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8517 /* Verify the capabilities */
8518 struct rte_cryptodev_sym_capability_idx cap_idx;
8519 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8520 cap_idx.algo.aead = tdata->algo;
8521 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8525 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8527 /* clear mbuf payload */
8528 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8529 rte_pktmbuf_tailroom(ut_params->ibuf));
8531 /* Create AEAD operation */
8532 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8536 /* Create GCM xform */
8537 memcpy(key, tdata->key.data, tdata->key.len);
8538 retval = create_aead_xform(ut_params->op,
8540 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8541 key, tdata->key.len,
8542 tdata->aad.len, tdata->auth_tag.len,
8547 ut_params->op->sym->m_src = ut_params->ibuf;
8549 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8550 RTE_CRYPTO_OP_SESSIONLESS,
8551 "crypto op session type not sessionless");
8553 /* Process crypto operation */
8554 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8555 ut_params->op), "failed to process sym crypto op");
8557 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8559 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8560 "crypto op status not success");
8562 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8564 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8565 ut_params->op->sym->cipher.data.offset);
8566 auth_tag = ciphertext + plaintext_pad_len;
8568 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8569 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8572 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8574 tdata->ciphertext.data,
8575 tdata->ciphertext.len,
8576 "Ciphertext data not as expected");
8578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8580 tdata->auth_tag.data,
8581 tdata->auth_tag.len,
8582 "Generated auth tag not as expected");
8589 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8591 return test_authenticated_encryption_sessionless(
8596 test_authenticated_decryption_sessionless(
8597 const struct aead_test_data *tdata)
8599 struct crypto_testsuite_params *ts_params = &testsuite_params;
8600 struct crypto_unittest_params *ut_params = &unittest_params;
8604 uint8_t key[tdata->key.len + 1];
8605 struct rte_cryptodev_info dev_info;
8607 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8608 uint64_t feat_flags = dev_info.feature_flags;
8610 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
8611 printf("Device doesn't support Sessionless ops.\n");
8615 /* not supported with CPU crypto */
8616 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8619 /* Verify the capabilities */
8620 struct rte_cryptodev_sym_capability_idx cap_idx;
8621 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8622 cap_idx.algo.aead = tdata->algo;
8623 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8627 /* alloc mbuf and set payload */
8628 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8630 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8631 rte_pktmbuf_tailroom(ut_params->ibuf));
8633 /* Create AEAD operation */
8634 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8638 /* Create AEAD xform */
8639 memcpy(key, tdata->key.data, tdata->key.len);
8640 retval = create_aead_xform(ut_params->op,
8642 RTE_CRYPTO_AEAD_OP_DECRYPT,
8643 key, tdata->key.len,
8644 tdata->aad.len, tdata->auth_tag.len,
8649 ut_params->op->sym->m_src = ut_params->ibuf;
8651 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8652 RTE_CRYPTO_OP_SESSIONLESS,
8653 "crypto op session type not sessionless");
8655 /* Process crypto operation */
8656 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8657 ut_params->op), "failed to process sym crypto op");
8659 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8661 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8662 "crypto op status not success");
8664 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8665 ut_params->op->sym->cipher.data.offset);
8667 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8670 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8672 tdata->plaintext.data,
8673 tdata->plaintext.len,
8674 "Plaintext data not as expected");
8676 TEST_ASSERT_EQUAL(ut_params->op->status,
8677 RTE_CRYPTO_OP_STATUS_SUCCESS,
8678 "Authentication failed");
8683 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8685 return test_authenticated_decryption_sessionless(
8690 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8692 return test_authenticated_encryption(&ccm_test_case_128_1);
8696 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8698 return test_authenticated_encryption(&ccm_test_case_128_2);
8702 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8704 return test_authenticated_encryption(&ccm_test_case_128_3);
8708 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8710 return test_authenticated_decryption(&ccm_test_case_128_1);
8714 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8716 return test_authenticated_decryption(&ccm_test_case_128_2);
8720 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8722 return test_authenticated_decryption(&ccm_test_case_128_3);
8726 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8728 return test_authenticated_encryption(&ccm_test_case_192_1);
8732 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8734 return test_authenticated_encryption(&ccm_test_case_192_2);
8738 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8740 return test_authenticated_encryption(&ccm_test_case_192_3);
8744 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8746 return test_authenticated_decryption(&ccm_test_case_192_1);
8750 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8752 return test_authenticated_decryption(&ccm_test_case_192_2);
8756 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8758 return test_authenticated_decryption(&ccm_test_case_192_3);
8762 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8764 return test_authenticated_encryption(&ccm_test_case_256_1);
8768 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8770 return test_authenticated_encryption(&ccm_test_case_256_2);
8774 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8776 return test_authenticated_encryption(&ccm_test_case_256_3);
8780 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8782 return test_authenticated_decryption(&ccm_test_case_256_1);
8786 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8788 return test_authenticated_decryption(&ccm_test_case_256_2);
8792 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8794 return test_authenticated_decryption(&ccm_test_case_256_3);
8800 struct crypto_testsuite_params *ts_params = &testsuite_params;
8801 struct rte_cryptodev_stats stats;
8802 struct rte_cryptodev *dev;
8803 cryptodev_stats_get_t temp_pfn;
8805 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8808 /* Verify the capabilities */
8809 struct rte_cryptodev_sym_capability_idx cap_idx;
8810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8811 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8812 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8815 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8816 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8817 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8821 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8822 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8823 &stats) == -ENODEV),
8824 "rte_cryptodev_stats_get invalid dev failed");
8825 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8826 "rte_cryptodev_stats_get invalid Param failed");
8827 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8828 temp_pfn = dev->dev_ops->stats_get;
8829 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8830 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8832 "rte_cryptodev_stats_get invalid Param failed");
8833 dev->dev_ops->stats_get = temp_pfn;
8835 /* Test expected values */
8837 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8839 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8841 "rte_cryptodev_stats_get failed");
8842 TEST_ASSERT((stats.enqueued_count == 1),
8843 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8844 TEST_ASSERT((stats.dequeued_count == 1),
8845 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8846 TEST_ASSERT((stats.enqueue_err_count == 0),
8847 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8848 TEST_ASSERT((stats.dequeue_err_count == 0),
8849 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8851 /* invalid device but should ignore and not reset device stats*/
8852 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
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");
8859 /* check that a valid reset clears stats */
8860 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8861 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8863 "rte_cryptodev_stats_get failed");
8864 TEST_ASSERT((stats.enqueued_count == 0),
8865 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8866 TEST_ASSERT((stats.dequeued_count == 0),
8867 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8869 return TEST_SUCCESS;
8872 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8873 struct crypto_unittest_params *ut_params,
8874 enum rte_crypto_auth_operation op,
8875 const struct HMAC_MD5_vector *test_case)
8879 memcpy(key, test_case->key.data, test_case->key.len);
8881 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8882 ut_params->auth_xform.next = NULL;
8883 ut_params->auth_xform.auth.op = op;
8885 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8887 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8888 ut_params->auth_xform.auth.key.length = test_case->key.len;
8889 ut_params->auth_xform.auth.key.data = key;
8891 ut_params->sess = rte_cryptodev_sym_session_create(
8892 ts_params->session_mpool);
8894 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8895 ut_params->sess, &ut_params->auth_xform,
8896 ts_params->session_priv_mpool);
8898 if (ut_params->sess == NULL)
8901 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8903 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8904 rte_pktmbuf_tailroom(ut_params->ibuf));
8909 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8910 const struct HMAC_MD5_vector *test_case,
8911 uint8_t **plaintext)
8913 uint16_t plaintext_pad_len;
8915 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8917 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8920 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8922 memcpy(*plaintext, test_case->plaintext.data,
8923 test_case->plaintext.len);
8925 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8926 ut_params->ibuf, MD5_DIGEST_LEN);
8927 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8928 "no room to append digest");
8929 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8930 ut_params->ibuf, plaintext_pad_len);
8932 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8933 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8934 test_case->auth_tag.len);
8937 sym_op->auth.data.offset = 0;
8938 sym_op->auth.data.length = test_case->plaintext.len;
8940 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8941 ut_params->op->sym->m_src = ut_params->ibuf;
8947 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8949 uint16_t plaintext_pad_len;
8950 uint8_t *plaintext, *auth_tag;
8952 struct crypto_testsuite_params *ts_params = &testsuite_params;
8953 struct crypto_unittest_params *ut_params = &unittest_params;
8955 /* Verify the capabilities */
8956 struct rte_cryptodev_sym_capability_idx cap_idx;
8957 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8958 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8959 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8963 if (MD5_HMAC_create_session(ts_params, ut_params,
8964 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8967 /* Generate Crypto op data structure */
8968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8970 TEST_ASSERT_NOT_NULL(ut_params->op,
8971 "Failed to allocate symmetric crypto operation struct");
8973 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8976 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8979 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8980 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
8983 TEST_ASSERT_NOT_NULL(
8984 process_crypto_request(ts_params->valid_devs[0],
8986 "failed to process sym crypto op");
8988 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8989 "crypto op processing failed");
8991 if (ut_params->op->sym->m_dst) {
8992 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8993 uint8_t *, plaintext_pad_len);
8995 auth_tag = plaintext + plaintext_pad_len;
8998 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9000 test_case->auth_tag.data,
9001 test_case->auth_tag.len,
9002 "HMAC_MD5 generated tag not as expected");
9004 return TEST_SUCCESS;
9008 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9012 struct crypto_testsuite_params *ts_params = &testsuite_params;
9013 struct crypto_unittest_params *ut_params = &unittest_params;
9015 /* Verify the capabilities */
9016 struct rte_cryptodev_sym_capability_idx cap_idx;
9017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9018 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9023 if (MD5_HMAC_create_session(ts_params, ut_params,
9024 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9028 /* Generate Crypto op data structure */
9029 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9030 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9031 TEST_ASSERT_NOT_NULL(ut_params->op,
9032 "Failed to allocate symmetric crypto operation struct");
9034 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9037 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9038 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9041 TEST_ASSERT_NOT_NULL(
9042 process_crypto_request(ts_params->valid_devs[0],
9044 "failed to process sym crypto op");
9046 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9047 "HMAC_MD5 crypto op processing failed");
9049 return TEST_SUCCESS;
9053 test_MD5_HMAC_generate_case_1(void)
9055 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9059 test_MD5_HMAC_verify_case_1(void)
9061 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9065 test_MD5_HMAC_generate_case_2(void)
9067 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9071 test_MD5_HMAC_verify_case_2(void)
9073 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9077 test_multi_session(void)
9079 struct crypto_testsuite_params *ts_params = &testsuite_params;
9080 struct crypto_unittest_params *ut_params = &unittest_params;
9082 struct rte_cryptodev_info dev_info;
9083 struct rte_cryptodev_sym_session **sessions;
9087 /* Verify the capabilities */
9088 struct rte_cryptodev_sym_capability_idx cap_idx;
9089 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9090 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9091 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9094 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9095 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9096 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9100 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9101 aes_cbc_key, hmac_sha512_key);
9104 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9106 sessions = rte_malloc(NULL,
9107 (sizeof(struct rte_cryptodev_sym_session *) *
9108 MAX_NB_SESSIONS) + 1, 0);
9110 /* Create multiple crypto sessions*/
9111 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9113 sessions[i] = rte_cryptodev_sym_session_create(
9114 ts_params->session_mpool);
9116 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9117 sessions[i], &ut_params->auth_xform,
9118 ts_params->session_priv_mpool);
9119 TEST_ASSERT_NOT_NULL(sessions[i],
9120 "Session creation failed at session number %u",
9123 /* Attempt to send a request on each session */
9124 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9128 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9129 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9131 "Failed to perform decrypt on request number %u.", i);
9132 /* free crypto operation structure */
9134 rte_crypto_op_free(ut_params->op);
9137 * free mbuf - both obuf and ibuf are usually the same,
9138 * so check if they point at the same address is necessary,
9139 * to avoid freeing the mbuf twice.
9141 if (ut_params->obuf) {
9142 rte_pktmbuf_free(ut_params->obuf);
9143 if (ut_params->ibuf == ut_params->obuf)
9144 ut_params->ibuf = 0;
9145 ut_params->obuf = 0;
9147 if (ut_params->ibuf) {
9148 rte_pktmbuf_free(ut_params->ibuf);
9149 ut_params->ibuf = 0;
9153 /* Next session create should fail */
9154 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9155 sessions[i], &ut_params->auth_xform,
9156 ts_params->session_priv_mpool);
9157 TEST_ASSERT_NULL(sessions[i],
9158 "Session creation succeeded unexpectedly!");
9160 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9161 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9163 rte_cryptodev_sym_session_free(sessions[i]);
9168 return TEST_SUCCESS;
9171 struct multi_session_params {
9172 struct crypto_unittest_params ut_params;
9173 uint8_t *cipher_key;
9175 const uint8_t *cipher;
9176 const uint8_t *digest;
9180 #define MB_SESSION_NUMBER 3
9183 test_multi_session_random_usage(void)
9185 struct crypto_testsuite_params *ts_params = &testsuite_params;
9186 struct rte_cryptodev_info dev_info;
9187 struct rte_cryptodev_sym_session **sessions;
9189 struct multi_session_params ut_paramz[] = {
9192 .cipher_key = ms_aes_cbc_key0,
9193 .hmac_key = ms_hmac_key0,
9194 .cipher = ms_aes_cbc_cipher0,
9195 .digest = ms_hmac_digest0,
9196 .iv = ms_aes_cbc_iv0
9199 .cipher_key = ms_aes_cbc_key1,
9200 .hmac_key = ms_hmac_key1,
9201 .cipher = ms_aes_cbc_cipher1,
9202 .digest = ms_hmac_digest1,
9203 .iv = ms_aes_cbc_iv1
9206 .cipher_key = ms_aes_cbc_key2,
9207 .hmac_key = ms_hmac_key2,
9208 .cipher = ms_aes_cbc_cipher2,
9209 .digest = ms_hmac_digest2,
9210 .iv = ms_aes_cbc_iv2
9215 /* Verify the capabilities */
9216 struct rte_cryptodev_sym_capability_idx cap_idx;
9217 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9218 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9219 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9222 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9223 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9224 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9228 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9230 sessions = rte_malloc(NULL,
9231 (sizeof(struct rte_cryptodev_sym_session *)
9232 * MAX_NB_SESSIONS) + 1, 0);
9234 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9235 sessions[i] = rte_cryptodev_sym_session_create(
9236 ts_params->session_mpool);
9238 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9239 sizeof(struct crypto_unittest_params));
9241 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9242 &ut_paramz[i].ut_params,
9243 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9245 /* Create multiple crypto sessions*/
9246 rte_cryptodev_sym_session_init(
9247 ts_params->valid_devs[0],
9249 &ut_paramz[i].ut_params.auth_xform,
9250 ts_params->session_priv_mpool);
9252 TEST_ASSERT_NOT_NULL(sessions[i],
9253 "Session creation failed at session number %u",
9259 for (i = 0; i < 40000; i++) {
9261 j = rand() % MB_SESSION_NUMBER;
9263 TEST_ASSERT_SUCCESS(
9264 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9266 &ut_paramz[j].ut_params,
9267 ts_params, ut_paramz[j].cipher,
9268 ut_paramz[j].digest,
9270 "Failed to perform decrypt on request number %u.", i);
9272 if (ut_paramz[j].ut_params.op)
9273 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9276 * free mbuf - both obuf and ibuf are usually the same,
9277 * so check if they point at the same address is necessary,
9278 * to avoid freeing the mbuf twice.
9280 if (ut_paramz[j].ut_params.obuf) {
9281 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9282 if (ut_paramz[j].ut_params.ibuf
9283 == ut_paramz[j].ut_params.obuf)
9284 ut_paramz[j].ut_params.ibuf = 0;
9285 ut_paramz[j].ut_params.obuf = 0;
9287 if (ut_paramz[j].ut_params.ibuf) {
9288 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9289 ut_paramz[j].ut_params.ibuf = 0;
9293 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9294 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9296 rte_cryptodev_sym_session_free(sessions[i]);
9301 return TEST_SUCCESS;
9305 test_null_cipher_only_operation(void)
9307 struct crypto_testsuite_params *ts_params = &testsuite_params;
9308 struct crypto_unittest_params *ut_params = &unittest_params;
9310 /* Verify the capabilities */
9311 struct rte_cryptodev_sym_capability_idx cap_idx;
9312 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9313 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9314 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9318 /* Generate test mbuf data and space for digest */
9319 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9320 catch_22_quote, QUOTE_512_BYTES, 0);
9322 /* Setup Cipher Parameters */
9323 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9324 ut_params->cipher_xform.next = NULL;
9326 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9327 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9329 ut_params->sess = rte_cryptodev_sym_session_create(
9330 ts_params->session_mpool);
9332 /* Create Crypto session*/
9333 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9335 &ut_params->cipher_xform,
9336 ts_params->session_priv_mpool);
9337 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9339 /* Generate Crypto op data structure */
9340 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9341 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9342 TEST_ASSERT_NOT_NULL(ut_params->op,
9343 "Failed to allocate symmetric crypto operation struct");
9345 /* Set crypto operation data parameters */
9346 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9348 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9350 /* set crypto operation source mbuf */
9351 sym_op->m_src = ut_params->ibuf;
9353 sym_op->cipher.data.offset = 0;
9354 sym_op->cipher.data.length = QUOTE_512_BYTES;
9356 /* Process crypto operation */
9357 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9359 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9361 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9362 "crypto operation processing failed");
9365 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9366 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9369 "Ciphertext data not as expected");
9371 return TEST_SUCCESS;
9373 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9374 0xab, 0xab, 0xab, 0xab,
9375 0xab, 0xab, 0xab, 0xab,
9376 0xab, 0xab, 0xab, 0xab};
9378 test_null_auth_only_operation(void)
9380 struct crypto_testsuite_params *ts_params = &testsuite_params;
9381 struct crypto_unittest_params *ut_params = &unittest_params;
9384 /* Verify the capabilities */
9385 struct rte_cryptodev_sym_capability_idx cap_idx;
9386 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9387 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9388 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9392 /* Generate test mbuf data and space for digest */
9393 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9394 catch_22_quote, QUOTE_512_BYTES, 0);
9396 /* create a pointer for digest, but don't expect anything to be written
9397 * here in a NULL auth algo so no mbuf append done.
9399 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9401 /* prefill the memory pointed to by digest */
9402 memcpy(digest, orig_data, sizeof(orig_data));
9404 /* Setup HMAC Parameters */
9405 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9406 ut_params->auth_xform.next = NULL;
9408 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9409 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9411 ut_params->sess = rte_cryptodev_sym_session_create(
9412 ts_params->session_mpool);
9414 /* Create Crypto session*/
9415 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9416 ut_params->sess, &ut_params->auth_xform,
9417 ts_params->session_priv_mpool);
9418 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9420 /* Generate Crypto op data structure */
9421 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9422 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9423 TEST_ASSERT_NOT_NULL(ut_params->op,
9424 "Failed to allocate symmetric crypto operation struct");
9426 /* Set crypto operation data parameters */
9427 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9429 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9431 sym_op->m_src = ut_params->ibuf;
9433 sym_op->auth.data.offset = 0;
9434 sym_op->auth.data.length = QUOTE_512_BYTES;
9435 sym_op->auth.digest.data = digest;
9436 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9439 /* Process crypto operation */
9440 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9442 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9444 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9445 "crypto operation processing failed");
9446 /* Make sure memory pointed to by digest hasn't been overwritten */
9447 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9451 "Memory at digest ptr overwritten unexpectedly");
9453 return TEST_SUCCESS;
9458 test_null_cipher_auth_operation(void)
9460 struct crypto_testsuite_params *ts_params = &testsuite_params;
9461 struct crypto_unittest_params *ut_params = &unittest_params;
9464 /* Verify the capabilities */
9465 struct rte_cryptodev_sym_capability_idx cap_idx;
9466 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9467 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9468 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9472 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9477 /* Generate test mbuf data and space for digest */
9478 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9479 catch_22_quote, QUOTE_512_BYTES, 0);
9481 /* create a pointer for digest, but don't expect anything to be written
9482 * here in a NULL auth algo so no mbuf append done.
9484 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9486 /* prefill the memory pointed to by digest */
9487 memcpy(digest, orig_data, sizeof(orig_data));
9489 /* Setup Cipher Parameters */
9490 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9491 ut_params->cipher_xform.next = &ut_params->auth_xform;
9493 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9494 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9496 /* Setup HMAC Parameters */
9497 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9498 ut_params->auth_xform.next = NULL;
9500 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9501 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9503 ut_params->sess = rte_cryptodev_sym_session_create(
9504 ts_params->session_mpool);
9506 /* Create Crypto session*/
9507 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9508 ut_params->sess, &ut_params->cipher_xform,
9509 ts_params->session_priv_mpool);
9510 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9512 /* Generate Crypto op data structure */
9513 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9514 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9515 TEST_ASSERT_NOT_NULL(ut_params->op,
9516 "Failed to allocate symmetric crypto operation struct");
9518 /* Set crypto operation data parameters */
9519 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9521 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9523 sym_op->m_src = ut_params->ibuf;
9525 sym_op->cipher.data.offset = 0;
9526 sym_op->cipher.data.length = QUOTE_512_BYTES;
9528 sym_op->auth.data.offset = 0;
9529 sym_op->auth.data.length = QUOTE_512_BYTES;
9530 sym_op->auth.digest.data = digest;
9531 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9534 /* Process crypto operation */
9535 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9537 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9539 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9540 "crypto operation processing failed");
9543 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9544 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9547 "Ciphertext data not as expected");
9548 /* Make sure memory pointed to by digest hasn't been overwritten */
9549 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9553 "Memory at digest ptr overwritten unexpectedly");
9555 return TEST_SUCCESS;
9559 test_null_auth_cipher_operation(void)
9561 struct crypto_testsuite_params *ts_params = &testsuite_params;
9562 struct crypto_unittest_params *ut_params = &unittest_params;
9565 /* Verify the capabilities */
9566 struct rte_cryptodev_sym_capability_idx cap_idx;
9567 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9568 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9569 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9572 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9573 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9574 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9578 /* Generate test mbuf data */
9579 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9580 catch_22_quote, QUOTE_512_BYTES, 0);
9582 /* create a pointer for digest, but don't expect anything to be written
9583 * here in a NULL auth algo so no mbuf append done.
9585 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9587 /* prefill the memory pointed to by digest */
9588 memcpy(digest, orig_data, sizeof(orig_data));
9590 /* Setup Cipher Parameters */
9591 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9592 ut_params->cipher_xform.next = NULL;
9594 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9595 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9597 /* Setup HMAC Parameters */
9598 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9599 ut_params->auth_xform.next = &ut_params->cipher_xform;
9601 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9602 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9604 ut_params->sess = rte_cryptodev_sym_session_create(
9605 ts_params->session_mpool);
9607 /* Create Crypto session*/
9608 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9609 ut_params->sess, &ut_params->cipher_xform,
9610 ts_params->session_priv_mpool);
9611 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9613 /* Generate Crypto op data structure */
9614 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9615 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9616 TEST_ASSERT_NOT_NULL(ut_params->op,
9617 "Failed to allocate symmetric crypto operation struct");
9619 /* Set crypto operation data parameters */
9620 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9622 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9624 sym_op->m_src = ut_params->ibuf;
9626 sym_op->cipher.data.offset = 0;
9627 sym_op->cipher.data.length = QUOTE_512_BYTES;
9629 sym_op->auth.data.offset = 0;
9630 sym_op->auth.data.length = QUOTE_512_BYTES;
9631 sym_op->auth.digest.data = digest;
9632 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9635 /* Process crypto operation */
9636 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9638 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9640 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9641 "crypto operation processing failed");
9644 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9645 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9648 "Ciphertext data not as expected");
9649 /* Make sure memory pointed to by digest hasn't been overwritten */
9650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9654 "Memory at digest ptr overwritten unexpectedly");
9656 return TEST_SUCCESS;
9661 test_null_invalid_operation(void)
9663 struct crypto_testsuite_params *ts_params = &testsuite_params;
9664 struct crypto_unittest_params *ut_params = &unittest_params;
9667 /* This test is for NULL PMD only */
9668 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9669 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9672 /* Setup Cipher Parameters */
9673 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9674 ut_params->cipher_xform.next = NULL;
9676 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9677 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9679 ut_params->sess = rte_cryptodev_sym_session_create(
9680 ts_params->session_mpool);
9682 /* Create Crypto session*/
9683 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9684 ut_params->sess, &ut_params->cipher_xform,
9685 ts_params->session_priv_mpool);
9686 TEST_ASSERT(ret < 0,
9687 "Session creation succeeded unexpectedly");
9690 /* Setup HMAC Parameters */
9691 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9692 ut_params->auth_xform.next = NULL;
9694 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9695 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9697 ut_params->sess = rte_cryptodev_sym_session_create(
9698 ts_params->session_mpool);
9700 /* Create Crypto session*/
9701 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9702 ut_params->sess, &ut_params->auth_xform,
9703 ts_params->session_priv_mpool);
9704 TEST_ASSERT(ret < 0,
9705 "Session creation succeeded unexpectedly");
9707 return TEST_SUCCESS;
9711 #define NULL_BURST_LENGTH (32)
9714 test_null_burst_operation(void)
9716 struct crypto_testsuite_params *ts_params = &testsuite_params;
9717 struct crypto_unittest_params *ut_params = &unittest_params;
9719 unsigned i, burst_len = NULL_BURST_LENGTH;
9721 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9722 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9724 /* This test is for NULL PMD only */
9725 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9726 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9729 /* Setup Cipher Parameters */
9730 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9731 ut_params->cipher_xform.next = &ut_params->auth_xform;
9733 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9734 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9736 /* Setup HMAC Parameters */
9737 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9738 ut_params->auth_xform.next = NULL;
9740 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9741 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9743 ut_params->sess = rte_cryptodev_sym_session_create(
9744 ts_params->session_mpool);
9746 /* Create Crypto session*/
9747 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9748 ut_params->sess, &ut_params->cipher_xform,
9749 ts_params->session_priv_mpool);
9750 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9752 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9753 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9754 burst_len, "failed to generate burst of crypto ops");
9756 /* Generate an operation for each mbuf in burst */
9757 for (i = 0; i < burst_len; i++) {
9758 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9760 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9762 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9766 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9768 burst[i]->sym->m_src = m;
9771 /* Process crypto operation */
9772 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9773 0, burst, burst_len),
9775 "Error enqueuing burst");
9777 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9778 0, burst_dequeued, burst_len),
9780 "Error dequeuing burst");
9783 for (i = 0; i < burst_len; i++) {
9785 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9786 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9788 "data not as expected");
9790 rte_pktmbuf_free(burst[i]->sym->m_src);
9791 rte_crypto_op_free(burst[i]);
9794 return TEST_SUCCESS;
9798 generate_gmac_large_plaintext(uint8_t *data)
9802 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9803 memcpy(&data[i], &data[0], 32);
9807 create_gmac_operation(enum rte_crypto_auth_operation op,
9808 const struct gmac_test_data *tdata)
9810 struct crypto_testsuite_params *ts_params = &testsuite_params;
9811 struct crypto_unittest_params *ut_params = &unittest_params;
9812 struct rte_crypto_sym_op *sym_op;
9814 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9816 /* Generate Crypto op data structure */
9817 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9818 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9819 TEST_ASSERT_NOT_NULL(ut_params->op,
9820 "Failed to allocate symmetric crypto operation struct");
9822 sym_op = ut_params->op->sym;
9824 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9825 ut_params->ibuf, tdata->gmac_tag.len);
9826 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9827 "no room to append digest");
9829 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9830 ut_params->ibuf, plaintext_pad_len);
9832 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9833 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9834 tdata->gmac_tag.len);
9835 debug_hexdump(stdout, "digest:",
9836 sym_op->auth.digest.data,
9837 tdata->gmac_tag.len);
9840 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9841 uint8_t *, IV_OFFSET);
9843 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9845 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9847 sym_op->cipher.data.length = 0;
9848 sym_op->cipher.data.offset = 0;
9850 sym_op->auth.data.offset = 0;
9851 sym_op->auth.data.length = tdata->plaintext.len;
9856 static int create_gmac_session(uint8_t dev_id,
9857 const struct gmac_test_data *tdata,
9858 enum rte_crypto_auth_operation auth_op)
9860 uint8_t auth_key[tdata->key.len];
9862 struct crypto_testsuite_params *ts_params = &testsuite_params;
9863 struct crypto_unittest_params *ut_params = &unittest_params;
9865 memcpy(auth_key, tdata->key.data, tdata->key.len);
9867 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9868 ut_params->auth_xform.next = NULL;
9870 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9871 ut_params->auth_xform.auth.op = auth_op;
9872 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9873 ut_params->auth_xform.auth.key.length = tdata->key.len;
9874 ut_params->auth_xform.auth.key.data = auth_key;
9875 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9876 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9879 ut_params->sess = rte_cryptodev_sym_session_create(
9880 ts_params->session_mpool);
9882 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9883 &ut_params->auth_xform,
9884 ts_params->session_priv_mpool);
9886 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9892 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9894 struct crypto_testsuite_params *ts_params = &testsuite_params;
9895 struct crypto_unittest_params *ut_params = &unittest_params;
9899 uint8_t *auth_tag, *plaintext;
9900 uint16_t plaintext_pad_len;
9902 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9903 "No GMAC length in the source data");
9905 /* Verify the capabilities */
9906 struct rte_cryptodev_sym_capability_idx cap_idx;
9907 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9908 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9909 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9913 retval = create_gmac_session(ts_params->valid_devs[0],
9914 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9919 if (tdata->plaintext.len > MBUF_SIZE)
9920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9922 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9923 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9924 "Failed to allocate input buffer in mempool");
9926 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9927 rte_pktmbuf_tailroom(ut_params->ibuf));
9929 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9931 * Runtime generate the large plain text instead of use hard code
9932 * plain text vector. It is done to avoid create huge source file
9933 * with the test vector.
9935 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9936 generate_gmac_large_plaintext(tdata->plaintext.data);
9938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9940 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9942 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9943 debug_hexdump(stdout, "plaintext:", plaintext,
9944 tdata->plaintext.len);
9946 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9952 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9954 ut_params->op->sym->m_src = ut_params->ibuf;
9956 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9957 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9960 TEST_ASSERT_NOT_NULL(
9961 process_crypto_request(ts_params->valid_devs[0],
9962 ut_params->op), "failed to process sym crypto op");
9964 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9965 "crypto op processing failed");
9967 if (ut_params->op->sym->m_dst) {
9968 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9969 uint8_t *, plaintext_pad_len);
9971 auth_tag = plaintext + plaintext_pad_len;
9974 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9976 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9978 tdata->gmac_tag.data,
9979 tdata->gmac_tag.len,
9980 "GMAC Generated auth tag not as expected");
9986 test_AES_GMAC_authentication_test_case_1(void)
9988 return test_AES_GMAC_authentication(&gmac_test_case_1);
9992 test_AES_GMAC_authentication_test_case_2(void)
9994 return test_AES_GMAC_authentication(&gmac_test_case_2);
9998 test_AES_GMAC_authentication_test_case_3(void)
10000 return test_AES_GMAC_authentication(&gmac_test_case_3);
10004 test_AES_GMAC_authentication_test_case_4(void)
10006 return test_AES_GMAC_authentication(&gmac_test_case_4);
10010 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10012 struct crypto_testsuite_params *ts_params = &testsuite_params;
10013 struct crypto_unittest_params *ut_params = &unittest_params;
10015 uint32_t plaintext_pad_len;
10016 uint8_t *plaintext;
10018 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10019 "No GMAC length in the source data");
10021 /* Verify the capabilities */
10022 struct rte_cryptodev_sym_capability_idx cap_idx;
10023 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10024 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10025 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10029 retval = create_gmac_session(ts_params->valid_devs[0],
10030 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10035 if (tdata->plaintext.len > MBUF_SIZE)
10036 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10038 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10039 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10040 "Failed to allocate input buffer in mempool");
10042 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10043 rte_pktmbuf_tailroom(ut_params->ibuf));
10045 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10048 * Runtime generate the large plain text instead of use hard code
10049 * plain text vector. It is done to avoid create huge source file
10050 * with the test vector.
10052 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10053 generate_gmac_large_plaintext(tdata->plaintext.data);
10055 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10056 plaintext_pad_len);
10057 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10059 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10060 debug_hexdump(stdout, "plaintext:", plaintext,
10061 tdata->plaintext.len);
10063 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10069 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10071 ut_params->op->sym->m_src = ut_params->ibuf;
10073 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10074 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10077 TEST_ASSERT_NOT_NULL(
10078 process_crypto_request(ts_params->valid_devs[0],
10079 ut_params->op), "failed to process sym crypto op");
10081 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10082 "crypto op processing failed");
10089 test_AES_GMAC_authentication_verify_test_case_1(void)
10091 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10095 test_AES_GMAC_authentication_verify_test_case_2(void)
10097 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10101 test_AES_GMAC_authentication_verify_test_case_3(void)
10103 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10107 test_AES_GMAC_authentication_verify_test_case_4(void)
10109 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10112 struct test_crypto_vector {
10113 enum rte_crypto_cipher_algorithm crypto_algo;
10114 unsigned int cipher_offset;
10115 unsigned int cipher_len;
10128 const uint8_t *data;
10133 const uint8_t *data;
10137 enum rte_crypto_auth_algorithm auth_algo;
10138 unsigned int auth_offset;
10146 const uint8_t *data;
10156 static const struct test_crypto_vector
10157 hmac_sha1_test_crypto_vector = {
10158 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10160 .data = plaintext_hash,
10165 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10166 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10167 0xDE, 0xF4, 0xDE, 0xAD
10173 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10174 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10175 0x3F, 0x91, 0x64, 0x59
10181 static const struct test_crypto_vector
10182 aes128_gmac_test_vector = {
10183 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10185 .data = plaintext_hash,
10190 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10191 0x08, 0x09, 0x0A, 0x0B
10197 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10198 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10204 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10205 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10211 static const struct test_crypto_vector
10212 aes128cbc_hmac_sha1_test_vector = {
10213 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10214 .cipher_offset = 0,
10218 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10219 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10225 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10226 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10231 .data = plaintext_hash,
10235 .data = ciphertext512_aes128cbc,
10238 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10242 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10243 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10244 0xDE, 0xF4, 0xDE, 0xAD
10250 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10251 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10252 0x18, 0x8C, 0x1D, 0x32
10258 static const struct test_crypto_vector
10259 aes128cbc_hmac_sha1_aad_test_vector = {
10260 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10261 .cipher_offset = 12,
10265 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10266 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10272 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10273 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10278 .data = plaintext_hash,
10282 .data = ciphertext512_aes128cbc_aad,
10285 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10289 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10290 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10291 0xDE, 0xF4, 0xDE, 0xAD
10297 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10298 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10299 0x62, 0x8D, 0x62, 0x65
10306 data_corruption(uint8_t *data)
10312 tag_corruption(uint8_t *data, unsigned int tag_offset)
10314 data[tag_offset] += 1;
10318 create_auth_session(struct crypto_unittest_params *ut_params,
10320 const struct test_crypto_vector *reference,
10321 enum rte_crypto_auth_operation auth_op)
10323 struct crypto_testsuite_params *ts_params = &testsuite_params;
10324 uint8_t auth_key[reference->auth_key.len + 1];
10326 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10328 /* Setup Authentication Parameters */
10329 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10330 ut_params->auth_xform.auth.op = auth_op;
10331 ut_params->auth_xform.next = NULL;
10332 ut_params->auth_xform.auth.algo = reference->auth_algo;
10333 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10334 ut_params->auth_xform.auth.key.data = auth_key;
10335 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10337 /* Create Crypto session*/
10338 ut_params->sess = rte_cryptodev_sym_session_create(
10339 ts_params->session_mpool);
10341 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10342 &ut_params->auth_xform,
10343 ts_params->session_priv_mpool);
10345 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10351 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10353 const struct test_crypto_vector *reference,
10354 enum rte_crypto_auth_operation auth_op,
10355 enum rte_crypto_cipher_operation cipher_op)
10357 struct crypto_testsuite_params *ts_params = &testsuite_params;
10358 uint8_t cipher_key[reference->cipher_key.len + 1];
10359 uint8_t auth_key[reference->auth_key.len + 1];
10361 memcpy(cipher_key, reference->cipher_key.data,
10362 reference->cipher_key.len);
10363 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10365 /* Setup Authentication Parameters */
10366 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10367 ut_params->auth_xform.auth.op = auth_op;
10368 ut_params->auth_xform.auth.algo = reference->auth_algo;
10369 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10370 ut_params->auth_xform.auth.key.data = auth_key;
10371 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10373 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10374 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10375 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10377 ut_params->auth_xform.next = &ut_params->cipher_xform;
10379 /* Setup Cipher Parameters */
10380 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10381 ut_params->cipher_xform.next = NULL;
10382 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10383 ut_params->cipher_xform.cipher.op = cipher_op;
10384 ut_params->cipher_xform.cipher.key.data = cipher_key;
10385 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10386 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10387 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10390 /* Create Crypto session*/
10391 ut_params->sess = rte_cryptodev_sym_session_create(
10392 ts_params->session_mpool);
10394 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10395 &ut_params->auth_xform,
10396 ts_params->session_priv_mpool);
10398 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10404 create_auth_operation(struct crypto_testsuite_params *ts_params,
10405 struct crypto_unittest_params *ut_params,
10406 const struct test_crypto_vector *reference,
10407 unsigned int auth_generate)
10409 /* Generate Crypto op data structure */
10410 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10411 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10412 TEST_ASSERT_NOT_NULL(ut_params->op,
10413 "Failed to allocate pktmbuf offload");
10415 /* Set crypto operation data parameters */
10416 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10418 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10420 /* set crypto operation source mbuf */
10421 sym_op->m_src = ut_params->ibuf;
10424 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10425 ut_params->ibuf, reference->digest.len);
10427 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10428 "no room to append auth tag");
10430 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10431 ut_params->ibuf, reference->plaintext.len);
10434 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10436 memcpy(sym_op->auth.digest.data,
10437 reference->digest.data,
10438 reference->digest.len);
10440 debug_hexdump(stdout, "digest:",
10441 sym_op->auth.digest.data,
10442 reference->digest.len);
10444 sym_op->auth.data.length = reference->plaintext.len;
10445 sym_op->auth.data.offset = 0;
10451 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10452 struct crypto_unittest_params *ut_params,
10453 const struct test_crypto_vector *reference,
10454 unsigned int auth_generate)
10456 /* Generate Crypto op data structure */
10457 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10458 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10459 TEST_ASSERT_NOT_NULL(ut_params->op,
10460 "Failed to allocate pktmbuf offload");
10462 /* Set crypto operation data parameters */
10463 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10465 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10467 /* set crypto operation source mbuf */
10468 sym_op->m_src = ut_params->ibuf;
10471 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10472 ut_params->ibuf, reference->digest.len);
10474 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10475 "no room to append auth tag");
10477 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10478 ut_params->ibuf, reference->ciphertext.len);
10481 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10483 memcpy(sym_op->auth.digest.data,
10484 reference->digest.data,
10485 reference->digest.len);
10487 debug_hexdump(stdout, "digest:",
10488 sym_op->auth.digest.data,
10489 reference->digest.len);
10491 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10492 reference->iv.data, reference->iv.len);
10494 sym_op->cipher.data.length = 0;
10495 sym_op->cipher.data.offset = 0;
10497 sym_op->auth.data.length = reference->plaintext.len;
10498 sym_op->auth.data.offset = 0;
10504 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10505 struct crypto_unittest_params *ut_params,
10506 const struct test_crypto_vector *reference,
10507 unsigned int auth_generate)
10509 /* Generate Crypto op data structure */
10510 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10511 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10512 TEST_ASSERT_NOT_NULL(ut_params->op,
10513 "Failed to allocate pktmbuf offload");
10515 /* Set crypto operation data parameters */
10516 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10518 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10520 /* set crypto operation source mbuf */
10521 sym_op->m_src = ut_params->ibuf;
10524 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10525 ut_params->ibuf, reference->digest.len);
10527 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10528 "no room to append auth tag");
10530 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10531 ut_params->ibuf, reference->ciphertext.len);
10534 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10536 memcpy(sym_op->auth.digest.data,
10537 reference->digest.data,
10538 reference->digest.len);
10540 debug_hexdump(stdout, "digest:",
10541 sym_op->auth.digest.data,
10542 reference->digest.len);
10544 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10545 reference->iv.data, reference->iv.len);
10547 sym_op->cipher.data.length = reference->cipher_len;
10548 sym_op->cipher.data.offset = reference->cipher_offset;
10550 sym_op->auth.data.length = reference->plaintext.len;
10551 sym_op->auth.data.offset = reference->auth_offset;
10557 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10558 struct crypto_unittest_params *ut_params,
10559 const struct test_crypto_vector *reference)
10561 return create_auth_operation(ts_params, ut_params, reference, 0);
10565 create_auth_verify_GMAC_operation(
10566 struct crypto_testsuite_params *ts_params,
10567 struct crypto_unittest_params *ut_params,
10568 const struct test_crypto_vector *reference)
10570 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10574 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10575 struct crypto_unittest_params *ut_params,
10576 const struct test_crypto_vector *reference)
10578 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10582 test_authentication_verify_fail_when_data_corruption(
10583 struct crypto_testsuite_params *ts_params,
10584 struct crypto_unittest_params *ut_params,
10585 const struct test_crypto_vector *reference,
10586 unsigned int data_corrupted)
10590 uint8_t *plaintext;
10592 /* Verify the capabilities */
10593 struct rte_cryptodev_sym_capability_idx cap_idx;
10594 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10595 cap_idx.algo.auth = reference->auth_algo;
10596 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10600 /* Create session */
10601 retval = create_auth_session(ut_params,
10602 ts_params->valid_devs[0],
10604 RTE_CRYPTO_AUTH_OP_VERIFY);
10608 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10609 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10610 "Failed to allocate input buffer in mempool");
10612 /* clear mbuf payload */
10613 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10614 rte_pktmbuf_tailroom(ut_params->ibuf));
10616 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10617 reference->plaintext.len);
10618 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10619 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10621 debug_hexdump(stdout, "plaintext:", plaintext,
10622 reference->plaintext.len);
10624 /* Create operation */
10625 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10630 if (data_corrupted)
10631 data_corruption(plaintext);
10633 tag_corruption(plaintext, reference->plaintext.len);
10635 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10636 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10638 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10639 RTE_CRYPTO_OP_STATUS_SUCCESS,
10640 "authentication not failed");
10642 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10644 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10651 test_authentication_verify_GMAC_fail_when_corruption(
10652 struct crypto_testsuite_params *ts_params,
10653 struct crypto_unittest_params *ut_params,
10654 const struct test_crypto_vector *reference,
10655 unsigned int data_corrupted)
10658 uint8_t *plaintext;
10660 /* Verify the capabilities */
10661 struct rte_cryptodev_sym_capability_idx cap_idx;
10662 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10663 cap_idx.algo.auth = reference->auth_algo;
10664 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10668 /* Create session */
10669 retval = create_auth_cipher_session(ut_params,
10670 ts_params->valid_devs[0],
10672 RTE_CRYPTO_AUTH_OP_VERIFY,
10673 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10677 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10678 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10679 "Failed to allocate input buffer in mempool");
10681 /* clear mbuf payload */
10682 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10683 rte_pktmbuf_tailroom(ut_params->ibuf));
10685 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10686 reference->plaintext.len);
10687 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10688 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10690 debug_hexdump(stdout, "plaintext:", plaintext,
10691 reference->plaintext.len);
10693 /* Create operation */
10694 retval = create_auth_verify_GMAC_operation(ts_params,
10701 if (data_corrupted)
10702 data_corruption(plaintext);
10704 tag_corruption(plaintext, reference->aad.len);
10706 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10707 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10709 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10710 RTE_CRYPTO_OP_STATUS_SUCCESS,
10711 "authentication not failed");
10713 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10715 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10722 test_authenticated_decryption_fail_when_corruption(
10723 struct crypto_testsuite_params *ts_params,
10724 struct crypto_unittest_params *ut_params,
10725 const struct test_crypto_vector *reference,
10726 unsigned int data_corrupted)
10730 uint8_t *ciphertext;
10732 /* Verify the capabilities */
10733 struct rte_cryptodev_sym_capability_idx cap_idx;
10734 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10735 cap_idx.algo.auth = reference->auth_algo;
10736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10739 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10740 cap_idx.algo.cipher = reference->crypto_algo;
10741 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10745 /* Create session */
10746 retval = create_auth_cipher_session(ut_params,
10747 ts_params->valid_devs[0],
10749 RTE_CRYPTO_AUTH_OP_VERIFY,
10750 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10754 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10755 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10756 "Failed to allocate input buffer in mempool");
10758 /* clear mbuf payload */
10759 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10760 rte_pktmbuf_tailroom(ut_params->ibuf));
10762 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10763 reference->ciphertext.len);
10764 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10765 memcpy(ciphertext, reference->ciphertext.data,
10766 reference->ciphertext.len);
10768 /* Create operation */
10769 retval = create_cipher_auth_verify_operation(ts_params,
10776 if (data_corrupted)
10777 data_corruption(ciphertext);
10779 tag_corruption(ciphertext, reference->ciphertext.len);
10781 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10782 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10784 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10785 RTE_CRYPTO_OP_STATUS_SUCCESS,
10786 "authentication not failed");
10788 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10790 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10797 test_authenticated_encryt_with_esn(
10798 struct crypto_testsuite_params *ts_params,
10799 struct crypto_unittest_params *ut_params,
10800 const struct test_crypto_vector *reference)
10804 uint8_t *authciphertext, *plaintext, *auth_tag;
10805 uint16_t plaintext_pad_len;
10806 uint8_t cipher_key[reference->cipher_key.len + 1];
10807 uint8_t auth_key[reference->auth_key.len + 1];
10809 /* Verify the capabilities */
10810 struct rte_cryptodev_sym_capability_idx cap_idx;
10811 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10812 cap_idx.algo.auth = reference->auth_algo;
10813 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10816 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10817 cap_idx.algo.cipher = reference->crypto_algo;
10818 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10822 /* Create session */
10823 memcpy(cipher_key, reference->cipher_key.data,
10824 reference->cipher_key.len);
10825 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10827 /* Setup Cipher Parameters */
10828 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10829 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10830 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10831 ut_params->cipher_xform.cipher.key.data = cipher_key;
10832 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10833 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10834 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10836 ut_params->cipher_xform.next = &ut_params->auth_xform;
10838 /* Setup Authentication Parameters */
10839 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10840 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10841 ut_params->auth_xform.auth.algo = reference->auth_algo;
10842 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10843 ut_params->auth_xform.auth.key.data = auth_key;
10844 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10845 ut_params->auth_xform.next = NULL;
10847 /* Create Crypto session*/
10848 ut_params->sess = rte_cryptodev_sym_session_create(
10849 ts_params->session_mpool);
10851 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10853 &ut_params->cipher_xform,
10854 ts_params->session_priv_mpool);
10856 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10859 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10860 "Failed to allocate input buffer in mempool");
10862 /* clear mbuf payload */
10863 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10864 rte_pktmbuf_tailroom(ut_params->ibuf));
10866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10867 reference->plaintext.len);
10868 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10869 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10871 /* Create operation */
10872 retval = create_cipher_auth_operation(ts_params,
10879 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10880 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10883 ut_params->op = process_crypto_request(
10884 ts_params->valid_devs[0], ut_params->op);
10886 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10888 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10889 "crypto op processing failed");
10891 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10893 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10894 ut_params->op->sym->auth.data.offset);
10895 auth_tag = authciphertext + plaintext_pad_len;
10896 debug_hexdump(stdout, "ciphertext:", authciphertext,
10897 reference->ciphertext.len);
10898 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10900 /* Validate obuf */
10901 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10903 reference->ciphertext.data,
10904 reference->ciphertext.len,
10905 "Ciphertext data not as expected");
10907 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10909 reference->digest.data,
10910 reference->digest.len,
10911 "Generated digest not as expected");
10913 return TEST_SUCCESS;
10918 test_authenticated_decrypt_with_esn(
10919 struct crypto_testsuite_params *ts_params,
10920 struct crypto_unittest_params *ut_params,
10921 const struct test_crypto_vector *reference)
10925 uint8_t *ciphertext;
10926 uint8_t cipher_key[reference->cipher_key.len + 1];
10927 uint8_t auth_key[reference->auth_key.len + 1];
10929 /* Verify the capabilities */
10930 struct rte_cryptodev_sym_capability_idx cap_idx;
10931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10932 cap_idx.algo.auth = reference->auth_algo;
10933 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10936 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10937 cap_idx.algo.cipher = reference->crypto_algo;
10938 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10942 /* Create session */
10943 memcpy(cipher_key, reference->cipher_key.data,
10944 reference->cipher_key.len);
10945 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10947 /* Setup Authentication Parameters */
10948 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10949 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10950 ut_params->auth_xform.auth.algo = reference->auth_algo;
10951 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10952 ut_params->auth_xform.auth.key.data = auth_key;
10953 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10954 ut_params->auth_xform.next = &ut_params->cipher_xform;
10956 /* Setup Cipher Parameters */
10957 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10958 ut_params->cipher_xform.next = NULL;
10959 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10960 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10961 ut_params->cipher_xform.cipher.key.data = cipher_key;
10962 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10963 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10964 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10966 /* Create Crypto session*/
10967 ut_params->sess = rte_cryptodev_sym_session_create(
10968 ts_params->session_mpool);
10970 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10972 &ut_params->auth_xform,
10973 ts_params->session_priv_mpool);
10975 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10977 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10978 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10979 "Failed to allocate input buffer in mempool");
10981 /* clear mbuf payload */
10982 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10983 rte_pktmbuf_tailroom(ut_params->ibuf));
10985 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10986 reference->ciphertext.len);
10987 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10988 memcpy(ciphertext, reference->ciphertext.data,
10989 reference->ciphertext.len);
10991 /* Create operation */
10992 retval = create_cipher_auth_verify_operation(ts_params,
10999 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11000 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11003 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11006 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11007 TEST_ASSERT_EQUAL(ut_params->op->status,
11008 RTE_CRYPTO_OP_STATUS_SUCCESS,
11009 "crypto op processing passed");
11011 ut_params->obuf = ut_params->op->sym->m_src;
11012 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11018 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11019 const struct aead_test_data *tdata,
11020 void *digest_mem, uint64_t digest_phys)
11022 struct crypto_testsuite_params *ts_params = &testsuite_params;
11023 struct crypto_unittest_params *ut_params = &unittest_params;
11025 const unsigned int auth_tag_len = tdata->auth_tag.len;
11026 const unsigned int iv_len = tdata->iv.len;
11027 unsigned int aad_len = tdata->aad.len;
11028 unsigned int aad_len_pad = 0;
11030 /* Generate Crypto op data structure */
11031 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11032 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11033 TEST_ASSERT_NOT_NULL(ut_params->op,
11034 "Failed to allocate symmetric crypto operation struct");
11036 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11038 sym_op->aead.digest.data = digest_mem;
11040 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11041 "no room to append digest");
11043 sym_op->aead.digest.phys_addr = digest_phys;
11045 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11046 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11048 debug_hexdump(stdout, "digest:",
11049 sym_op->aead.digest.data,
11053 /* Append aad data */
11054 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11055 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11056 uint8_t *, IV_OFFSET);
11058 /* Copy IV 1 byte after the IV pointer, according to the API */
11059 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11061 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11063 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11064 ut_params->ibuf, aad_len);
11065 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11066 "no room to prepend aad");
11067 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11070 memset(sym_op->aead.aad.data, 0, aad_len);
11071 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11072 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11074 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11075 debug_hexdump(stdout, "aad:",
11076 sym_op->aead.aad.data, aad_len);
11078 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11079 uint8_t *, IV_OFFSET);
11081 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11083 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11085 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11086 ut_params->ibuf, aad_len_pad);
11087 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11088 "no room to prepend aad");
11089 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11092 memset(sym_op->aead.aad.data, 0, aad_len);
11093 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11095 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11096 debug_hexdump(stdout, "aad:",
11097 sym_op->aead.aad.data, aad_len);
11100 sym_op->aead.data.length = tdata->plaintext.len;
11101 sym_op->aead.data.offset = aad_len_pad;
11106 #define SGL_MAX_NO 16
11109 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11110 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11112 struct crypto_testsuite_params *ts_params = &testsuite_params;
11113 struct crypto_unittest_params *ut_params = &unittest_params;
11114 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11117 int to_trn_tbl[SGL_MAX_NO];
11119 unsigned int trn_data = 0;
11120 uint8_t *plaintext, *ciphertext, *auth_tag;
11121 struct rte_cryptodev_info dev_info;
11123 /* Verify the capabilities */
11124 struct rte_cryptodev_sym_capability_idx cap_idx;
11125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11126 cap_idx.algo.aead = tdata->algo;
11127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11131 /* OOP not supported with CPU crypto */
11132 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11135 /* Detailed check for the particular SGL support flag */
11136 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11138 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11139 if (sgl_in && (!(dev_info.feature_flags &
11140 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11143 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11144 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11145 tdata->plaintext.len;
11146 if (sgl_in && !sgl_out) {
11147 if (!(dev_info.feature_flags &
11148 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11150 } else if (!sgl_in && sgl_out) {
11151 if (!(dev_info.feature_flags &
11152 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11154 } else if (sgl_in && sgl_out) {
11155 if (!(dev_info.feature_flags &
11156 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11161 if (fragsz > tdata->plaintext.len)
11162 fragsz = tdata->plaintext.len;
11164 uint16_t plaintext_len = fragsz;
11165 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11167 if (fragsz_oop > tdata->plaintext.len)
11168 frag_size_oop = tdata->plaintext.len;
11171 void *digest_mem = NULL;
11173 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11175 if (tdata->plaintext.len % fragsz != 0) {
11176 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11179 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11184 * For out-op-place we need to alloc another mbuf
11187 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11188 rte_pktmbuf_append(ut_params->obuf,
11189 frag_size_oop + prepend_len);
11190 buf_oop = ut_params->obuf;
11193 /* Create AEAD session */
11194 retval = create_aead_session(ts_params->valid_devs[0],
11196 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11197 tdata->key.data, tdata->key.len,
11198 tdata->aad.len, tdata->auth_tag.len,
11203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11205 /* clear mbuf payload */
11206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11207 rte_pktmbuf_tailroom(ut_params->ibuf));
11209 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11212 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11214 trn_data += plaintext_len;
11216 buf = ut_params->ibuf;
11219 * Loop until no more fragments
11222 while (trn_data < tdata->plaintext.len) {
11224 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11225 (tdata->plaintext.len - trn_data) : fragsz;
11227 to_trn_tbl[ecx++] = to_trn;
11229 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11232 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11233 rte_pktmbuf_tailroom(buf));
11236 if (oop && !fragsz_oop) {
11237 buf_last_oop = buf_oop->next =
11238 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11239 buf_oop = buf_oop->next;
11240 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11241 0, rte_pktmbuf_tailroom(buf_oop));
11242 rte_pktmbuf_append(buf_oop, to_trn);
11245 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11248 memcpy(plaintext, tdata->plaintext.data + trn_data,
11250 trn_data += to_trn;
11251 if (trn_data == tdata->plaintext.len) {
11254 digest_mem = rte_pktmbuf_append(buf_oop,
11255 tdata->auth_tag.len);
11257 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11258 tdata->auth_tag.len);
11262 uint64_t digest_phys = 0;
11264 ut_params->ibuf->nb_segs = segs;
11267 if (fragsz_oop && oop) {
11271 if (frag_size_oop == tdata->plaintext.len) {
11272 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11273 tdata->auth_tag.len);
11275 digest_phys = rte_pktmbuf_iova_offset(
11277 tdata->plaintext.len + prepend_len);
11280 trn_data = frag_size_oop;
11281 while (trn_data < tdata->plaintext.len) {
11284 (tdata->plaintext.len - trn_data <
11286 (tdata->plaintext.len - trn_data) :
11289 to_trn_tbl[ecx++] = to_trn;
11291 buf_last_oop = buf_oop->next =
11292 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11293 buf_oop = buf_oop->next;
11294 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11295 0, rte_pktmbuf_tailroom(buf_oop));
11296 rte_pktmbuf_append(buf_oop, to_trn);
11298 trn_data += to_trn;
11300 if (trn_data == tdata->plaintext.len) {
11301 digest_mem = rte_pktmbuf_append(buf_oop,
11302 tdata->auth_tag.len);
11306 ut_params->obuf->nb_segs = segs;
11310 * Place digest at the end of the last buffer
11313 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11314 if (oop && buf_last_oop)
11315 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11317 if (!digest_mem && !oop) {
11318 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11319 + tdata->auth_tag.len);
11320 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11321 tdata->plaintext.len);
11324 /* Create AEAD operation */
11325 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11326 tdata, digest_mem, digest_phys);
11331 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11333 ut_params->op->sym->m_src = ut_params->ibuf;
11335 ut_params->op->sym->m_dst = ut_params->obuf;
11337 /* Process crypto operation */
11338 if (oop == IN_PLACE &&
11339 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11340 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11342 TEST_ASSERT_NOT_NULL(
11343 process_crypto_request(ts_params->valid_devs[0],
11344 ut_params->op), "failed to process sym crypto op");
11346 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11347 "crypto op processing failed");
11350 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11351 uint8_t *, prepend_len);
11353 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11354 uint8_t *, prepend_len);
11358 fragsz = fragsz_oop;
11360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11362 tdata->ciphertext.data,
11364 "Ciphertext data not as expected");
11366 buf = ut_params->op->sym->m_src->next;
11368 buf = ut_params->op->sym->m_dst->next;
11370 unsigned int off = fragsz;
11374 ciphertext = rte_pktmbuf_mtod(buf,
11377 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11379 tdata->ciphertext.data + off,
11381 "Ciphertext data not as expected");
11383 off += to_trn_tbl[ecx++];
11387 auth_tag = digest_mem;
11388 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11390 tdata->auth_tag.data,
11391 tdata->auth_tag.len,
11392 "Generated auth tag not as expected");
11398 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11400 return test_authenticated_encryption_SGL(
11401 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11405 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11407 return test_authenticated_encryption_SGL(
11408 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11412 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11414 return test_authenticated_encryption_SGL(
11415 &gcm_test_case_8, OUT_OF_PLACE, 400,
11416 gcm_test_case_8.plaintext.len);
11420 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11422 /* This test is not for OPENSSL PMD */
11423 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11424 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11427 return test_authenticated_encryption_SGL(
11428 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11432 test_authentication_verify_fail_when_data_corrupted(
11433 struct crypto_testsuite_params *ts_params,
11434 struct crypto_unittest_params *ut_params,
11435 const struct test_crypto_vector *reference)
11437 return test_authentication_verify_fail_when_data_corruption(
11438 ts_params, ut_params, reference, 1);
11442 test_authentication_verify_fail_when_tag_corrupted(
11443 struct crypto_testsuite_params *ts_params,
11444 struct crypto_unittest_params *ut_params,
11445 const struct test_crypto_vector *reference)
11447 return test_authentication_verify_fail_when_data_corruption(
11448 ts_params, ut_params, reference, 0);
11452 test_authentication_verify_GMAC_fail_when_data_corrupted(
11453 struct crypto_testsuite_params *ts_params,
11454 struct crypto_unittest_params *ut_params,
11455 const struct test_crypto_vector *reference)
11457 return test_authentication_verify_GMAC_fail_when_corruption(
11458 ts_params, ut_params, reference, 1);
11462 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11463 struct crypto_testsuite_params *ts_params,
11464 struct crypto_unittest_params *ut_params,
11465 const struct test_crypto_vector *reference)
11467 return test_authentication_verify_GMAC_fail_when_corruption(
11468 ts_params, ut_params, reference, 0);
11472 test_authenticated_decryption_fail_when_data_corrupted(
11473 struct crypto_testsuite_params *ts_params,
11474 struct crypto_unittest_params *ut_params,
11475 const struct test_crypto_vector *reference)
11477 return test_authenticated_decryption_fail_when_corruption(
11478 ts_params, ut_params, reference, 1);
11482 test_authenticated_decryption_fail_when_tag_corrupted(
11483 struct crypto_testsuite_params *ts_params,
11484 struct crypto_unittest_params *ut_params,
11485 const struct test_crypto_vector *reference)
11487 return test_authenticated_decryption_fail_when_corruption(
11488 ts_params, ut_params, reference, 0);
11492 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11494 return test_authentication_verify_fail_when_data_corrupted(
11495 &testsuite_params, &unittest_params,
11496 &hmac_sha1_test_crypto_vector);
11500 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11502 return test_authentication_verify_fail_when_tag_corrupted(
11503 &testsuite_params, &unittest_params,
11504 &hmac_sha1_test_crypto_vector);
11508 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11510 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11511 &testsuite_params, &unittest_params,
11512 &aes128_gmac_test_vector);
11516 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11518 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11519 &testsuite_params, &unittest_params,
11520 &aes128_gmac_test_vector);
11524 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11526 return test_authenticated_decryption_fail_when_data_corrupted(
11529 &aes128cbc_hmac_sha1_test_vector);
11533 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11535 return test_authenticated_decryption_fail_when_tag_corrupted(
11538 &aes128cbc_hmac_sha1_test_vector);
11542 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11544 return test_authenticated_encryt_with_esn(
11547 &aes128cbc_hmac_sha1_aad_test_vector);
11551 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11553 return test_authenticated_decrypt_with_esn(
11556 &aes128cbc_hmac_sha1_aad_test_vector);
11559 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11561 /* global AESNI slave IDs for the scheduler test */
11562 uint8_t aesni_ids[2];
11565 test_scheduler_attach_slave_op(void)
11567 struct crypto_testsuite_params *ts_params = &testsuite_params;
11568 uint8_t sched_id = ts_params->valid_devs[0];
11569 uint32_t nb_devs, i, nb_devs_attached = 0;
11571 char vdev_name[32];
11573 /* create 2 AESNI_MB if necessary */
11574 nb_devs = rte_cryptodev_device_count_by_driver(
11575 rte_cryptodev_driver_id_get(
11576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11578 for (i = nb_devs; i < 2; i++) {
11579 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11580 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11582 ret = rte_vdev_init(vdev_name, NULL);
11584 TEST_ASSERT(ret == 0,
11585 "Failed to create instance %u of"
11587 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11591 /* attach 2 AESNI_MB cdevs */
11592 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11594 struct rte_cryptodev_info info;
11595 unsigned int session_size;
11597 rte_cryptodev_info_get(i, &info);
11598 if (info.driver_id != rte_cryptodev_driver_id_get(
11599 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11602 session_size = rte_cryptodev_sym_get_private_session_size(i);
11604 * Create the session mempool again, since now there are new devices
11605 * to use the mempool.
11607 if (ts_params->session_mpool) {
11608 rte_mempool_free(ts_params->session_mpool);
11609 ts_params->session_mpool = NULL;
11611 if (ts_params->session_priv_mpool) {
11612 rte_mempool_free(ts_params->session_priv_mpool);
11613 ts_params->session_priv_mpool = NULL;
11616 if (info.sym.max_nb_sessions != 0 &&
11617 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11618 RTE_LOG(ERR, USER1,
11619 "Device does not support "
11620 "at least %u sessions\n",
11622 return TEST_FAILED;
11625 * Create mempool with maximum number of sessions,
11626 * to include the session headers
11628 if (ts_params->session_mpool == NULL) {
11629 ts_params->session_mpool =
11630 rte_cryptodev_sym_session_pool_create(
11632 MAX_NB_SESSIONS, 0, 0, 0,
11634 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11635 "session mempool allocation failed");
11639 * Create mempool with maximum number of sessions,
11640 * to include device specific session private data
11642 if (ts_params->session_priv_mpool == NULL) {
11643 ts_params->session_priv_mpool = rte_mempool_create(
11644 "test_sess_mp_priv",
11647 0, 0, NULL, NULL, NULL,
11648 NULL, SOCKET_ID_ANY,
11651 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11652 "session mempool allocation failed");
11655 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11656 ts_params->qp_conf.mp_session_private =
11657 ts_params->session_priv_mpool;
11659 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11662 TEST_ASSERT(ret == 0,
11663 "Failed to attach device %u of pmd : %s", i,
11664 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11666 aesni_ids[nb_devs_attached] = (uint8_t)i;
11668 nb_devs_attached++;
11675 test_scheduler_detach_slave_op(void)
11677 struct crypto_testsuite_params *ts_params = &testsuite_params;
11678 uint8_t sched_id = ts_params->valid_devs[0];
11682 for (i = 0; i < 2; i++) {
11683 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11685 TEST_ASSERT(ret == 0,
11686 "Failed to detach device %u", aesni_ids[i]);
11693 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11695 struct crypto_testsuite_params *ts_params = &testsuite_params;
11696 uint8_t sched_id = ts_params->valid_devs[0];
11698 return rte_cryptodev_scheduler_mode_set(sched_id,
11703 test_scheduler_mode_roundrobin_op(void)
11705 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11706 0, "Failed to set roundrobin mode");
11712 test_scheduler_mode_multicore_op(void)
11714 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11715 0, "Failed to set multicore mode");
11721 test_scheduler_mode_failover_op(void)
11723 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11724 0, "Failed to set failover mode");
11730 test_scheduler_mode_pkt_size_distr_op(void)
11732 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11733 0, "Failed to set pktsize mode");
11738 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11739 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11740 .setup = testsuite_setup,
11741 .teardown = testsuite_teardown,
11742 .unit_test_cases = {
11744 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11745 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11746 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11747 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11748 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11749 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11752 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11753 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11754 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11755 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11756 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11757 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11760 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11761 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11762 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11763 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11764 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11765 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11768 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11769 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11770 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11771 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11772 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11773 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11775 TEST_CASES_END() /**< NULL terminate unit test array */
11779 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11781 static struct unit_test_suite cryptodev_testsuite = {
11782 .suite_name = "Crypto Unit Test Suite",
11783 .setup = testsuite_setup,
11784 .teardown = testsuite_teardown,
11785 .unit_test_cases = {
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_device_configure_invalid_dev_id),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_queue_pair_descriptor_setup),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_device_configure_invalid_queue_pair_ids),
11793 TEST_CASE_ST(ut_setup, ut_teardown,
11794 test_multi_session),
11795 TEST_CASE_ST(ut_setup, ut_teardown,
11796 test_multi_session_random_usage),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_null_invalid_operation),
11800 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11802 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11803 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11804 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11805 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11806 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11807 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11808 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11809 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11810 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11812 /** AES CCM Authenticated Encryption 128 bits key */
11813 TEST_CASE_ST(ut_setup, ut_teardown,
11814 test_AES_CCM_authenticated_encryption_test_case_128_1),
11815 TEST_CASE_ST(ut_setup, ut_teardown,
11816 test_AES_CCM_authenticated_encryption_test_case_128_2),
11817 TEST_CASE_ST(ut_setup, ut_teardown,
11818 test_AES_CCM_authenticated_encryption_test_case_128_3),
11820 /** AES CCM Authenticated Decryption 128 bits key*/
11821 TEST_CASE_ST(ut_setup, ut_teardown,
11822 test_AES_CCM_authenticated_decryption_test_case_128_1),
11823 TEST_CASE_ST(ut_setup, ut_teardown,
11824 test_AES_CCM_authenticated_decryption_test_case_128_2),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_CCM_authenticated_decryption_test_case_128_3),
11828 /** AES CCM Authenticated Encryption 192 bits key */
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_AES_CCM_authenticated_encryption_test_case_192_1),
11831 TEST_CASE_ST(ut_setup, ut_teardown,
11832 test_AES_CCM_authenticated_encryption_test_case_192_2),
11833 TEST_CASE_ST(ut_setup, ut_teardown,
11834 test_AES_CCM_authenticated_encryption_test_case_192_3),
11836 /** AES CCM Authenticated Decryption 192 bits key*/
11837 TEST_CASE_ST(ut_setup, ut_teardown,
11838 test_AES_CCM_authenticated_decryption_test_case_192_1),
11839 TEST_CASE_ST(ut_setup, ut_teardown,
11840 test_AES_CCM_authenticated_decryption_test_case_192_2),
11841 TEST_CASE_ST(ut_setup, ut_teardown,
11842 test_AES_CCM_authenticated_decryption_test_case_192_3),
11844 /** AES CCM Authenticated Encryption 256 bits key */
11845 TEST_CASE_ST(ut_setup, ut_teardown,
11846 test_AES_CCM_authenticated_encryption_test_case_256_1),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_CCM_authenticated_encryption_test_case_256_2),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_CCM_authenticated_encryption_test_case_256_3),
11852 /** AES CCM Authenticated Decryption 256 bits key*/
11853 TEST_CASE_ST(ut_setup, ut_teardown,
11854 test_AES_CCM_authenticated_decryption_test_case_256_1),
11855 TEST_CASE_ST(ut_setup, ut_teardown,
11856 test_AES_CCM_authenticated_decryption_test_case_256_2),
11857 TEST_CASE_ST(ut_setup, ut_teardown,
11858 test_AES_CCM_authenticated_decryption_test_case_256_3),
11860 /** AES GCM Authenticated Encryption */
11861 TEST_CASE_ST(ut_setup, ut_teardown,
11862 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11863 TEST_CASE_ST(ut_setup, ut_teardown,
11864 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11865 TEST_CASE_ST(ut_setup, ut_teardown,
11866 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11867 TEST_CASE_ST(ut_setup, ut_teardown,
11868 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11869 TEST_CASE_ST(ut_setup, ut_teardown,
11870 test_AES_GCM_authenticated_encryption_test_case_1),
11871 TEST_CASE_ST(ut_setup, ut_teardown,
11872 test_AES_GCM_authenticated_encryption_test_case_2),
11873 TEST_CASE_ST(ut_setup, ut_teardown,
11874 test_AES_GCM_authenticated_encryption_test_case_3),
11875 TEST_CASE_ST(ut_setup, ut_teardown,
11876 test_AES_GCM_authenticated_encryption_test_case_4),
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_AES_GCM_authenticated_encryption_test_case_5),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_AES_GCM_authenticated_encryption_test_case_6),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_AES_GCM_authenticated_encryption_test_case_7),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_AES_GCM_authenticated_encryption_test_case_8),
11885 TEST_CASE_ST(ut_setup, ut_teardown,
11886 test_AES_GCM_J0_authenticated_encryption_test_case_1),
11888 /** AES GCM Authenticated Decryption */
11889 TEST_CASE_ST(ut_setup, ut_teardown,
11890 test_AES_GCM_authenticated_decryption_test_case_1),
11891 TEST_CASE_ST(ut_setup, ut_teardown,
11892 test_AES_GCM_authenticated_decryption_test_case_2),
11893 TEST_CASE_ST(ut_setup, ut_teardown,
11894 test_AES_GCM_authenticated_decryption_test_case_3),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_AES_GCM_authenticated_decryption_test_case_4),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_AES_GCM_authenticated_decryption_test_case_5),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_AES_GCM_authenticated_decryption_test_case_6),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_AES_GCM_authenticated_decryption_test_case_7),
11903 TEST_CASE_ST(ut_setup, ut_teardown,
11904 test_AES_GCM_authenticated_decryption_test_case_8),
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_AES_GCM_J0_authenticated_decryption_test_case_1),
11908 /** AES GCM Authenticated Encryption 192 bits key */
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_AES_GCM_auth_encryption_test_case_192_1),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_AES_GCM_auth_encryption_test_case_192_2),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_AES_GCM_auth_encryption_test_case_192_3),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_AES_GCM_auth_encryption_test_case_192_4),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_AES_GCM_auth_encryption_test_case_192_5),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_AES_GCM_auth_encryption_test_case_192_6),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_AES_GCM_auth_encryption_test_case_192_7),
11924 /** AES GCM Authenticated Decryption 192 bits key */
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_AES_GCM_auth_decryption_test_case_192_1),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_AES_GCM_auth_decryption_test_case_192_2),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_AES_GCM_auth_decryption_test_case_192_3),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_AES_GCM_auth_decryption_test_case_192_4),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_AES_GCM_auth_decryption_test_case_192_5),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_AES_GCM_auth_decryption_test_case_192_6),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_AES_GCM_auth_decryption_test_case_192_7),
11940 /** AES GCM Authenticated Encryption 256 bits key */
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_AES_GCM_auth_encryption_test_case_256_1),
11943 TEST_CASE_ST(ut_setup, ut_teardown,
11944 test_AES_GCM_auth_encryption_test_case_256_2),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_AES_GCM_auth_encryption_test_case_256_3),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_AES_GCM_auth_encryption_test_case_256_4),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_AES_GCM_auth_encryption_test_case_256_5),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_AES_GCM_auth_encryption_test_case_256_6),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_AES_GCM_auth_encryption_test_case_256_7),
11956 /** AES GCM Authenticated Decryption 256 bits key */
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_AES_GCM_auth_decryption_test_case_256_1),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_AES_GCM_auth_decryption_test_case_256_2),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_AES_GCM_auth_decryption_test_case_256_3),
11963 TEST_CASE_ST(ut_setup, ut_teardown,
11964 test_AES_GCM_auth_decryption_test_case_256_4),
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_GCM_auth_decryption_test_case_256_5),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_GCM_auth_decryption_test_case_256_6),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_GCM_auth_decryption_test_case_256_7),
11972 /** AES GCM Authenticated Encryption big aad size */
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_GCM_auth_encryption_test_case_aad_1),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_GCM_auth_encryption_test_case_aad_2),
11978 /** AES GCM Authenticated Decryption big aad size */
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_AES_GCM_auth_decryption_test_case_aad_1),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_GCM_auth_decryption_test_case_aad_2),
11984 /** Out of place tests */
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11987 TEST_CASE_ST(ut_setup, ut_teardown,
11988 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11990 /** Session-less tests */
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11996 /** AES GMAC Authentication */
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_AES_GMAC_authentication_test_case_1),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_AES_GMAC_authentication_verify_test_case_1),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_AES_GMAC_authentication_test_case_2),
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_AES_GMAC_authentication_verify_test_case_2),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_AES_GMAC_authentication_test_case_3),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_AES_GMAC_authentication_verify_test_case_3),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_AES_GMAC_authentication_test_case_4),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_AES_GMAC_authentication_verify_test_case_4),
12014 /** SNOW 3G encrypt only (UEA2) */
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_snow3g_encryption_test_case_1),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_snow3g_encryption_test_case_2),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_snow3g_encryption_test_case_3),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_snow3g_encryption_test_case_4),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_snow3g_encryption_test_case_5),
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_snow3g_encryption_test_case_1_oop),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_snow3g_encryption_test_case_1_oop_sgl),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_snow3g_encryption_test_case_1_offset_oop),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_snow3g_decryption_test_case_1_oop),
12035 /** SNOW 3G generate auth, then encrypt (UEA2) */
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_snow3g_auth_cipher_test_case_1),
12038 TEST_CASE_ST(ut_setup, ut_teardown,
12039 test_snow3g_auth_cipher_test_case_2),
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_auth_cipher_test_case_2_oop),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_auth_cipher_part_digest_enc),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_auth_cipher_part_digest_enc_oop),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_auth_cipher_test_case_3_sgl),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12050 TEST_CASE_ST(ut_setup, ut_teardown,
12051 test_snow3g_auth_cipher_part_digest_enc_sgl),
12052 TEST_CASE_ST(ut_setup, ut_teardown,
12053 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12055 /** SNOW 3G decrypt (UEA2), then verify auth */
12056 TEST_CASE_ST(ut_setup, ut_teardown,
12057 test_snow3g_auth_cipher_verify_test_case_1),
12058 TEST_CASE_ST(ut_setup, ut_teardown,
12059 test_snow3g_auth_cipher_verify_test_case_2),
12060 TEST_CASE_ST(ut_setup, ut_teardown,
12061 test_snow3g_auth_cipher_verify_test_case_2_oop),
12062 TEST_CASE_ST(ut_setup, ut_teardown,
12063 test_snow3g_auth_cipher_verify_part_digest_enc),
12064 TEST_CASE_ST(ut_setup, ut_teardown,
12065 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12066 TEST_CASE_ST(ut_setup, ut_teardown,
12067 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12068 TEST_CASE_ST(ut_setup, ut_teardown,
12069 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12075 /** SNOW 3G decrypt only (UEA2) */
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_snow3g_decryption_test_case_1),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_snow3g_decryption_test_case_2),
12080 TEST_CASE_ST(ut_setup, ut_teardown,
12081 test_snow3g_decryption_test_case_3),
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_snow3g_decryption_test_case_4),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_snow3g_decryption_test_case_5),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_snow3g_decryption_with_digest_test_case_1),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_snow3g_hash_generate_test_case_1),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_snow3g_hash_generate_test_case_2),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_snow3g_hash_generate_test_case_3),
12094 /* Tests with buffers which length is not byte-aligned */
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_snow3g_hash_generate_test_case_4),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_snow3g_hash_generate_test_case_5),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_snow3g_hash_generate_test_case_6),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_snow3g_hash_verify_test_case_1),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_snow3g_hash_verify_test_case_2),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_snow3g_hash_verify_test_case_3),
12107 /* Tests with buffers which length is not byte-aligned */
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_snow3g_hash_verify_test_case_4),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_snow3g_hash_verify_test_case_5),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_snow3g_hash_verify_test_case_6),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_snow3g_cipher_auth_test_case_1),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_snow3g_auth_cipher_with_digest_test_case_1),
12119 /** ZUC encrypt only (EEA3) */
12120 TEST_CASE_ST(ut_setup, ut_teardown,
12121 test_zuc_encryption_test_case_1),
12122 TEST_CASE_ST(ut_setup, ut_teardown,
12123 test_zuc_encryption_test_case_2),
12124 TEST_CASE_ST(ut_setup, ut_teardown,
12125 test_zuc_encryption_test_case_3),
12126 TEST_CASE_ST(ut_setup, ut_teardown,
12127 test_zuc_encryption_test_case_4),
12128 TEST_CASE_ST(ut_setup, ut_teardown,
12129 test_zuc_encryption_test_case_5),
12130 TEST_CASE_ST(ut_setup, ut_teardown,
12131 test_zuc_encryption_test_case_6_sgl),
12133 /** ZUC authenticate (EIA3) */
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_zuc_hash_generate_test_case_1),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_zuc_hash_generate_test_case_2),
12138 TEST_CASE_ST(ut_setup, ut_teardown,
12139 test_zuc_hash_generate_test_case_3),
12140 TEST_CASE_ST(ut_setup, ut_teardown,
12141 test_zuc_hash_generate_test_case_4),
12142 TEST_CASE_ST(ut_setup, ut_teardown,
12143 test_zuc_hash_generate_test_case_5),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_zuc_hash_generate_test_case_6),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_zuc_hash_generate_test_case_7),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_zuc_hash_generate_test_case_8),
12151 /** ZUC alg-chain (EEA3/EIA3) */
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_zuc_cipher_auth_test_case_1),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_zuc_cipher_auth_test_case_2),
12157 /** ZUC generate auth, then encrypt (EEA3) */
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_zuc_auth_cipher_test_case_1),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_zuc_auth_cipher_test_case_1_oop),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_zuc_auth_cipher_test_case_1_sgl),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_zuc_auth_cipher_test_case_1_oop_sgl),
12167 /** ZUC decrypt (EEA3), then verify auth */
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_zuc_auth_cipher_verify_test_case_1),
12170 TEST_CASE_ST(ut_setup, ut_teardown,
12171 test_zuc_auth_cipher_verify_test_case_1_oop),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_zuc_auth_cipher_verify_test_case_1_sgl),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12177 /** HMAC_MD5 Authentication */
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_MD5_HMAC_generate_case_1),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_MD5_HMAC_verify_case_1),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_MD5_HMAC_generate_case_2),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_MD5_HMAC_verify_case_2),
12187 /** KASUMI hash only (UIA1) */
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_kasumi_hash_generate_test_case_1),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_kasumi_hash_generate_test_case_2),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_kasumi_hash_generate_test_case_3),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_kasumi_hash_generate_test_case_4),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_kasumi_hash_generate_test_case_5),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_kasumi_hash_generate_test_case_6),
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_kasumi_hash_verify_test_case_1),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_kasumi_hash_verify_test_case_2),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_kasumi_hash_verify_test_case_3),
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_kasumi_hash_verify_test_case_4),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_kasumi_hash_verify_test_case_5),
12212 /** KASUMI encrypt only (UEA1) */
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_encryption_test_case_1),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_encryption_test_case_1_sgl),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_kasumi_encryption_test_case_1_oop),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_encryption_test_case_1_oop_sgl),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_encryption_test_case_2),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_encryption_test_case_3),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_kasumi_encryption_test_case_4),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_encryption_test_case_5),
12230 /** KASUMI decrypt only (UEA1) */
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_decryption_test_case_1),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_kasumi_decryption_test_case_2),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_kasumi_decryption_test_case_3),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_kasumi_decryption_test_case_4),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_kasumi_decryption_test_case_5),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_kasumi_decryption_test_case_1_oop),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_kasumi_cipher_auth_test_case_1),
12247 /** KASUMI generate auth, then encrypt (F8) */
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_kasumi_auth_cipher_test_case_1),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_kasumi_auth_cipher_test_case_2),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_kasumi_auth_cipher_test_case_2_oop),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 test_kasumi_auth_cipher_test_case_2_sgl),
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12259 /** KASUMI decrypt (F8), then verify auth */
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 test_kasumi_auth_cipher_verify_test_case_1),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_kasumi_auth_cipher_verify_test_case_2),
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_kasumi_auth_cipher_verify_test_case_2_oop),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12271 /** ESN Testcase */
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12277 /** Negative tests */
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12306 TEST_CASE_ST(ut_setup, ut_teardown,
12307 authentication_verify_AES128_GMAC_fail_data_corrupt),
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12310 TEST_CASE_ST(ut_setup, ut_teardown,
12311 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12312 TEST_CASE_ST(ut_setup, ut_teardown,
12313 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12315 /** Mixed CIPHER + HASH algorithms */
12316 /** AUTH AES CMAC + CIPHER AES CTR */
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12334 /** AUTH ZUC + CIPHER SNOW3G */
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_auth_zuc_cipher_snow_test_case_1),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_verify_auth_zuc_cipher_snow_test_case_1),
12339 /** AUTH AES CMAC + CIPHER SNOW3G */
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_auth_aes_cmac_cipher_snow_test_case_1),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12344 /** AUTH ZUC + CIPHER AES CTR */
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_auth_zuc_cipher_aes_ctr_test_case_1),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12349 /** AUTH SNOW3G + CIPHER AES CTR */
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_auth_snow_cipher_aes_ctr_test_case_1),
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12354 /** AUTH SNOW3G + CIPHER ZUC */
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_auth_snow_cipher_zuc_test_case_1),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_verify_auth_snow_cipher_zuc_test_case_1),
12359 /** AUTH AES CMAC + CIPHER ZUC */
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_auth_aes_cmac_cipher_zuc_test_case_1),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12365 /** AUTH NULL + CIPHER SNOW3G */
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_auth_null_cipher_snow_test_case_1),
12368 TEST_CASE_ST(ut_setup, ut_teardown,
12369 test_verify_auth_null_cipher_snow_test_case_1),
12370 /** AUTH NULL + CIPHER ZUC */
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_auth_null_cipher_zuc_test_case_1),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_verify_auth_null_cipher_zuc_test_case_1),
12375 /** AUTH SNOW3G + CIPHER NULL */
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_auth_snow_cipher_null_test_case_1),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 test_verify_auth_snow_cipher_null_test_case_1),
12380 /** AUTH ZUC + CIPHER NULL */
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_auth_zuc_cipher_null_test_case_1),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_verify_auth_zuc_cipher_null_test_case_1),
12385 /** AUTH NULL + CIPHER AES CTR */
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_auth_null_cipher_aes_ctr_test_case_1),
12388 TEST_CASE_ST(ut_setup, ut_teardown,
12389 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12390 /** AUTH AES CMAC + CIPHER NULL */
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_auth_aes_cmac_cipher_null_test_case_1),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12396 #ifdef RTE_LIBRTE_SECURITY
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_PDCP_PROTO_all),
12400 TEST_CASES_END() /**< NULL terminate unit test array */
12404 static struct unit_test_suite cryptodev_virtio_testsuite = {
12405 .suite_name = "Crypto VIRTIO Unit Test Suite",
12406 .setup = testsuite_setup,
12407 .teardown = testsuite_teardown,
12408 .unit_test_cases = {
12409 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12411 TEST_CASES_END() /**< NULL terminate unit test array */
12415 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12416 .suite_name = "Crypto CAAM JR Unit Test Suite",
12417 .setup = testsuite_setup,
12418 .teardown = testsuite_teardown,
12419 .unit_test_cases = {
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_device_configure_invalid_dev_id),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_multi_session),
12425 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12426 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12427 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12428 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12429 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12431 TEST_CASES_END() /**< NULL terminate unit test array */
12435 static struct unit_test_suite cryptodev_armv8_testsuite = {
12436 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12437 .setup = testsuite_setup,
12438 .teardown = testsuite_teardown,
12439 .unit_test_cases = {
12440 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12442 /** Negative tests */
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12448 TEST_CASES_END() /**< NULL terminate unit test array */
12452 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12453 .suite_name = "Crypto Device Marvell Component Test Suite",
12454 .setup = testsuite_setup,
12455 .teardown = testsuite_teardown,
12456 .unit_test_cases = {
12457 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_multi_session_random_usage),
12460 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12461 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12462 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12463 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12464 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12466 /** Negative tests */
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12471 TEST_CASE_ST(ut_setup, ut_teardown,
12472 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12476 TEST_CASES_END() /**< NULL terminate unit test array */
12480 static struct unit_test_suite cryptodev_ccp_testsuite = {
12481 .suite_name = "Crypto Device CCP Unit Test Suite",
12482 .setup = testsuite_setup,
12483 .teardown = testsuite_teardown,
12484 .unit_test_cases = {
12485 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_multi_session_random_usage),
12488 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12489 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12490 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12491 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12492 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12494 /** Negative tests */
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12504 TEST_CASES_END() /**< NULL terminate unit test array */
12508 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12509 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12510 .setup = testsuite_setup,
12511 .teardown = testsuite_teardown,
12512 .unit_test_cases = {
12513 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12514 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12515 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12516 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12517 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12519 /** AES GCM Authenticated Encryption */
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_authenticated_encryption_test_case_1),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_authenticated_encryption_test_case_2),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_authenticated_encryption_test_case_3),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_authenticated_encryption_test_case_4),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_authenticated_encryption_test_case_5),
12530 TEST_CASE_ST(ut_setup, ut_teardown,
12531 test_AES_GCM_authenticated_encryption_test_case_6),
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_AES_GCM_authenticated_encryption_test_case_7),
12535 /** AES GCM Authenticated Decryption */
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_authenticated_decryption_test_case_1),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_authenticated_decryption_test_case_2),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_authenticated_decryption_test_case_3),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_authenticated_decryption_test_case_4),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_authenticated_decryption_test_case_5),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_authenticated_decryption_test_case_6),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_authenticated_decryption_test_case_7),
12550 /** AES GMAC Authentication */
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_AES_GMAC_authentication_test_case_1),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_AES_GMAC_authentication_verify_test_case_1),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_AES_GMAC_authentication_test_case_2),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_AES_GMAC_authentication_verify_test_case_2),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_AES_GMAC_authentication_test_case_3),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_AES_GMAC_authentication_verify_test_case_3),
12564 /** SNOW 3G encrypt only (UEA2) */
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_snow3g_encryption_test_case_1),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_snow3g_encryption_test_case_2),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_snow3g_encryption_test_case_3),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_snow3g_encryption_test_case_4),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_snow3g_encryption_test_case_5),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_snow3g_encryption_test_case_1_oop),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_snow3g_decryption_test_case_1_oop),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_snow3g_encryption_test_case_1_oop_sgl),
12583 /** SNOW 3G decrypt only (UEA2) */
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_snow3g_decryption_test_case_1),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_snow3g_decryption_test_case_2),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_snow3g_decryption_test_case_3),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_snow3g_decryption_test_case_4),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_snow3g_decryption_test_case_5),
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_snow3g_hash_generate_test_case_1),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_snow3g_hash_generate_test_case_2),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_snow3g_hash_generate_test_case_3),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_snow3g_hash_verify_test_case_1),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_snow3g_hash_verify_test_case_2),
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_snow3g_hash_verify_test_case_3),
12608 /** ZUC encrypt only (EEA3) */
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_zuc_encryption_test_case_1),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_zuc_encryption_test_case_2),
12613 TEST_CASE_ST(ut_setup, ut_teardown,
12614 test_zuc_encryption_test_case_3),
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_zuc_encryption_test_case_4),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_zuc_encryption_test_case_5),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_zuc_hash_generate_test_case_1),
12621 TEST_CASE_ST(ut_setup, ut_teardown,
12622 test_zuc_hash_generate_test_case_2),
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_zuc_hash_generate_test_case_3),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_zuc_hash_generate_test_case_4),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_zuc_hash_generate_test_case_5),
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_zuc_encryption_test_case_6_sgl),
12632 /** KASUMI encrypt only (UEA1) */
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_kasumi_encryption_test_case_1),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_kasumi_encryption_test_case_2),
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_kasumi_encryption_test_case_3),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_kasumi_encryption_test_case_4),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_kasumi_encryption_test_case_5),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_kasumi_encryption_test_case_1_sgl),
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_kasumi_encryption_test_case_1_oop_sgl),
12647 /** KASUMI decrypt only (UEA1) */
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_kasumi_decryption_test_case_1),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_kasumi_decryption_test_case_2),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_kasumi_decryption_test_case_3),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_kasumi_decryption_test_case_4),
12656 TEST_CASE_ST(ut_setup, ut_teardown,
12657 test_kasumi_decryption_test_case_5),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_kasumi_encryption_test_case_1_oop),
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_kasumi_decryption_test_case_1_oop),
12664 /** KASUMI hash only (UIA1) */
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_kasumi_hash_generate_test_case_1),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 test_kasumi_hash_generate_test_case_2),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_kasumi_hash_generate_test_case_3),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_kasumi_hash_generate_test_case_4),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_kasumi_hash_generate_test_case_5),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_kasumi_hash_generate_test_case_6),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_kasumi_hash_verify_test_case_1),
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_kasumi_hash_verify_test_case_2),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_kasumi_hash_verify_test_case_3),
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 test_kasumi_hash_verify_test_case_4),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_kasumi_hash_verify_test_case_5),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_null_cipher_only_operation),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_null_auth_only_operation),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_null_cipher_auth_operation),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_null_auth_cipher_operation),
12698 /** Negative tests */
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 authentication_verify_AES128_GMAC_fail_data_corrupt),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12711 TEST_CASES_END() /**< NULL terminate unit test array */
12715 static struct unit_test_suite cryptodev_nitrox_testsuite = {
12716 .suite_name = "Crypto NITROX Unit Test Suite",
12717 .setup = testsuite_setup,
12718 .teardown = testsuite_teardown,
12719 .unit_test_cases = {
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_device_configure_invalid_dev_id),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_device_configure_invalid_queue_pair_ids),
12724 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12725 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12727 TEST_CASES_END() /**< NULL terminate unit test array */
12731 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
12732 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
12733 .setup = testsuite_setup,
12734 .teardown = testsuite_teardown,
12735 .unit_test_cases = {
12736 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12737 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12738 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12739 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12740 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12742 /** AES GCM Authenticated Encryption */
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_AES_GCM_authenticated_encryption_test_case_1),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_encryption_test_case_2),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_encryption_test_case_3),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_authenticated_encryption_test_case_4),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_authenticated_encryption_test_case_5),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_authenticated_encryption_test_case_6),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_authenticated_encryption_test_case_7),
12758 /** AES GCM Authenticated Decryption */
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GCM_authenticated_decryption_test_case_1),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_authenticated_decryption_test_case_2),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_authenticated_decryption_test_case_3),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_authenticated_decryption_test_case_4),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_authenticated_decryption_test_case_5),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_authenticated_decryption_test_case_6),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_authenticated_decryption_test_case_7),
12773 /** AES GMAC Authentication */
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GMAC_authentication_test_case_1),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_AES_GMAC_authentication_verify_test_case_1),
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_AES_GMAC_authentication_test_case_2),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GMAC_authentication_verify_test_case_2),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_AES_GMAC_authentication_test_case_3),
12784 TEST_CASE_ST(ut_setup, ut_teardown,
12785 test_AES_GMAC_authentication_verify_test_case_3),
12787 /** SNOW 3G encrypt only (UEA2) */
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_snow3g_encryption_test_case_1),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_snow3g_encryption_test_case_2),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_snow3g_encryption_test_case_3),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_snow3g_encryption_test_case_4),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_snow3g_encryption_test_case_5),
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_snow3g_encryption_test_case_1_oop),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_snow3g_decryption_test_case_1_oop),
12803 TEST_CASE_ST(ut_setup, ut_teardown,
12804 test_snow3g_encryption_test_case_1_oop_sgl),
12806 /** SNOW 3G decrypt only (UEA2) */
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_snow3g_decryption_test_case_1),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_snow3g_decryption_test_case_2),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_snow3g_decryption_test_case_3),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_snow3g_decryption_test_case_4),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_snow3g_decryption_test_case_5),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_snow3g_hash_generate_test_case_1),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_snow3g_hash_generate_test_case_2),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_snow3g_hash_generate_test_case_3),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_snow3g_hash_verify_test_case_1),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_snow3g_hash_verify_test_case_2),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_snow3g_hash_verify_test_case_3),
12831 /** ZUC encrypt only (EEA3) */
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_zuc_encryption_test_case_1),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_zuc_encryption_test_case_2),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_zuc_encryption_test_case_3),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_zuc_encryption_test_case_4),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_zuc_encryption_test_case_5),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_zuc_hash_generate_test_case_1),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_zuc_hash_generate_test_case_2),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_zuc_hash_generate_test_case_3),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_zuc_hash_generate_test_case_4),
12850 TEST_CASE_ST(ut_setup, ut_teardown,
12851 test_zuc_hash_generate_test_case_5),
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_zuc_encryption_test_case_6_sgl),
12855 /** KASUMI encrypt only (UEA1) */
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_kasumi_encryption_test_case_1),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_kasumi_encryption_test_case_2),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_kasumi_encryption_test_case_3),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_kasumi_encryption_test_case_4),
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 test_kasumi_encryption_test_case_5),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_kasumi_encryption_test_case_1_sgl),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_kasumi_encryption_test_case_1_oop_sgl),
12870 /** KASUMI decrypt only (UEA1) */
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_kasumi_decryption_test_case_1),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_kasumi_decryption_test_case_2),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_kasumi_decryption_test_case_3),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_kasumi_decryption_test_case_4),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_kasumi_decryption_test_case_5),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_kasumi_encryption_test_case_1_oop),
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_kasumi_decryption_test_case_1_oop),
12887 /** KASUMI hash only (UIA1) */
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_kasumi_hash_generate_test_case_1),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_kasumi_hash_generate_test_case_2),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_kasumi_hash_generate_test_case_3),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_kasumi_hash_generate_test_case_4),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_hash_generate_test_case_5),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_hash_generate_test_case_6),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_kasumi_hash_verify_test_case_1),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_hash_verify_test_case_2),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_kasumi_hash_verify_test_case_3),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_kasumi_hash_verify_test_case_4),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_kasumi_hash_verify_test_case_5),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_null_cipher_only_operation),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_null_auth_only_operation),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_null_cipher_auth_operation),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_null_auth_cipher_operation),
12921 /** Negative tests */
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 authentication_verify_AES128_GMAC_fail_data_corrupt),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12934 TEST_CASES_END() /**< NULL terminate unit test array */
12939 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12941 gbl_driver_id = rte_cryptodev_driver_id_get(
12942 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12944 if (gbl_driver_id == -1) {
12945 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12946 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12947 "are enabled in config file to run this testsuite.\n");
12948 return TEST_SKIPPED;
12951 return unit_test_suite_runner(&cryptodev_testsuite);
12955 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12957 gbl_driver_id = rte_cryptodev_driver_id_get(
12958 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12960 if (gbl_driver_id == -1) {
12961 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12962 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12963 "in config file to run this testsuite.\n");
12964 return TEST_FAILED;
12967 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12971 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12973 gbl_driver_id = rte_cryptodev_driver_id_get(
12974 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12976 if (gbl_driver_id == -1) {
12977 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12978 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12979 "in config file to run this testsuite.\n");
12980 return TEST_SKIPPED;
12983 return unit_test_suite_runner(&cryptodev_testsuite);
12987 test_cryptodev_cpu_aesni_mb(void)
12990 enum rte_security_session_action_type at;
12992 gbl_driver_id = rte_cryptodev_driver_id_get(
12993 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12995 if (gbl_driver_id == -1) {
12996 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12997 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12998 "in config file to run this testsuite.\n");
12999 return TEST_SKIPPED;
13002 at = gbl_action_type;
13003 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13004 rc = unit_test_suite_runner(&cryptodev_testsuite);
13005 gbl_action_type = at;
13010 test_cryptodev_openssl(void)
13012 gbl_driver_id = rte_cryptodev_driver_id_get(
13013 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13015 if (gbl_driver_id == -1) {
13016 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13017 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13018 "in config file to run this testsuite.\n");
13019 return TEST_SKIPPED;
13022 return unit_test_suite_runner(&cryptodev_testsuite);
13026 test_cryptodev_aesni_gcm(void)
13028 gbl_driver_id = rte_cryptodev_driver_id_get(
13029 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13031 if (gbl_driver_id == -1) {
13032 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13033 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13034 "in config file to run this testsuite.\n");
13035 return TEST_SKIPPED;
13038 return unit_test_suite_runner(&cryptodev_testsuite);
13042 test_cryptodev_cpu_aesni_gcm(void)
13045 enum rte_security_session_action_type at;
13047 gbl_driver_id = rte_cryptodev_driver_id_get(
13048 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13050 if (gbl_driver_id == -1) {
13051 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13052 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13053 "in config file to run this testsuite.\n");
13054 return TEST_SKIPPED;
13057 at = gbl_action_type;
13058 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13059 rc = unit_test_suite_runner(&cryptodev_testsuite);
13060 gbl_action_type = at;
13065 test_cryptodev_null(void)
13067 gbl_driver_id = rte_cryptodev_driver_id_get(
13068 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13070 if (gbl_driver_id == -1) {
13071 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13072 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13073 "in config file to run this testsuite.\n");
13074 return TEST_SKIPPED;
13077 return unit_test_suite_runner(&cryptodev_testsuite);
13081 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13083 gbl_driver_id = rte_cryptodev_driver_id_get(
13084 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13086 if (gbl_driver_id == -1) {
13087 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13088 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13089 "in config file to run this testsuite.\n");
13090 return TEST_SKIPPED;
13093 return unit_test_suite_runner(&cryptodev_testsuite);
13097 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13099 gbl_driver_id = rte_cryptodev_driver_id_get(
13100 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13102 if (gbl_driver_id == -1) {
13103 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13104 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13105 "in config file to run this testsuite.\n");
13106 return TEST_SKIPPED;
13109 return unit_test_suite_runner(&cryptodev_testsuite);
13113 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13115 gbl_driver_id = rte_cryptodev_driver_id_get(
13116 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13118 if (gbl_driver_id == -1) {
13119 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13120 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13121 "in config file to run this testsuite.\n");
13122 return TEST_SKIPPED;
13125 return unit_test_suite_runner(&cryptodev_testsuite);
13129 test_cryptodev_armv8(void)
13131 gbl_driver_id = rte_cryptodev_driver_id_get(
13132 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13134 if (gbl_driver_id == -1) {
13135 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13136 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13137 "in config file to run this testsuite.\n");
13138 return TEST_SKIPPED;
13141 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13145 test_cryptodev_mrvl(void)
13147 gbl_driver_id = rte_cryptodev_driver_id_get(
13148 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13150 if (gbl_driver_id == -1) {
13151 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13152 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13153 "in config file to run this testsuite.\n");
13154 return TEST_SKIPPED;
13157 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13160 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13163 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13165 gbl_driver_id = rte_cryptodev_driver_id_get(
13166 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13168 if (gbl_driver_id == -1) {
13169 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13170 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13171 "in config file to run this testsuite.\n");
13172 return TEST_SKIPPED;
13175 if (rte_cryptodev_driver_id_get(
13176 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13177 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13178 " enabled in config file to run this testsuite.\n");
13179 return TEST_SKIPPED;
13181 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13184 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13189 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13191 gbl_driver_id = rte_cryptodev_driver_id_get(
13192 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13194 if (gbl_driver_id == -1) {
13195 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13196 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13197 "in config file to run this testsuite.\n");
13198 return TEST_SKIPPED;
13201 return unit_test_suite_runner(&cryptodev_testsuite);
13205 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13207 gbl_driver_id = rte_cryptodev_driver_id_get(
13208 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13210 if (gbl_driver_id == -1) {
13211 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13212 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13213 "in config file to run this testsuite.\n");
13214 return TEST_SKIPPED;
13217 return unit_test_suite_runner(&cryptodev_testsuite);
13221 test_cryptodev_ccp(void)
13223 gbl_driver_id = rte_cryptodev_driver_id_get(
13224 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13226 if (gbl_driver_id == -1) {
13227 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13228 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13229 "in config file to run this testsuite.\n");
13230 return TEST_FAILED;
13233 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13237 test_cryptodev_octeontx(void)
13239 gbl_driver_id = rte_cryptodev_driver_id_get(
13240 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13241 if (gbl_driver_id == -1) {
13242 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13243 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13244 "enabled in config file to run this "
13246 return TEST_FAILED;
13248 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13252 test_cryptodev_octeontx2(void)
13254 gbl_driver_id = rte_cryptodev_driver_id_get(
13255 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13256 if (gbl_driver_id == -1) {
13257 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13258 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13259 "enabled in config file to run this "
13261 return TEST_FAILED;
13263 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13267 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13269 gbl_driver_id = rte_cryptodev_driver_id_get(
13270 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13272 if (gbl_driver_id == -1) {
13273 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13274 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13275 "in config file to run this testsuite.\n");
13276 return TEST_FAILED;
13279 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13283 test_cryptodev_nitrox(void)
13285 gbl_driver_id = rte_cryptodev_driver_id_get(
13286 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13288 if (gbl_driver_id == -1) {
13289 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13290 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13291 "in config file to run this testsuite.\n");
13292 return TEST_FAILED;
13295 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13298 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13299 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13300 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13301 test_cryptodev_cpu_aesni_mb);
13302 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13303 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13304 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13305 test_cryptodev_cpu_aesni_gcm);
13306 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13307 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13308 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13309 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13310 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13311 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13312 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13313 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13314 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13315 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13316 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13317 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13318 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13319 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);