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_gmac_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->auth.data.offset,
159 sop->auth.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);
172 symvec.digest = (void **)&sop->auth.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;
189 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
193 struct rte_crypto_sym_op *sop;
194 union rte_crypto_sym_ofs ofs;
195 struct rte_crypto_sgl sgl;
196 struct rte_crypto_sym_vec symvec;
197 struct rte_crypto_vec vec[UINT8_MAX];
201 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
202 sop->aead.data.length, vec, RTE_DIM(vec));
204 if (n < 0 || n != sop->m_src->nb_segs) {
205 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
212 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
214 symvec.aad = (void **)&sop->aead.aad.data;
215 symvec.digest = (void **)&sop->aead.digest.data;
221 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
225 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
227 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
230 static struct rte_crypto_op *
231 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
234 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
236 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
237 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
243 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
246 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
247 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
254 static struct crypto_testsuite_params testsuite_params = { NULL };
255 static struct crypto_unittest_params unittest_params;
258 testsuite_setup(void)
260 struct crypto_testsuite_params *ts_params = &testsuite_params;
261 struct rte_cryptodev_info info;
262 uint32_t i = 0, nb_devs, dev_id;
266 memset(ts_params, 0, sizeof(*ts_params));
268 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
269 if (ts_params->mbuf_pool == NULL) {
270 /* Not already created so create */
271 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
273 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
275 if (ts_params->mbuf_pool == NULL) {
276 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
281 ts_params->large_mbuf_pool = rte_mempool_lookup(
282 "CRYPTO_LARGE_MBUFPOOL");
283 if (ts_params->large_mbuf_pool == NULL) {
284 /* Not already created so create */
285 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
286 "CRYPTO_LARGE_MBUFPOOL",
289 if (ts_params->large_mbuf_pool == NULL) {
291 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
296 ts_params->op_mpool = rte_crypto_op_pool_create(
297 "MBUF_CRYPTO_SYM_OP_POOL",
298 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
299 NUM_MBUFS, MBUF_CACHE_SIZE,
301 sizeof(struct rte_crypto_sym_xform) +
304 if (ts_params->op_mpool == NULL) {
305 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
309 /* Create an AESNI MB device if required */
310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
312 nb_devs = rte_cryptodev_device_count_by_driver(
313 rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
317 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
319 TEST_ASSERT(ret == 0,
320 "Failed to create instance of"
322 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
326 /* Create an AESNI GCM device if required */
327 if (gbl_driver_id == rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
329 nb_devs = rte_cryptodev_device_count_by_driver(
330 rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
333 TEST_ASSERT_SUCCESS(rte_vdev_init(
334 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
335 "Failed to create instance of"
337 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
341 /* Create a SNOW 3G device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
348 TEST_ASSERT_SUCCESS(rte_vdev_init(
349 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
350 "Failed to create instance of"
352 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
356 /* Create a KASUMI device if required */
357 if (gbl_driver_id == rte_cryptodev_driver_id_get(
358 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
359 nb_devs = rte_cryptodev_device_count_by_driver(
360 rte_cryptodev_driver_id_get(
361 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
363 TEST_ASSERT_SUCCESS(rte_vdev_init(
364 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
365 "Failed to create instance of"
367 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
371 /* Create a ZUC device if required */
372 if (gbl_driver_id == rte_cryptodev_driver_id_get(
373 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
374 nb_devs = rte_cryptodev_device_count_by_driver(
375 rte_cryptodev_driver_id_get(
376 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
378 TEST_ASSERT_SUCCESS(rte_vdev_init(
379 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
380 "Failed to create instance of"
382 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
386 /* Create a NULL device if required */
387 if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
389 nb_devs = rte_cryptodev_device_count_by_driver(
390 rte_cryptodev_driver_id_get(
391 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
394 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
396 TEST_ASSERT(ret == 0,
397 "Failed to create instance of"
399 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
403 /* Create an OPENSSL device if required */
404 if (gbl_driver_id == rte_cryptodev_driver_id_get(
405 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
406 nb_devs = rte_cryptodev_device_count_by_driver(
407 rte_cryptodev_driver_id_get(
408 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
411 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
414 TEST_ASSERT(ret == 0, "Failed to create "
415 "instance of pmd : %s",
416 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
420 /* Create a ARMv8 device if required */
421 if (gbl_driver_id == rte_cryptodev_driver_id_get(
422 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
423 nb_devs = rte_cryptodev_device_count_by_driver(
424 rte_cryptodev_driver_id_get(
425 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
428 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
431 TEST_ASSERT(ret == 0, "Failed to create "
432 "instance of pmd : %s",
433 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
437 /* Create a MVSAM device if required */
438 if (gbl_driver_id == rte_cryptodev_driver_id_get(
439 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
440 nb_devs = rte_cryptodev_device_count_by_driver(
441 rte_cryptodev_driver_id_get(
442 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
445 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
448 TEST_ASSERT(ret == 0, "Failed to create "
449 "instance of pmd : %s",
450 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
454 /* Create an CCP device if required */
455 if (gbl_driver_id == rte_cryptodev_driver_id_get(
456 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
457 nb_devs = rte_cryptodev_device_count_by_driver(
458 rte_cryptodev_driver_id_get(
459 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
462 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
465 TEST_ASSERT(ret == 0, "Failed to create "
466 "instance of pmd : %s",
467 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
471 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
472 char vdev_args[VDEV_ARGS_SIZE] = {""};
473 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
474 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
475 uint16_t slave_core_count = 0;
476 uint16_t socket_id = 0;
478 if (gbl_driver_id == rte_cryptodev_driver_id_get(
479 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
481 /* Identify the Slave Cores
482 * Use 2 slave cores for the device args
484 RTE_LCORE_FOREACH_SLAVE(i) {
485 if (slave_core_count > 1)
487 snprintf(vdev_args, sizeof(vdev_args),
488 "%s%d", temp_str, i);
489 strcpy(temp_str, vdev_args);
490 strlcat(temp_str, ";", sizeof(temp_str));
492 socket_id = rte_lcore_to_socket_id(i);
494 if (slave_core_count != 2) {
496 "Cryptodev scheduler test require at least "
497 "two slave cores to run. "
498 "Please use the correct coremask.\n");
501 strcpy(temp_str, vdev_args);
502 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
503 temp_str, socket_id);
504 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
505 nb_devs = rte_cryptodev_device_count_by_driver(
506 rte_cryptodev_driver_id_get(
507 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
510 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
512 TEST_ASSERT(ret == 0,
513 "Failed to create instance %u of"
515 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
518 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
520 nb_devs = rte_cryptodev_count();
522 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
526 /* Create list of valid crypto devs */
527 for (i = 0; i < nb_devs; i++) {
528 rte_cryptodev_info_get(i, &info);
529 if (info.driver_id == gbl_driver_id)
530 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
533 if (ts_params->valid_dev_count < 1)
536 /* Set up all the qps on the first of the valid devices found */
538 dev_id = ts_params->valid_devs[0];
540 rte_cryptodev_info_get(dev_id, &info);
542 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
543 ts_params->conf.socket_id = SOCKET_ID_ANY;
544 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
546 unsigned int session_size =
547 rte_cryptodev_sym_get_private_session_size(dev_id);
550 * Create mempool with maximum number of sessions * 2,
551 * to include the session headers
553 if (info.sym.max_nb_sessions != 0 &&
554 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
555 RTE_LOG(ERR, USER1, "Device does not support "
556 "at least %u sessions\n",
561 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
562 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
564 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
565 "session mempool allocation failed");
567 ts_params->session_priv_mpool = rte_mempool_create(
571 0, 0, NULL, NULL, NULL,
574 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
575 "session mempool allocation failed");
579 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
581 "Failed to configure cryptodev %u with %u qps",
582 dev_id, ts_params->conf.nb_queue_pairs);
584 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
585 ts_params->qp_conf.mp_session = ts_params->session_mpool;
586 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
588 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
589 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
590 dev_id, qp_id, &ts_params->qp_conf,
591 rte_cryptodev_socket_id(dev_id)),
592 "Failed to setup queue pair %u on cryptodev %u",
600 testsuite_teardown(void)
602 struct crypto_testsuite_params *ts_params = &testsuite_params;
604 if (ts_params->mbuf_pool != NULL) {
605 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
606 rte_mempool_avail_count(ts_params->mbuf_pool));
609 if (ts_params->op_mpool != NULL) {
610 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
611 rte_mempool_avail_count(ts_params->op_mpool));
614 /* Free session mempools */
615 if (ts_params->session_priv_mpool != NULL) {
616 rte_mempool_free(ts_params->session_priv_mpool);
617 ts_params->session_priv_mpool = NULL;
620 if (ts_params->session_mpool != NULL) {
621 rte_mempool_free(ts_params->session_mpool);
622 ts_params->session_mpool = NULL;
629 struct crypto_testsuite_params *ts_params = &testsuite_params;
630 struct crypto_unittest_params *ut_params = &unittest_params;
634 /* Clear unit test parameters before running test */
635 memset(ut_params, 0, sizeof(*ut_params));
637 /* Reconfigure device to default parameters */
638 ts_params->conf.socket_id = SOCKET_ID_ANY;
639 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
640 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
641 ts_params->qp_conf.mp_session = ts_params->session_mpool;
642 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
644 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
646 "Failed to configure cryptodev %u",
647 ts_params->valid_devs[0]);
649 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
650 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
651 ts_params->valid_devs[0], qp_id,
653 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
654 "Failed to setup queue pair %u on cryptodev %u",
655 qp_id, ts_params->valid_devs[0]);
659 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
661 /* Start the device */
662 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
663 "Failed to start cryptodev %u",
664 ts_params->valid_devs[0]);
672 struct crypto_testsuite_params *ts_params = &testsuite_params;
673 struct crypto_unittest_params *ut_params = &unittest_params;
674 struct rte_cryptodev_stats stats;
676 /* free crypto session structure */
677 #ifdef RTE_LIBRTE_SECURITY
678 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
679 if (ut_params->sec_session) {
680 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
681 (ts_params->valid_devs[0]),
682 ut_params->sec_session);
683 ut_params->sec_session = NULL;
688 if (ut_params->sess) {
689 rte_cryptodev_sym_session_clear(
690 ts_params->valid_devs[0],
692 rte_cryptodev_sym_session_free(ut_params->sess);
693 ut_params->sess = NULL;
697 /* free crypto operation structure */
699 rte_crypto_op_free(ut_params->op);
702 * free mbuf - both obuf and ibuf are usually the same,
703 * so check if they point at the same address is necessary,
704 * to avoid freeing the mbuf twice.
706 if (ut_params->obuf) {
707 rte_pktmbuf_free(ut_params->obuf);
708 if (ut_params->ibuf == ut_params->obuf)
712 if (ut_params->ibuf) {
713 rte_pktmbuf_free(ut_params->ibuf);
717 if (ts_params->mbuf_pool != NULL)
718 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
719 rte_mempool_avail_count(ts_params->mbuf_pool));
721 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
723 /* Stop the device */
724 rte_cryptodev_stop(ts_params->valid_devs[0]);
728 test_device_configure_invalid_dev_id(void)
730 struct crypto_testsuite_params *ts_params = &testsuite_params;
731 uint16_t dev_id, num_devs = 0;
733 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
734 "Need at least %d devices for test", 1);
736 /* valid dev_id values */
737 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
739 /* Stop the device in case it's started so it can be configured */
740 rte_cryptodev_stop(dev_id);
742 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
743 "Failed test for rte_cryptodev_configure: "
744 "invalid dev_num %u", dev_id);
746 /* invalid dev_id values */
749 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
750 "Failed test for rte_cryptodev_configure: "
751 "invalid dev_num %u", dev_id);
755 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
756 "Failed test for rte_cryptodev_configure:"
757 "invalid dev_num %u", dev_id);
763 test_device_configure_invalid_queue_pair_ids(void)
765 struct crypto_testsuite_params *ts_params = &testsuite_params;
766 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
768 /* This test is for QAT and NITROX PMDs only */
769 if (gbl_driver_id != rte_cryptodev_driver_id_get(
770 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)) &&
771 gbl_driver_id != rte_cryptodev_driver_id_get(
772 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)))
775 /* Stop the device in case it's started so it can be configured */
776 rte_cryptodev_stop(ts_params->valid_devs[0]);
778 /* valid - one queue pairs */
779 ts_params->conf.nb_queue_pairs = 1;
781 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
783 "Failed to configure cryptodev: dev_id %u, qp_id %u",
784 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
787 /* valid - max value queue pairs */
788 ts_params->conf.nb_queue_pairs = orig_nb_qps;
790 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
792 "Failed to configure cryptodev: dev_id %u, qp_id %u",
793 ts_params->valid_devs[0],
794 ts_params->conf.nb_queue_pairs);
797 /* invalid - zero queue pairs */
798 ts_params->conf.nb_queue_pairs = 0;
800 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
802 "Failed test for rte_cryptodev_configure, dev_id %u,"
804 ts_params->valid_devs[0],
805 ts_params->conf.nb_queue_pairs);
808 /* invalid - max value supported by field queue pairs */
809 ts_params->conf.nb_queue_pairs = UINT16_MAX;
811 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
813 "Failed test for rte_cryptodev_configure, dev_id %u,"
815 ts_params->valid_devs[0],
816 ts_params->conf.nb_queue_pairs);
819 /* invalid - max value + 1 queue pairs */
820 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
822 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
824 "Failed test for rte_cryptodev_configure, dev_id %u,"
826 ts_params->valid_devs[0],
827 ts_params->conf.nb_queue_pairs);
829 /* revert to original testsuite value */
830 ts_params->conf.nb_queue_pairs = orig_nb_qps;
836 test_queue_pair_descriptor_setup(void)
838 struct crypto_testsuite_params *ts_params = &testsuite_params;
839 struct rte_cryptodev_info dev_info;
840 struct rte_cryptodev_qp_conf qp_conf = {
841 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
846 /* This test is for QAT PMD only */
847 if (gbl_driver_id != rte_cryptodev_driver_id_get(
848 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
851 /* Stop the device in case it's started so it can be configured */
852 rte_cryptodev_stop(ts_params->valid_devs[0]);
855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
857 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
859 "Failed to configure cryptodev %u",
860 ts_params->valid_devs[0]);
863 * Test various ring sizes on this device. memzones can't be
864 * freed so are re-used if ring is released and re-created.
866 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
867 qp_conf.mp_session = ts_params->session_mpool;
868 qp_conf.mp_session_private = ts_params->session_priv_mpool;
870 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
871 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
872 ts_params->valid_devs[0], qp_id, &qp_conf,
873 rte_cryptodev_socket_id(
874 ts_params->valid_devs[0])),
876 "rte_cryptodev_queue_pair_setup: num_inflights "
877 "%u on qp %u on cryptodev %u",
878 qp_conf.nb_descriptors, qp_id,
879 ts_params->valid_devs[0]);
882 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
884 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
885 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
886 ts_params->valid_devs[0], qp_id, &qp_conf,
887 rte_cryptodev_socket_id(
888 ts_params->valid_devs[0])),
890 " rte_cryptodev_queue_pair_setup: num_inflights"
891 " %u on qp %u on cryptodev %u",
892 qp_conf.nb_descriptors, qp_id,
893 ts_params->valid_devs[0]);
896 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
898 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
899 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
900 ts_params->valid_devs[0], qp_id, &qp_conf,
901 rte_cryptodev_socket_id(
902 ts_params->valid_devs[0])),
904 "rte_cryptodev_queue_pair_setup: num_inflights"
905 " %u on qp %u on cryptodev %u",
906 qp_conf.nb_descriptors, qp_id,
907 ts_params->valid_devs[0]);
910 /* invalid number of descriptors - max supported + 2 */
911 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
913 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
914 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
915 ts_params->valid_devs[0], qp_id, &qp_conf,
916 rte_cryptodev_socket_id(
917 ts_params->valid_devs[0])),
918 "Unexpectedly passed test for "
919 "rte_cryptodev_queue_pair_setup:"
920 "num_inflights %u on qp %u on cryptodev %u",
921 qp_conf.nb_descriptors, qp_id,
922 ts_params->valid_devs[0]);
925 /* invalid number of descriptors - max value of parameter */
926 qp_conf.nb_descriptors = UINT32_MAX-1;
928 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
929 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
930 ts_params->valid_devs[0], qp_id, &qp_conf,
931 rte_cryptodev_socket_id(
932 ts_params->valid_devs[0])),
933 "Unexpectedly passed test for "
934 "rte_cryptodev_queue_pair_setup:"
935 "num_inflights %u on qp %u on cryptodev %u",
936 qp_conf.nb_descriptors, qp_id,
937 ts_params->valid_devs[0]);
940 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
942 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
943 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
944 ts_params->valid_devs[0], qp_id, &qp_conf,
945 rte_cryptodev_socket_id(
946 ts_params->valid_devs[0])),
948 " rte_cryptodev_queue_pair_setup:"
949 "num_inflights %u on qp %u on cryptodev %u",
950 qp_conf.nb_descriptors, qp_id,
951 ts_params->valid_devs[0]);
954 /* invalid number of descriptors - max supported + 1 */
955 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
957 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
958 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
959 ts_params->valid_devs[0], qp_id, &qp_conf,
960 rte_cryptodev_socket_id(
961 ts_params->valid_devs[0])),
962 "Unexpectedly passed test for "
963 "rte_cryptodev_queue_pair_setup:"
964 "num_inflights %u on qp %u on cryptodev %u",
965 qp_conf.nb_descriptors, qp_id,
966 ts_params->valid_devs[0]);
969 /* test invalid queue pair id */
970 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
972 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
974 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
975 ts_params->valid_devs[0],
977 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
978 "Failed test for rte_cryptodev_queue_pair_setup:"
979 "invalid qp %u on cryptodev %u",
980 qp_id, ts_params->valid_devs[0]);
982 qp_id = 0xffff; /*invalid*/
984 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
985 ts_params->valid_devs[0],
987 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
988 "Failed test for rte_cryptodev_queue_pair_setup:"
989 "invalid qp %u on cryptodev %u",
990 qp_id, ts_params->valid_devs[0]);
995 /* ***** Plaintext data for tests ***** */
997 const char catch_22_quote_1[] =
998 "There was only one catch and that was Catch-22, which "
999 "specified that a concern for one's safety in the face of "
1000 "dangers that were real and immediate was the process of a "
1001 "rational mind. Orr was crazy and could be grounded. All he "
1002 "had to do was ask; and as soon as he did, he would no longer "
1003 "be crazy and would have to fly more missions. Orr would be "
1004 "crazy to fly more missions and sane if he didn't, but if he "
1005 "was sane he had to fly them. If he flew them he was crazy "
1006 "and didn't have to; but if he didn't want to he was sane and "
1007 "had to. Yossarian was moved very deeply by the absolute "
1008 "simplicity of this clause of Catch-22 and let out a "
1009 "respectful whistle. \"That's some catch, that Catch-22\", he "
1010 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1012 const char catch_22_quote[] =
1013 "What a lousy earth! He wondered how many people were "
1014 "destitute that same night even in his own prosperous country, "
1015 "how many homes were shanties, how many husbands were drunk "
1016 "and wives socked, and how many children were bullied, abused, "
1017 "or abandoned. How many families hungered for food they could "
1018 "not afford to buy? How many hearts were broken? How many "
1019 "suicides would take place that same night, how many people "
1020 "would go insane? How many cockroaches and landlords would "
1021 "triumph? How many winners were losers, successes failures, "
1022 "and rich men poor men? How many wise guys were stupid? How "
1023 "many happy endings were unhappy endings? How many honest men "
1024 "were liars, brave men cowards, loyal men traitors, how many "
1025 "sainted men were corrupt, how many people in positions of "
1026 "trust had sold their souls to bodyguards, how many had never "
1027 "had souls? How many straight-and-narrow paths were crooked "
1028 "paths? How many best families were worst families and how "
1029 "many good people were bad people? When you added them all up "
1030 "and then subtracted, you might be left with only the children, "
1031 "and perhaps with Albert Einstein and an old violinist or "
1032 "sculptor somewhere.";
1034 #define QUOTE_480_BYTES (480)
1035 #define QUOTE_512_BYTES (512)
1036 #define QUOTE_768_BYTES (768)
1037 #define QUOTE_1024_BYTES (1024)
1041 /* ***** SHA1 Hash Tests ***** */
1043 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1045 static uint8_t hmac_sha1_key[] = {
1046 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1047 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1048 0xDE, 0xF4, 0xDE, 0xAD };
1050 /* ***** SHA224 Hash Tests ***** */
1052 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1055 /* ***** AES-CBC Cipher Tests ***** */
1057 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1058 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1060 static uint8_t aes_cbc_key[] = {
1061 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1062 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1064 static uint8_t aes_cbc_iv[] = {
1065 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1066 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1069 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1071 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1072 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1073 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1074 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1075 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1076 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1077 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1078 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1079 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1080 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1081 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1082 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1083 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1084 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1085 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1086 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1087 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1088 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1089 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1090 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1091 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1092 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1093 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1096 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1097 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1098 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1099 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1100 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1101 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1102 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1103 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1104 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1105 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1106 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1107 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1108 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1109 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1110 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1111 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1112 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1113 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1114 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1115 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1116 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1117 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1118 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1119 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1120 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1121 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1122 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1123 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1124 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1125 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1126 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1127 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1128 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1129 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1130 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1131 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1132 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1133 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1134 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1135 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1138 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1139 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1140 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1141 0x18, 0x8c, 0x1d, 0x32
1145 /* Multisession Vector context Test */
1146 /*Begin Session 0 */
1147 static uint8_t ms_aes_cbc_key0[] = {
1148 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1152 static uint8_t ms_aes_cbc_iv0[] = {
1153 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1157 static const uint8_t ms_aes_cbc_cipher0[] = {
1158 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1159 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1160 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1161 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1162 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1163 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1164 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1165 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1166 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1167 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1168 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1169 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1170 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1171 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1172 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1173 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1174 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1175 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1176 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1177 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1178 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1179 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1180 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1181 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1182 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1183 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1184 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1185 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1186 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1187 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1188 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1189 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1190 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1191 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1192 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1193 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1194 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1195 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1196 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1197 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1198 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1199 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1200 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1201 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1202 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1203 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1204 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1205 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1206 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1207 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1208 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1209 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1210 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1211 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1212 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1213 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1214 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1215 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1216 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1217 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1218 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1219 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1220 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1221 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1225 static uint8_t ms_hmac_key0[] = {
1226 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest0[] = {
1237 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1238 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1239 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1240 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1241 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1242 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1243 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1244 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1248 /* Begin session 1 */
1250 static uint8_t ms_aes_cbc_key1[] = {
1251 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1252 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1255 static uint8_t ms_aes_cbc_iv1[] = {
1256 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1257 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1260 static const uint8_t ms_aes_cbc_cipher1[] = {
1261 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1262 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1263 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1264 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1265 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1266 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1267 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1268 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1269 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1270 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1271 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1272 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1273 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1274 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1275 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1276 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1277 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1278 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1279 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1280 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1281 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1282 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1283 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1284 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1285 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1286 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1287 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1288 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1289 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1290 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1291 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1292 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1293 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1294 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1295 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1296 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1297 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1298 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1299 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1300 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1301 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1302 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1303 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1304 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1305 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1306 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1307 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1308 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1309 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1310 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1311 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1312 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1313 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1314 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1315 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1316 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1317 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1318 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1319 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1320 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1321 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1322 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1323 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1324 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1328 static uint8_t ms_hmac_key1[] = {
1329 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1330 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1331 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1332 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1333 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1334 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1335 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1336 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1339 static const uint8_t ms_hmac_digest1[] = {
1340 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1341 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1342 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1343 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1344 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1345 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1346 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1347 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1350 /* Begin Session 2 */
1351 static uint8_t ms_aes_cbc_key2[] = {
1352 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1353 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1356 static uint8_t ms_aes_cbc_iv2[] = {
1357 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1358 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1361 static const uint8_t ms_aes_cbc_cipher2[] = {
1362 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1363 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1364 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1365 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1366 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1367 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1368 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1369 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1370 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1371 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1372 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1373 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1374 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1375 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1376 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1377 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1378 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1379 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1380 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1381 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1382 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1383 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1384 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1385 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1386 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1387 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1388 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1389 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1390 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1391 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1392 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1393 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1394 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1395 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1396 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1397 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1398 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1399 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1400 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1401 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1402 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1403 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1404 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1405 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1406 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1407 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1408 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1409 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1410 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1411 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1412 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1413 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1414 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1415 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1416 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1417 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1418 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1419 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1420 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1421 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1422 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1423 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1424 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1425 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1428 static uint8_t ms_hmac_key2[] = {
1429 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1430 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1431 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1432 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1433 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1434 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1435 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1436 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1439 static const uint8_t ms_hmac_digest2[] = {
1440 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1441 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1442 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1443 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1444 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1445 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1446 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1447 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1454 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1456 struct crypto_testsuite_params *ts_params = &testsuite_params;
1457 struct crypto_unittest_params *ut_params = &unittest_params;
1459 /* Verify the capabilities */
1460 struct rte_cryptodev_sym_capability_idx cap_idx;
1461 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1462 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1463 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1466 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1467 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1468 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1472 /* Generate test mbuf data and space for digest */
1473 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1474 catch_22_quote, QUOTE_512_BYTES, 0);
1476 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1477 DIGEST_BYTE_LENGTH_SHA1);
1478 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1480 /* Setup Cipher Parameters */
1481 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1482 ut_params->cipher_xform.next = &ut_params->auth_xform;
1484 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1485 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1486 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1487 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1488 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1489 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1491 /* Setup HMAC Parameters */
1492 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1494 ut_params->auth_xform.next = NULL;
1496 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1497 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1498 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1499 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1500 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1502 ut_params->sess = rte_cryptodev_sym_session_create(
1503 ts_params->session_mpool);
1505 /* Create crypto session*/
1506 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1507 ut_params->sess, &ut_params->cipher_xform,
1508 ts_params->session_priv_mpool);
1509 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1511 /* Generate crypto op data structure */
1512 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1513 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1514 TEST_ASSERT_NOT_NULL(ut_params->op,
1515 "Failed to allocate symmetric crypto operation struct");
1517 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1519 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1521 /* set crypto operation source mbuf */
1522 sym_op->m_src = ut_params->ibuf;
1524 /* Set crypto operation authentication parameters */
1525 sym_op->auth.digest.data = ut_params->digest;
1526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1527 ut_params->ibuf, QUOTE_512_BYTES);
1529 sym_op->auth.data.offset = 0;
1530 sym_op->auth.data.length = QUOTE_512_BYTES;
1532 /* Copy IV at the end of the crypto operation */
1533 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1534 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1536 /* Set crypto operation cipher parameters */
1537 sym_op->cipher.data.offset = 0;
1538 sym_op->cipher.data.length = QUOTE_512_BYTES;
1540 /* Process crypto operation */
1541 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1542 ut_params->op), "failed to process sym crypto op");
1544 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1545 "crypto op processing failed");
1548 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1551 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1552 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1554 "ciphertext data not as expected");
1556 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1558 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1559 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1560 gbl_driver_id == rte_cryptodev_driver_id_get(
1561 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1562 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1563 DIGEST_BYTE_LENGTH_SHA1,
1564 "Generated digest data not as expected");
1566 return TEST_SUCCESS;
1569 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1571 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1573 static uint8_t hmac_sha512_key[] = {
1574 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1575 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1576 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1577 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1578 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1579 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1580 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1581 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1583 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1584 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1585 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1586 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1587 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1588 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1589 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1590 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1591 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1596 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1597 struct crypto_unittest_params *ut_params,
1598 uint8_t *cipher_key,
1602 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1603 struct crypto_unittest_params *ut_params,
1604 struct crypto_testsuite_params *ts_params,
1605 const uint8_t *cipher,
1606 const uint8_t *digest,
1611 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1612 struct crypto_unittest_params *ut_params,
1613 uint8_t *cipher_key,
1617 /* Setup Cipher Parameters */
1618 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1619 ut_params->cipher_xform.next = NULL;
1621 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1622 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1623 ut_params->cipher_xform.cipher.key.data = cipher_key;
1624 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1625 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1626 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1628 /* Setup HMAC Parameters */
1629 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1630 ut_params->auth_xform.next = &ut_params->cipher_xform;
1632 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1633 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1634 ut_params->auth_xform.auth.key.data = hmac_key;
1635 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1636 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1638 return TEST_SUCCESS;
1643 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1644 struct crypto_unittest_params *ut_params,
1645 struct crypto_testsuite_params *ts_params,
1646 const uint8_t *cipher,
1647 const uint8_t *digest,
1650 /* Generate test mbuf data and digest */
1651 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1654 QUOTE_512_BYTES, 0);
1656 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1657 DIGEST_BYTE_LENGTH_SHA512);
1658 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1660 rte_memcpy(ut_params->digest,
1662 DIGEST_BYTE_LENGTH_SHA512);
1664 /* Generate Crypto op data structure */
1665 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1666 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1667 TEST_ASSERT_NOT_NULL(ut_params->op,
1668 "Failed to allocate symmetric crypto operation struct");
1670 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1672 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1674 /* set crypto operation source mbuf */
1675 sym_op->m_src = ut_params->ibuf;
1677 sym_op->auth.digest.data = ut_params->digest;
1678 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1679 ut_params->ibuf, QUOTE_512_BYTES);
1681 sym_op->auth.data.offset = 0;
1682 sym_op->auth.data.length = QUOTE_512_BYTES;
1684 /* Copy IV at the end of the crypto operation */
1685 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1686 iv, CIPHER_IV_LENGTH_AES_CBC);
1688 sym_op->cipher.data.offset = 0;
1689 sym_op->cipher.data.length = QUOTE_512_BYTES;
1691 /* Process crypto operation */
1692 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1693 ut_params->op), "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],
1727 if (status == -ENOTSUP)
1730 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1732 return TEST_SUCCESS;
1736 test_AES_cipheronly_all(void)
1738 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1742 test_AES_docsis_all(void)
1744 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1748 test_DES_docsis_all(void)
1750 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1754 test_DES_cipheronly_all(void)
1756 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1760 test_authonly_all(void)
1762 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1766 test_AES_chain_all(void)
1768 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1772 test_3DES_chain_all(void)
1774 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1778 test_3DES_cipheronly_all(void)
1780 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1783 /* ***** SNOW 3G Tests ***** */
1785 create_wireless_algo_hash_session(uint8_t dev_id,
1786 const uint8_t *key, const uint8_t key_len,
1787 const uint8_t iv_len, const uint8_t auth_len,
1788 enum rte_crypto_auth_operation op,
1789 enum rte_crypto_auth_algorithm algo)
1791 uint8_t hash_key[key_len];
1794 struct crypto_testsuite_params *ts_params = &testsuite_params;
1795 struct crypto_unittest_params *ut_params = &unittest_params;
1797 memcpy(hash_key, key, key_len);
1799 debug_hexdump(stdout, "key:", key, key_len);
1801 /* Setup Authentication Parameters */
1802 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1803 ut_params->auth_xform.next = NULL;
1805 ut_params->auth_xform.auth.op = op;
1806 ut_params->auth_xform.auth.algo = algo;
1807 ut_params->auth_xform.auth.key.length = key_len;
1808 ut_params->auth_xform.auth.key.data = hash_key;
1809 ut_params->auth_xform.auth.digest_length = auth_len;
1810 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1811 ut_params->auth_xform.auth.iv.length = iv_len;
1812 ut_params->sess = rte_cryptodev_sym_session_create(
1813 ts_params->session_mpool);
1815 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1816 &ut_params->auth_xform,
1817 ts_params->session_priv_mpool);
1818 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1819 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1824 create_wireless_algo_cipher_session(uint8_t dev_id,
1825 enum rte_crypto_cipher_operation op,
1826 enum rte_crypto_cipher_algorithm algo,
1827 const uint8_t *key, const uint8_t key_len,
1830 uint8_t cipher_key[key_len];
1832 struct crypto_testsuite_params *ts_params = &testsuite_params;
1833 struct crypto_unittest_params *ut_params = &unittest_params;
1835 memcpy(cipher_key, key, key_len);
1837 /* Setup Cipher Parameters */
1838 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1839 ut_params->cipher_xform.next = NULL;
1841 ut_params->cipher_xform.cipher.algo = algo;
1842 ut_params->cipher_xform.cipher.op = op;
1843 ut_params->cipher_xform.cipher.key.data = cipher_key;
1844 ut_params->cipher_xform.cipher.key.length = key_len;
1845 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1846 ut_params->cipher_xform.cipher.iv.length = iv_len;
1848 debug_hexdump(stdout, "key:", key, key_len);
1850 /* Create Crypto session */
1851 ut_params->sess = rte_cryptodev_sym_session_create(
1852 ts_params->session_mpool);
1854 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1855 &ut_params->cipher_xform,
1856 ts_params->session_priv_mpool);
1857 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1858 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1863 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1864 unsigned int cipher_len,
1865 unsigned int cipher_offset)
1867 struct crypto_testsuite_params *ts_params = &testsuite_params;
1868 struct crypto_unittest_params *ut_params = &unittest_params;
1870 /* Generate Crypto op data structure */
1871 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1872 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1873 TEST_ASSERT_NOT_NULL(ut_params->op,
1874 "Failed to allocate pktmbuf offload");
1876 /* Set crypto operation data parameters */
1877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1881 /* set crypto operation source mbuf */
1882 sym_op->m_src = ut_params->ibuf;
1885 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1887 sym_op->cipher.data.length = cipher_len;
1888 sym_op->cipher.data.offset = cipher_offset;
1893 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1894 unsigned int cipher_len,
1895 unsigned int cipher_offset)
1897 struct crypto_testsuite_params *ts_params = &testsuite_params;
1898 struct crypto_unittest_params *ut_params = &unittest_params;
1900 /* Generate Crypto op data structure */
1901 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1902 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1903 TEST_ASSERT_NOT_NULL(ut_params->op,
1904 "Failed to allocate pktmbuf offload");
1906 /* Set crypto operation data parameters */
1907 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1909 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1911 /* set crypto operation source mbuf */
1912 sym_op->m_src = ut_params->ibuf;
1913 sym_op->m_dst = ut_params->obuf;
1916 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1918 sym_op->cipher.data.length = cipher_len;
1919 sym_op->cipher.data.offset = cipher_offset;
1924 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1925 enum rte_crypto_cipher_operation cipher_op,
1926 enum rte_crypto_auth_operation auth_op,
1927 enum rte_crypto_auth_algorithm auth_algo,
1928 enum rte_crypto_cipher_algorithm cipher_algo,
1929 const uint8_t *key, uint8_t key_len,
1930 uint8_t auth_iv_len, uint8_t auth_len,
1931 uint8_t cipher_iv_len)
1934 uint8_t cipher_auth_key[key_len];
1937 struct crypto_testsuite_params *ts_params = &testsuite_params;
1938 struct crypto_unittest_params *ut_params = &unittest_params;
1940 memcpy(cipher_auth_key, key, key_len);
1942 /* Setup Authentication Parameters */
1943 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1944 ut_params->auth_xform.next = NULL;
1946 ut_params->auth_xform.auth.op = auth_op;
1947 ut_params->auth_xform.auth.algo = auth_algo;
1948 ut_params->auth_xform.auth.key.length = key_len;
1949 /* Hash key = cipher key */
1950 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1951 ut_params->auth_xform.auth.digest_length = auth_len;
1952 /* Auth IV will be after cipher IV */
1953 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1954 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1956 /* Setup Cipher Parameters */
1957 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1958 ut_params->cipher_xform.next = &ut_params->auth_xform;
1960 ut_params->cipher_xform.cipher.algo = cipher_algo;
1961 ut_params->cipher_xform.cipher.op = cipher_op;
1962 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1963 ut_params->cipher_xform.cipher.key.length = key_len;
1964 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1965 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1967 debug_hexdump(stdout, "key:", key, key_len);
1969 /* Create Crypto session*/
1970 ut_params->sess = rte_cryptodev_sym_session_create(
1971 ts_params->session_mpool);
1972 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1974 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1975 &ut_params->cipher_xform,
1976 ts_params->session_priv_mpool);
1977 if (status == -ENOTSUP)
1980 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1985 create_wireless_cipher_auth_session(uint8_t dev_id,
1986 enum rte_crypto_cipher_operation cipher_op,
1987 enum rte_crypto_auth_operation auth_op,
1988 enum rte_crypto_auth_algorithm auth_algo,
1989 enum rte_crypto_cipher_algorithm cipher_algo,
1990 const struct wireless_test_data *tdata)
1992 const uint8_t key_len = tdata->key.len;
1993 uint8_t cipher_auth_key[key_len];
1996 struct crypto_testsuite_params *ts_params = &testsuite_params;
1997 struct crypto_unittest_params *ut_params = &unittest_params;
1998 const uint8_t *key = tdata->key.data;
1999 const uint8_t auth_len = tdata->digest.len;
2000 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2001 uint8_t auth_iv_len = tdata->auth_iv.len;
2003 memcpy(cipher_auth_key, key, key_len);
2005 /* Setup Authentication Parameters */
2006 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2007 ut_params->auth_xform.next = NULL;
2009 ut_params->auth_xform.auth.op = auth_op;
2010 ut_params->auth_xform.auth.algo = auth_algo;
2011 ut_params->auth_xform.auth.key.length = key_len;
2012 /* Hash key = cipher key */
2013 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2014 ut_params->auth_xform.auth.digest_length = auth_len;
2015 /* Auth IV will be after cipher IV */
2016 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2017 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2019 /* Setup Cipher Parameters */
2020 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2021 ut_params->cipher_xform.next = &ut_params->auth_xform;
2023 ut_params->cipher_xform.cipher.algo = cipher_algo;
2024 ut_params->cipher_xform.cipher.op = cipher_op;
2025 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2026 ut_params->cipher_xform.cipher.key.length = key_len;
2027 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2028 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2031 debug_hexdump(stdout, "key:", key, key_len);
2033 /* Create Crypto session*/
2034 ut_params->sess = rte_cryptodev_sym_session_create(
2035 ts_params->session_mpool);
2037 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2038 &ut_params->cipher_xform,
2039 ts_params->session_priv_mpool);
2041 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2042 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2047 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2048 const struct wireless_test_data *tdata)
2050 return create_wireless_cipher_auth_session(dev_id,
2051 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2052 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2053 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2057 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2058 enum rte_crypto_cipher_operation cipher_op,
2059 enum rte_crypto_auth_operation auth_op,
2060 enum rte_crypto_auth_algorithm auth_algo,
2061 enum rte_crypto_cipher_algorithm cipher_algo,
2062 const uint8_t *key, const uint8_t key_len,
2063 uint8_t auth_iv_len, uint8_t auth_len,
2064 uint8_t cipher_iv_len)
2066 uint8_t auth_cipher_key[key_len];
2068 struct crypto_testsuite_params *ts_params = &testsuite_params;
2069 struct crypto_unittest_params *ut_params = &unittest_params;
2071 memcpy(auth_cipher_key, key, key_len);
2073 /* Setup Authentication Parameters */
2074 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2075 ut_params->auth_xform.auth.op = auth_op;
2076 ut_params->auth_xform.next = &ut_params->cipher_xform;
2077 ut_params->auth_xform.auth.algo = auth_algo;
2078 ut_params->auth_xform.auth.key.length = key_len;
2079 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2080 ut_params->auth_xform.auth.digest_length = auth_len;
2081 /* Auth IV will be after cipher IV */
2082 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2083 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2085 /* Setup Cipher Parameters */
2086 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2087 ut_params->cipher_xform.next = NULL;
2088 ut_params->cipher_xform.cipher.algo = cipher_algo;
2089 ut_params->cipher_xform.cipher.op = cipher_op;
2090 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2091 ut_params->cipher_xform.cipher.key.length = key_len;
2092 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2093 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2095 debug_hexdump(stdout, "key:", key, key_len);
2097 /* Create Crypto session*/
2098 ut_params->sess = rte_cryptodev_sym_session_create(
2099 ts_params->session_mpool);
2100 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2102 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2103 ut_params->auth_xform.next = NULL;
2104 ut_params->cipher_xform.next = &ut_params->auth_xform;
2105 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2106 &ut_params->cipher_xform,
2107 ts_params->session_priv_mpool);
2110 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2111 &ut_params->auth_xform,
2112 ts_params->session_priv_mpool);
2114 if (status == -ENOTSUP)
2117 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2123 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2124 unsigned int auth_tag_len,
2125 const uint8_t *iv, unsigned int iv_len,
2126 unsigned int data_pad_len,
2127 enum rte_crypto_auth_operation op,
2128 unsigned int auth_len, unsigned int auth_offset)
2130 struct crypto_testsuite_params *ts_params = &testsuite_params;
2132 struct crypto_unittest_params *ut_params = &unittest_params;
2134 /* Generate Crypto op data structure */
2135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2137 TEST_ASSERT_NOT_NULL(ut_params->op,
2138 "Failed to allocate pktmbuf offload");
2140 /* Set crypto operation data parameters */
2141 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2143 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2145 /* set crypto operation source mbuf */
2146 sym_op->m_src = ut_params->ibuf;
2149 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2152 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2153 ut_params->ibuf, auth_tag_len);
2155 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2156 "no room to append auth tag");
2157 ut_params->digest = sym_op->auth.digest.data;
2158 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2159 ut_params->ibuf, data_pad_len);
2160 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2161 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2163 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2165 debug_hexdump(stdout, "digest:",
2166 sym_op->auth.digest.data,
2169 sym_op->auth.data.length = auth_len;
2170 sym_op->auth.data.offset = auth_offset;
2176 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2177 enum rte_crypto_auth_operation op)
2179 struct crypto_testsuite_params *ts_params = &testsuite_params;
2180 struct crypto_unittest_params *ut_params = &unittest_params;
2182 const uint8_t *auth_tag = tdata->digest.data;
2183 const unsigned int auth_tag_len = tdata->digest.len;
2184 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2185 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2187 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2188 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2189 const uint8_t *auth_iv = tdata->auth_iv.data;
2190 const uint8_t auth_iv_len = tdata->auth_iv.len;
2191 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2192 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2194 /* Generate Crypto op data structure */
2195 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2196 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2197 TEST_ASSERT_NOT_NULL(ut_params->op,
2198 "Failed to allocate pktmbuf offload");
2199 /* Set crypto operation data parameters */
2200 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2202 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2204 /* set crypto operation source mbuf */
2205 sym_op->m_src = ut_params->ibuf;
2208 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2209 ut_params->ibuf, auth_tag_len);
2211 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2212 "no room to append auth tag");
2213 ut_params->digest = sym_op->auth.digest.data;
2214 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2215 ut_params->ibuf, data_pad_len);
2216 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2217 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2219 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2221 debug_hexdump(stdout, "digest:",
2222 sym_op->auth.digest.data,
2225 /* Copy cipher and auth IVs at the end of the crypto operation */
2226 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2228 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2229 iv_ptr += cipher_iv_len;
2230 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2232 sym_op->cipher.data.length = cipher_len;
2233 sym_op->cipher.data.offset = 0;
2234 sym_op->auth.data.length = auth_len;
2235 sym_op->auth.data.offset = 0;
2241 create_zuc_cipher_hash_generate_operation(
2242 const struct wireless_test_data *tdata)
2244 return create_wireless_cipher_hash_operation(tdata,
2245 RTE_CRYPTO_AUTH_OP_GENERATE);
2249 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2250 const unsigned auth_tag_len,
2251 const uint8_t *auth_iv, uint8_t auth_iv_len,
2252 unsigned data_pad_len,
2253 enum rte_crypto_auth_operation op,
2254 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2255 const unsigned cipher_len, const unsigned cipher_offset,
2256 const unsigned auth_len, const unsigned auth_offset)
2258 struct crypto_testsuite_params *ts_params = &testsuite_params;
2259 struct crypto_unittest_params *ut_params = &unittest_params;
2261 enum rte_crypto_cipher_algorithm cipher_algo =
2262 ut_params->cipher_xform.cipher.algo;
2263 enum rte_crypto_auth_algorithm auth_algo =
2264 ut_params->auth_xform.auth.algo;
2266 /* Generate Crypto op data structure */
2267 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2268 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2269 TEST_ASSERT_NOT_NULL(ut_params->op,
2270 "Failed to allocate pktmbuf offload");
2271 /* Set crypto operation data parameters */
2272 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2274 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2276 /* set crypto operation source mbuf */
2277 sym_op->m_src = ut_params->ibuf;
2280 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2281 ut_params->ibuf, auth_tag_len);
2283 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2284 "no room to append auth tag");
2285 ut_params->digest = sym_op->auth.digest.data;
2287 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2288 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2289 ut_params->ibuf, data_pad_len);
2291 struct rte_mbuf *m = ut_params->ibuf;
2292 unsigned int offset = data_pad_len;
2294 while (offset > m->data_len && m->next != NULL) {
2295 offset -= m->data_len;
2298 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2302 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2303 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2305 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2307 debug_hexdump(stdout, "digest:",
2308 sym_op->auth.digest.data,
2311 /* Copy cipher and auth IVs at the end of the crypto operation */
2312 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2314 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2315 iv_ptr += cipher_iv_len;
2316 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2318 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2319 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2320 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2321 sym_op->cipher.data.length = cipher_len;
2322 sym_op->cipher.data.offset = cipher_offset;
2324 sym_op->cipher.data.length = cipher_len >> 3;
2325 sym_op->cipher.data.offset = cipher_offset >> 3;
2328 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2329 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2330 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2331 sym_op->auth.data.length = auth_len;
2332 sym_op->auth.data.offset = auth_offset;
2334 sym_op->auth.data.length = auth_len >> 3;
2335 sym_op->auth.data.offset = auth_offset >> 3;
2342 create_wireless_algo_auth_cipher_operation(
2343 const uint8_t *auth_tag, unsigned int auth_tag_len,
2344 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2345 const uint8_t *auth_iv, uint8_t auth_iv_len,
2346 unsigned int data_pad_len,
2347 unsigned int cipher_len, unsigned int cipher_offset,
2348 unsigned int auth_len, unsigned int auth_offset,
2349 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2351 struct crypto_testsuite_params *ts_params = &testsuite_params;
2352 struct crypto_unittest_params *ut_params = &unittest_params;
2354 enum rte_crypto_cipher_algorithm cipher_algo =
2355 ut_params->cipher_xform.cipher.algo;
2356 enum rte_crypto_auth_algorithm auth_algo =
2357 ut_params->auth_xform.auth.algo;
2359 /* Generate Crypto op data structure */
2360 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2361 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2362 TEST_ASSERT_NOT_NULL(ut_params->op,
2363 "Failed to allocate pktmbuf offload");
2365 /* Set crypto operation data parameters */
2366 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2368 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2370 /* set crypto operation mbufs */
2371 sym_op->m_src = ut_params->ibuf;
2372 if (op_mode == OUT_OF_PLACE)
2373 sym_op->m_dst = ut_params->obuf;
2377 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2378 (op_mode == IN_PLACE ?
2379 ut_params->ibuf : ut_params->obuf),
2380 uint8_t *, data_pad_len);
2381 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2382 (op_mode == IN_PLACE ?
2383 ut_params->ibuf : ut_params->obuf),
2385 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2387 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2388 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2389 sym_op->m_src : sym_op->m_dst);
2390 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2391 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2392 sgl_buf = sgl_buf->next;
2394 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2395 uint8_t *, remaining_off);
2396 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2398 memset(sym_op->auth.digest.data, 0, remaining_off);
2399 while (sgl_buf->next != NULL) {
2400 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2401 0, rte_pktmbuf_data_len(sgl_buf));
2402 sgl_buf = sgl_buf->next;
2406 /* Copy digest for the verification */
2408 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2410 /* Copy cipher and auth IVs at the end of the crypto operation */
2411 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2412 ut_params->op, uint8_t *, IV_OFFSET);
2414 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2415 iv_ptr += cipher_iv_len;
2416 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2418 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2419 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2420 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2421 sym_op->cipher.data.length = cipher_len;
2422 sym_op->cipher.data.offset = cipher_offset;
2424 sym_op->cipher.data.length = cipher_len >> 3;
2425 sym_op->cipher.data.offset = cipher_offset >> 3;
2428 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2429 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2430 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2431 sym_op->auth.data.length = auth_len;
2432 sym_op->auth.data.offset = auth_offset;
2434 sym_op->auth.data.length = auth_len >> 3;
2435 sym_op->auth.data.offset = auth_offset >> 3;
2442 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2444 struct crypto_testsuite_params *ts_params = &testsuite_params;
2445 struct crypto_unittest_params *ut_params = &unittest_params;
2448 unsigned plaintext_pad_len;
2449 unsigned plaintext_len;
2452 /* QAT PMD supports byte-aligned data only */
2453 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2454 (gbl_driver_id == rte_cryptodev_driver_id_get(
2455 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2458 /* Verify the capabilities */
2459 struct rte_cryptodev_sym_capability_idx cap_idx;
2460 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2461 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2462 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2466 /* Create SNOW 3G session */
2467 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2468 tdata->key.data, tdata->key.len,
2469 tdata->auth_iv.len, tdata->digest.len,
2470 RTE_CRYPTO_AUTH_OP_GENERATE,
2471 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2475 /* alloc mbuf and set payload */
2476 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2479 rte_pktmbuf_tailroom(ut_params->ibuf));
2481 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2482 /* Append data which is padded to a multiple of */
2483 /* the algorithms block size */
2484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2489 /* Create SNOW 3G operation */
2490 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2491 tdata->auth_iv.data, tdata->auth_iv.len,
2492 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2493 tdata->validAuthLenInBits.len,
2498 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2500 ut_params->obuf = ut_params->op->sym->m_src;
2501 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2502 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2503 + plaintext_pad_len;
2506 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2509 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2510 "SNOW 3G Generated auth tag not as expected");
2516 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2518 struct crypto_testsuite_params *ts_params = &testsuite_params;
2519 struct crypto_unittest_params *ut_params = &unittest_params;
2522 unsigned plaintext_pad_len;
2523 unsigned plaintext_len;
2526 /* QAT PMD supports byte-aligned data only */
2527 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
2528 (gbl_driver_id == rte_cryptodev_driver_id_get(
2529 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
2532 /* Verify the capabilities */
2533 struct rte_cryptodev_sym_capability_idx cap_idx;
2534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2540 /* Create SNOW 3G session */
2541 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2542 tdata->key.data, tdata->key.len,
2543 tdata->auth_iv.len, tdata->digest.len,
2544 RTE_CRYPTO_AUTH_OP_VERIFY,
2545 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2548 /* alloc mbuf and set payload */
2549 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2551 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2552 rte_pktmbuf_tailroom(ut_params->ibuf));
2554 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2555 /* Append data which is padded to a multiple of */
2556 /* the algorithms block size */
2557 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2558 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2560 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2562 /* Create SNOW 3G operation */
2563 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2565 tdata->auth_iv.data, tdata->auth_iv.len,
2567 RTE_CRYPTO_AUTH_OP_VERIFY,
2568 tdata->validAuthLenInBits.len,
2573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2575 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2576 ut_params->obuf = ut_params->op->sym->m_src;
2577 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2578 + plaintext_pad_len;
2581 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2590 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2592 struct crypto_testsuite_params *ts_params = &testsuite_params;
2593 struct crypto_unittest_params *ut_params = &unittest_params;
2596 unsigned plaintext_pad_len;
2597 unsigned plaintext_len;
2600 /* Verify the capabilities */
2601 struct rte_cryptodev_sym_capability_idx cap_idx;
2602 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2603 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2604 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2608 /* Create KASUMI session */
2609 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2610 tdata->key.data, tdata->key.len,
2611 0, tdata->digest.len,
2612 RTE_CRYPTO_AUTH_OP_GENERATE,
2613 RTE_CRYPTO_AUTH_KASUMI_F9);
2617 /* alloc mbuf and set payload */
2618 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2621 rte_pktmbuf_tailroom(ut_params->ibuf));
2623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2624 /* Append data which is padded to a multiple of */
2625 /* the algorithms block size */
2626 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2629 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2631 /* Create KASUMI operation */
2632 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2634 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2635 tdata->plaintext.len,
2640 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2642 ut_params->obuf = ut_params->op->sym->m_src;
2643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2644 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2645 + plaintext_pad_len;
2648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2651 DIGEST_BYTE_LENGTH_KASUMI_F9,
2652 "KASUMI Generated auth tag not as expected");
2658 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2660 struct crypto_testsuite_params *ts_params = &testsuite_params;
2661 struct crypto_unittest_params *ut_params = &unittest_params;
2664 unsigned plaintext_pad_len;
2665 unsigned plaintext_len;
2668 /* Verify the capabilities */
2669 struct rte_cryptodev_sym_capability_idx cap_idx;
2670 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2671 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2672 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2676 /* Create KASUMI session */
2677 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2678 tdata->key.data, tdata->key.len,
2679 0, tdata->digest.len,
2680 RTE_CRYPTO_AUTH_OP_VERIFY,
2681 RTE_CRYPTO_AUTH_KASUMI_F9);
2684 /* alloc mbuf and set payload */
2685 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2688 rte_pktmbuf_tailroom(ut_params->ibuf));
2690 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2691 /* Append data which is padded to a multiple */
2692 /* of the algorithms block size */
2693 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2696 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2698 /* Create KASUMI operation */
2699 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2703 RTE_CRYPTO_AUTH_OP_VERIFY,
2704 tdata->plaintext.len,
2709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2711 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2712 ut_params->obuf = ut_params->op->sym->m_src;
2713 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2714 + plaintext_pad_len;
2717 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2726 test_snow3g_hash_generate_test_case_1(void)
2728 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2732 test_snow3g_hash_generate_test_case_2(void)
2734 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2738 test_snow3g_hash_generate_test_case_3(void)
2740 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2744 test_snow3g_hash_generate_test_case_4(void)
2746 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2750 test_snow3g_hash_generate_test_case_5(void)
2752 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2756 test_snow3g_hash_generate_test_case_6(void)
2758 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2762 test_snow3g_hash_verify_test_case_1(void)
2764 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2769 test_snow3g_hash_verify_test_case_2(void)
2771 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2775 test_snow3g_hash_verify_test_case_3(void)
2777 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2781 test_snow3g_hash_verify_test_case_4(void)
2783 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2787 test_snow3g_hash_verify_test_case_5(void)
2789 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2793 test_snow3g_hash_verify_test_case_6(void)
2795 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2799 test_kasumi_hash_generate_test_case_1(void)
2801 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2805 test_kasumi_hash_generate_test_case_2(void)
2807 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2811 test_kasumi_hash_generate_test_case_3(void)
2813 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2817 test_kasumi_hash_generate_test_case_4(void)
2819 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2823 test_kasumi_hash_generate_test_case_5(void)
2825 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2829 test_kasumi_hash_generate_test_case_6(void)
2831 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2835 test_kasumi_hash_verify_test_case_1(void)
2837 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2841 test_kasumi_hash_verify_test_case_2(void)
2843 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2847 test_kasumi_hash_verify_test_case_3(void)
2849 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2853 test_kasumi_hash_verify_test_case_4(void)
2855 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2859 test_kasumi_hash_verify_test_case_5(void)
2861 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2865 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2867 struct crypto_testsuite_params *ts_params = &testsuite_params;
2868 struct crypto_unittest_params *ut_params = &unittest_params;
2871 uint8_t *plaintext, *ciphertext;
2872 unsigned plaintext_pad_len;
2873 unsigned plaintext_len;
2875 /* Verify the capabilities */
2876 struct rte_cryptodev_sym_capability_idx cap_idx;
2877 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2878 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2879 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2883 /* Create KASUMI session */
2884 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2885 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2886 RTE_CRYPTO_CIPHER_KASUMI_F8,
2887 tdata->key.data, tdata->key.len,
2888 tdata->cipher_iv.len);
2892 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2894 /* Clear mbuf payload */
2895 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2896 rte_pktmbuf_tailroom(ut_params->ibuf));
2898 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2899 /* Append data which is padded to a multiple */
2900 /* of the algorithms block size */
2901 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2902 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2904 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2906 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2908 /* Create KASUMI operation */
2909 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2910 tdata->cipher_iv.len,
2911 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2912 tdata->validCipherOffsetInBits.len);
2916 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2918 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2920 ut_params->obuf = ut_params->op->sym->m_dst;
2921 if (ut_params->obuf)
2922 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2924 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2926 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2928 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2929 (tdata->validCipherOffsetInBits.len >> 3);
2931 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2933 reference_ciphertext,
2934 tdata->validCipherLenInBits.len,
2935 "KASUMI Ciphertext data not as expected");
2940 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2942 struct crypto_testsuite_params *ts_params = &testsuite_params;
2943 struct crypto_unittest_params *ut_params = &unittest_params;
2947 unsigned int plaintext_pad_len;
2948 unsigned int plaintext_len;
2950 uint8_t buffer[10000];
2951 const uint8_t *ciphertext;
2953 struct rte_cryptodev_info dev_info;
2955 /* Verify the capabilities */
2956 struct rte_cryptodev_sym_capability_idx cap_idx;
2957 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2958 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2959 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2963 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2965 uint64_t feat_flags = dev_info.feature_flags;
2967 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2968 printf("Device doesn't support in-place scatter-gather. "
2973 /* Create KASUMI session */
2974 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2975 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2976 RTE_CRYPTO_CIPHER_KASUMI_F8,
2977 tdata->key.data, tdata->key.len,
2978 tdata->cipher_iv.len);
2982 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2985 /* Append data which is padded to a multiple */
2986 /* of the algorithms block size */
2987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2989 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2990 plaintext_pad_len, 10, 0);
2992 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2994 /* Create KASUMI operation */
2995 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2996 tdata->cipher_iv.len,
2997 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2998 tdata->validCipherOffsetInBits.len);
3002 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3004 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3006 ut_params->obuf = ut_params->op->sym->m_dst;
3008 if (ut_params->obuf)
3009 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3010 plaintext_len, buffer);
3012 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3013 tdata->validCipherOffsetInBits.len >> 3,
3014 plaintext_len, buffer);
3017 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3019 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3020 (tdata->validCipherOffsetInBits.len >> 3);
3022 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3024 reference_ciphertext,
3025 tdata->validCipherLenInBits.len,
3026 "KASUMI Ciphertext data not as expected");
3031 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3033 struct crypto_testsuite_params *ts_params = &testsuite_params;
3034 struct crypto_unittest_params *ut_params = &unittest_params;
3037 uint8_t *plaintext, *ciphertext;
3038 unsigned plaintext_pad_len;
3039 unsigned plaintext_len;
3041 /* Verify the capabilities */
3042 struct rte_cryptodev_sym_capability_idx cap_idx;
3043 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3044 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3045 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3049 /* Create KASUMI session */
3050 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3051 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3052 RTE_CRYPTO_CIPHER_KASUMI_F8,
3053 tdata->key.data, tdata->key.len,
3054 tdata->cipher_iv.len);
3058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3059 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3061 /* Clear mbuf payload */
3062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3063 rte_pktmbuf_tailroom(ut_params->ibuf));
3065 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3066 /* Append data which is padded to a multiple */
3067 /* of the algorithms block size */
3068 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3069 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3071 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3072 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3074 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3076 /* Create KASUMI operation */
3077 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3078 tdata->cipher_iv.len,
3079 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3080 tdata->validCipherOffsetInBits.len);
3084 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3086 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3088 ut_params->obuf = ut_params->op->sym->m_dst;
3089 if (ut_params->obuf)
3090 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3092 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3094 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3096 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3097 (tdata->validCipherOffsetInBits.len >> 3);
3099 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3101 reference_ciphertext,
3102 tdata->validCipherLenInBits.len,
3103 "KASUMI Ciphertext data not as expected");
3108 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3110 struct crypto_testsuite_params *ts_params = &testsuite_params;
3111 struct crypto_unittest_params *ut_params = &unittest_params;
3114 unsigned int plaintext_pad_len;
3115 unsigned int plaintext_len;
3117 const uint8_t *ciphertext;
3118 uint8_t buffer[2048];
3120 struct rte_cryptodev_info dev_info;
3122 /* Verify the capabilities */
3123 struct rte_cryptodev_sym_capability_idx cap_idx;
3124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3125 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3130 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3132 uint64_t feat_flags = dev_info.feature_flags;
3133 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3134 printf("Device doesn't support out-of-place scatter-gather "
3135 "in both input and output mbufs. "
3140 /* Create KASUMI session */
3141 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3142 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3143 RTE_CRYPTO_CIPHER_KASUMI_F8,
3144 tdata->key.data, tdata->key.len,
3145 tdata->cipher_iv.len);
3149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3150 /* Append data which is padded to a multiple */
3151 /* of the algorithms block size */
3152 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3154 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3155 plaintext_pad_len, 10, 0);
3156 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3157 plaintext_pad_len, 3, 0);
3159 /* Append data which is padded to a multiple */
3160 /* of the algorithms block size */
3161 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3163 /* Create KASUMI operation */
3164 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3165 tdata->cipher_iv.len,
3166 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3167 tdata->validCipherOffsetInBits.len);
3171 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3173 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3175 ut_params->obuf = ut_params->op->sym->m_dst;
3176 if (ut_params->obuf)
3177 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3178 plaintext_pad_len, buffer);
3180 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3181 tdata->validCipherOffsetInBits.len >> 3,
3182 plaintext_pad_len, buffer);
3184 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3185 (tdata->validCipherOffsetInBits.len >> 3);
3187 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3189 reference_ciphertext,
3190 tdata->validCipherLenInBits.len,
3191 "KASUMI Ciphertext data not as expected");
3197 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3199 struct crypto_testsuite_params *ts_params = &testsuite_params;
3200 struct crypto_unittest_params *ut_params = &unittest_params;
3203 uint8_t *ciphertext, *plaintext;
3204 unsigned ciphertext_pad_len;
3205 unsigned ciphertext_len;
3207 /* Verify the capabilities */
3208 struct rte_cryptodev_sym_capability_idx cap_idx;
3209 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3210 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3211 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3215 /* Create KASUMI session */
3216 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3217 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3218 RTE_CRYPTO_CIPHER_KASUMI_F8,
3219 tdata->key.data, tdata->key.len,
3220 tdata->cipher_iv.len);
3224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3225 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3227 /* Clear mbuf payload */
3228 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3229 rte_pktmbuf_tailroom(ut_params->ibuf));
3231 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3232 /* Append data which is padded to a multiple */
3233 /* of the algorithms block size */
3234 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3235 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3236 ciphertext_pad_len);
3237 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3238 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3240 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3242 /* Create KASUMI operation */
3243 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3244 tdata->cipher_iv.len,
3245 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3246 tdata->validCipherOffsetInBits.len);
3250 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3252 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3254 ut_params->obuf = ut_params->op->sym->m_dst;
3255 if (ut_params->obuf)
3256 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3258 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3260 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3262 const uint8_t *reference_plaintext = tdata->plaintext.data +
3263 (tdata->validCipherOffsetInBits.len >> 3);
3265 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3267 reference_plaintext,
3268 tdata->validCipherLenInBits.len,
3269 "KASUMI Plaintext data not as expected");
3274 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3276 struct crypto_testsuite_params *ts_params = &testsuite_params;
3277 struct crypto_unittest_params *ut_params = &unittest_params;
3280 uint8_t *ciphertext, *plaintext;
3281 unsigned ciphertext_pad_len;
3282 unsigned ciphertext_len;
3284 /* Verify the capabilities */
3285 struct rte_cryptodev_sym_capability_idx cap_idx;
3286 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3287 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3288 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3292 /* Create KASUMI session */
3293 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3294 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3295 RTE_CRYPTO_CIPHER_KASUMI_F8,
3296 tdata->key.data, tdata->key.len,
3297 tdata->cipher_iv.len);
3301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3303 /* Clear mbuf payload */
3304 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3305 rte_pktmbuf_tailroom(ut_params->ibuf));
3307 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3308 /* Append data which is padded to a multiple */
3309 /* of the algorithms block size */
3310 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3311 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3312 ciphertext_pad_len);
3313 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3315 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3317 /* Create KASUMI operation */
3318 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3319 tdata->cipher_iv.len,
3320 tdata->ciphertext.len,
3321 tdata->validCipherOffsetInBits.len);
3325 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3327 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3329 ut_params->obuf = ut_params->op->sym->m_dst;
3330 if (ut_params->obuf)
3331 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3333 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3335 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3337 const uint8_t *reference_plaintext = tdata->plaintext.data +
3338 (tdata->validCipherOffsetInBits.len >> 3);
3340 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3342 reference_plaintext,
3343 tdata->validCipherLenInBits.len,
3344 "KASUMI Plaintext data not as expected");
3349 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3351 struct crypto_testsuite_params *ts_params = &testsuite_params;
3352 struct crypto_unittest_params *ut_params = &unittest_params;
3355 uint8_t *plaintext, *ciphertext;
3356 unsigned plaintext_pad_len;
3357 unsigned plaintext_len;
3359 /* Verify the capabilities */
3360 struct rte_cryptodev_sym_capability_idx cap_idx;
3361 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3362 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3363 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3367 /* Create SNOW 3G session */
3368 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3369 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3370 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3371 tdata->key.data, tdata->key.len,
3372 tdata->cipher_iv.len);
3376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3378 /* Clear mbuf payload */
3379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3380 rte_pktmbuf_tailroom(ut_params->ibuf));
3382 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3383 /* Append data which is padded to a multiple of */
3384 /* the algorithms block size */
3385 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3386 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3388 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3390 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3392 /* Create SNOW 3G operation */
3393 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3394 tdata->cipher_iv.len,
3395 tdata->validCipherLenInBits.len,
3400 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3402 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3404 ut_params->obuf = ut_params->op->sym->m_dst;
3405 if (ut_params->obuf)
3406 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3408 ciphertext = plaintext;
3410 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3413 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3415 tdata->ciphertext.data,
3416 tdata->validDataLenInBits.len,
3417 "SNOW 3G Ciphertext data not as expected");
3423 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3425 struct crypto_testsuite_params *ts_params = &testsuite_params;
3426 struct crypto_unittest_params *ut_params = &unittest_params;
3427 uint8_t *plaintext, *ciphertext;
3430 unsigned plaintext_pad_len;
3431 unsigned plaintext_len;
3433 /* Verify the capabilities */
3434 struct rte_cryptodev_sym_capability_idx cap_idx;
3435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3436 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3441 /* Create SNOW 3G session */
3442 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3443 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3444 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3445 tdata->key.data, tdata->key.len,
3446 tdata->cipher_iv.len);
3450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3451 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3453 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3454 "Failed to allocate input buffer in mempool");
3455 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3456 "Failed to allocate output buffer in mempool");
3458 /* Clear mbuf payload */
3459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3460 rte_pktmbuf_tailroom(ut_params->ibuf));
3462 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3463 /* Append data which is padded to a multiple of */
3464 /* the algorithms block size */
3465 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3466 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3468 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3469 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3471 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3473 /* Create SNOW 3G operation */
3474 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3475 tdata->cipher_iv.len,
3476 tdata->validCipherLenInBits.len,
3481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3483 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3485 ut_params->obuf = ut_params->op->sym->m_dst;
3486 if (ut_params->obuf)
3487 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3489 ciphertext = plaintext;
3491 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3494 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3496 tdata->ciphertext.data,
3497 tdata->validDataLenInBits.len,
3498 "SNOW 3G Ciphertext data not as expected");
3503 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3505 struct crypto_testsuite_params *ts_params = &testsuite_params;
3506 struct crypto_unittest_params *ut_params = &unittest_params;
3509 unsigned int plaintext_pad_len;
3510 unsigned int plaintext_len;
3511 uint8_t buffer[10000];
3512 const uint8_t *ciphertext;
3514 struct rte_cryptodev_info dev_info;
3516 /* Verify the capabilities */
3517 struct rte_cryptodev_sym_capability_idx cap_idx;
3518 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3519 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3524 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3526 uint64_t feat_flags = dev_info.feature_flags;
3528 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3529 printf("Device doesn't support out-of-place scatter-gather "
3530 "in both input and output mbufs. "
3535 /* Create SNOW 3G session */
3536 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3538 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3539 tdata->key.data, tdata->key.len,
3540 tdata->cipher_iv.len);
3544 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3545 /* Append data which is padded to a multiple of */
3546 /* the algorithms block size */
3547 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3549 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3550 plaintext_pad_len, 10, 0);
3551 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3552 plaintext_pad_len, 3, 0);
3554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3555 "Failed to allocate input buffer in mempool");
3556 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3557 "Failed to allocate output buffer in mempool");
3559 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3561 /* Create SNOW 3G operation */
3562 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3563 tdata->cipher_iv.len,
3564 tdata->validCipherLenInBits.len,
3569 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3571 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3573 ut_params->obuf = ut_params->op->sym->m_dst;
3574 if (ut_params->obuf)
3575 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3576 plaintext_len, buffer);
3578 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3579 plaintext_len, buffer);
3581 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3584 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3586 tdata->ciphertext.data,
3587 tdata->validDataLenInBits.len,
3588 "SNOW 3G Ciphertext data not as expected");
3593 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3595 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3597 uint8_t curr_byte, prev_byte;
3598 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3599 uint8_t lower_byte_mask = (1 << offset) - 1;
3602 prev_byte = buffer[0];
3603 buffer[0] >>= offset;
3605 for (i = 1; i < length_in_bytes; i++) {
3606 curr_byte = buffer[i];
3607 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3608 (curr_byte >> offset);
3609 prev_byte = curr_byte;
3614 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3616 struct crypto_testsuite_params *ts_params = &testsuite_params;
3617 struct crypto_unittest_params *ut_params = &unittest_params;
3618 uint8_t *plaintext, *ciphertext;
3620 uint32_t plaintext_len;
3621 uint32_t plaintext_pad_len;
3622 uint8_t extra_offset = 4;
3623 uint8_t *expected_ciphertext_shifted;
3625 /* QAT PMD supports byte-aligned data only */
3626 if (gbl_driver_id == rte_cryptodev_driver_id_get(
3627 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)))
3630 /* Verify the capabilities */
3631 struct rte_cryptodev_sym_capability_idx cap_idx;
3632 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3633 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3634 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3638 /* Create SNOW 3G session */
3639 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3640 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3641 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3642 tdata->key.data, tdata->key.len,
3643 tdata->cipher_iv.len);
3647 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3648 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3650 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3651 "Failed to allocate input buffer in mempool");
3652 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3653 "Failed to allocate output buffer in mempool");
3655 /* Clear mbuf payload */
3656 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3657 rte_pktmbuf_tailroom(ut_params->ibuf));
3659 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3661 * Append data which is padded to a
3662 * multiple of the algorithms block size
3664 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3666 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3669 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3671 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3672 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3674 #ifdef RTE_APP_TEST_DEBUG
3675 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3677 /* Create SNOW 3G operation */
3678 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3679 tdata->cipher_iv.len,
3680 tdata->validCipherLenInBits.len,
3685 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3687 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3689 ut_params->obuf = ut_params->op->sym->m_dst;
3690 if (ut_params->obuf)
3691 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3693 ciphertext = plaintext;
3695 #ifdef RTE_APP_TEST_DEBUG
3696 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3699 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3701 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3702 "failed to reserve memory for ciphertext shifted\n");
3704 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3705 ceil_byte_length(tdata->ciphertext.len));
3706 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3709 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3711 expected_ciphertext_shifted,
3712 tdata->validDataLenInBits.len,
3714 "SNOW 3G Ciphertext data not as expected");
3718 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3720 struct crypto_testsuite_params *ts_params = &testsuite_params;
3721 struct crypto_unittest_params *ut_params = &unittest_params;
3725 uint8_t *plaintext, *ciphertext;
3726 unsigned ciphertext_pad_len;
3727 unsigned ciphertext_len;
3729 /* Verify the capabilities */
3730 struct rte_cryptodev_sym_capability_idx cap_idx;
3731 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3732 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3733 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3737 /* Create SNOW 3G session */
3738 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3739 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3740 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3741 tdata->key.data, tdata->key.len,
3742 tdata->cipher_iv.len);
3746 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3748 /* Clear mbuf payload */
3749 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3750 rte_pktmbuf_tailroom(ut_params->ibuf));
3752 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3753 /* Append data which is padded to a multiple of */
3754 /* the algorithms block size */
3755 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3756 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3757 ciphertext_pad_len);
3758 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3760 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3762 /* Create SNOW 3G operation */
3763 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3764 tdata->cipher_iv.len,
3765 tdata->validCipherLenInBits.len,
3766 tdata->cipher.offset_bits);
3770 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3772 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3774 if (ut_params->obuf)
3775 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3777 plaintext = ciphertext;
3779 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3782 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3783 tdata->plaintext.data,
3784 tdata->validDataLenInBits.len,
3785 "SNOW 3G Plaintext data not as expected");
3789 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3791 struct crypto_testsuite_params *ts_params = &testsuite_params;
3792 struct crypto_unittest_params *ut_params = &unittest_params;
3796 uint8_t *plaintext, *ciphertext;
3797 unsigned ciphertext_pad_len;
3798 unsigned ciphertext_len;
3800 /* Verify the capabilities */
3801 struct rte_cryptodev_sym_capability_idx cap_idx;
3802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3803 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3804 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3808 /* Create SNOW 3G session */
3809 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3810 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3811 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3812 tdata->key.data, tdata->key.len,
3813 tdata->cipher_iv.len);
3817 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3818 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3820 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3821 "Failed to allocate input buffer");
3822 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3823 "Failed to allocate output buffer");
3825 /* Clear mbuf payload */
3826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3827 rte_pktmbuf_tailroom(ut_params->ibuf));
3829 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3830 rte_pktmbuf_tailroom(ut_params->obuf));
3832 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3833 /* Append data which is padded to a multiple of */
3834 /* the algorithms block size */
3835 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3836 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3837 ciphertext_pad_len);
3838 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3839 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3841 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3843 /* Create SNOW 3G operation */
3844 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3845 tdata->cipher_iv.len,
3846 tdata->validCipherLenInBits.len,
3851 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3853 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3854 ut_params->obuf = ut_params->op->sym->m_dst;
3855 if (ut_params->obuf)
3856 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3858 plaintext = ciphertext;
3860 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3863 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3864 tdata->plaintext.data,
3865 tdata->validDataLenInBits.len,
3866 "SNOW 3G Plaintext data not as expected");
3871 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3873 struct crypto_testsuite_params *ts_params = &testsuite_params;
3874 struct crypto_unittest_params *ut_params = &unittest_params;
3878 uint8_t *plaintext, *ciphertext;
3879 unsigned int plaintext_pad_len;
3880 unsigned int plaintext_len;
3882 struct rte_cryptodev_sym_capability_idx cap_idx;
3884 /* Check if device supports ZUC EEA3 */
3885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3886 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3888 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3892 /* Check if device supports ZUC EIA3 */
3893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3894 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3896 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3900 /* Create ZUC session */
3901 retval = create_zuc_cipher_auth_encrypt_generate_session(
3902 ts_params->valid_devs[0],
3906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3908 /* clear mbuf payload */
3909 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3910 rte_pktmbuf_tailroom(ut_params->ibuf));
3912 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3913 /* Append data which is padded to a multiple of */
3914 /* the algorithms block size */
3915 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3916 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3918 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3920 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3922 /* Create ZUC operation */
3923 retval = create_zuc_cipher_hash_generate_operation(tdata);
3927 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3929 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3930 ut_params->obuf = ut_params->op->sym->m_src;
3931 if (ut_params->obuf)
3932 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3934 ciphertext = plaintext;
3936 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3938 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3940 tdata->ciphertext.data,
3941 tdata->validDataLenInBits.len,
3942 "ZUC Ciphertext data not as expected");
3944 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3945 + plaintext_pad_len;
3948 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3952 "ZUC Generated auth tag not as expected");
3957 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3959 struct crypto_testsuite_params *ts_params = &testsuite_params;
3960 struct crypto_unittest_params *ut_params = &unittest_params;
3964 uint8_t *plaintext, *ciphertext;
3965 unsigned plaintext_pad_len;
3966 unsigned plaintext_len;
3968 /* Verify the capabilities */
3969 struct rte_cryptodev_sym_capability_idx cap_idx;
3970 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3971 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3972 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3976 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3981 /* Create SNOW 3G session */
3982 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3983 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3984 RTE_CRYPTO_AUTH_OP_GENERATE,
3985 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3986 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3987 tdata->key.data, tdata->key.len,
3988 tdata->auth_iv.len, tdata->digest.len,
3989 tdata->cipher_iv.len);
3992 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3994 /* clear mbuf payload */
3995 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3996 rte_pktmbuf_tailroom(ut_params->ibuf));
3998 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3999 /* Append data which is padded to a multiple of */
4000 /* the algorithms block size */
4001 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4002 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4004 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4006 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4008 /* Create SNOW 3G operation */
4009 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4010 tdata->digest.len, tdata->auth_iv.data,
4012 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4013 tdata->cipher_iv.data, tdata->cipher_iv.len,
4014 tdata->validCipherLenInBits.len,
4016 tdata->validAuthLenInBits.len,
4022 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4024 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4025 ut_params->obuf = ut_params->op->sym->m_src;
4026 if (ut_params->obuf)
4027 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4029 ciphertext = plaintext;
4031 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4035 tdata->ciphertext.data,
4036 tdata->validDataLenInBits.len,
4037 "SNOW 3G Ciphertext data not as expected");
4039 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4040 + plaintext_pad_len;
4043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4046 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4047 "SNOW 3G Generated auth tag not as expected");
4052 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4053 uint8_t op_mode, uint8_t verify)
4055 struct crypto_testsuite_params *ts_params = &testsuite_params;
4056 struct crypto_unittest_params *ut_params = &unittest_params;
4060 uint8_t *plaintext = NULL, *ciphertext = NULL;
4061 unsigned int plaintext_pad_len;
4062 unsigned int plaintext_len;
4063 unsigned int ciphertext_pad_len;
4064 unsigned int ciphertext_len;
4066 struct rte_cryptodev_info dev_info;
4068 /* Verify the capabilities */
4069 struct rte_cryptodev_sym_capability_idx cap_idx;
4070 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4071 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4072 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4076 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4081 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4083 uint64_t feat_flags = dev_info.feature_flags;
4085 if (op_mode == OUT_OF_PLACE) {
4086 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4087 printf("Device doesn't support digest encrypted.\n");
4092 /* Create SNOW 3G session */
4093 retval = create_wireless_algo_auth_cipher_session(
4094 ts_params->valid_devs[0],
4095 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4096 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4097 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4098 : RTE_CRYPTO_AUTH_OP_GENERATE),
4099 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4100 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4101 tdata->key.data, tdata->key.len,
4102 tdata->auth_iv.len, tdata->digest.len,
4103 tdata->cipher_iv.len);
4108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4109 if (op_mode == OUT_OF_PLACE)
4110 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4112 /* clear mbuf payload */
4113 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4114 rte_pktmbuf_tailroom(ut_params->ibuf));
4115 if (op_mode == OUT_OF_PLACE)
4116 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4117 rte_pktmbuf_tailroom(ut_params->obuf));
4119 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4120 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4121 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4122 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4125 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4126 ciphertext_pad_len);
4127 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4128 if (op_mode == OUT_OF_PLACE)
4129 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4130 debug_hexdump(stdout, "ciphertext:", ciphertext,
4133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4135 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4136 if (op_mode == OUT_OF_PLACE)
4137 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4138 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4141 /* Create SNOW 3G operation */
4142 retval = create_wireless_algo_auth_cipher_operation(
4143 tdata->digest.data, tdata->digest.len,
4144 tdata->cipher_iv.data, tdata->cipher_iv.len,
4145 tdata->auth_iv.data, tdata->auth_iv.len,
4146 (tdata->digest.offset_bytes == 0 ?
4147 (verify ? ciphertext_pad_len : plaintext_pad_len)
4148 : tdata->digest.offset_bytes),
4149 tdata->validCipherLenInBits.len,
4150 tdata->cipher.offset_bits,
4151 tdata->validAuthLenInBits.len,
4152 tdata->auth.offset_bits,
4153 op_mode, 0, verify);
4158 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4163 ut_params->obuf = (op_mode == IN_PLACE ?
4164 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4167 if (ut_params->obuf)
4168 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4171 plaintext = ciphertext +
4172 (tdata->cipher.offset_bits >> 3);
4174 debug_hexdump(stdout, "plaintext:", plaintext,
4175 (tdata->plaintext.len >> 3) - tdata->digest.len);
4176 debug_hexdump(stdout, "plaintext expected:",
4177 tdata->plaintext.data,
4178 (tdata->plaintext.len >> 3) - tdata->digest.len);
4180 if (ut_params->obuf)
4181 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4184 ciphertext = plaintext;
4186 debug_hexdump(stdout, "ciphertext:", ciphertext,
4188 debug_hexdump(stdout, "ciphertext expected:",
4189 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4191 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4192 + (tdata->digest.offset_bytes == 0 ?
4193 plaintext_pad_len : tdata->digest.offset_bytes);
4195 debug_hexdump(stdout, "digest:", ut_params->digest,
4197 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4203 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4205 tdata->plaintext.data,
4206 tdata->plaintext.len >> 3,
4207 "SNOW 3G Plaintext data not as expected");
4209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4211 tdata->ciphertext.data,
4212 tdata->validDataLenInBits.len,
4213 "SNOW 3G Ciphertext data not as expected");
4215 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4218 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4219 "SNOW 3G Generated auth tag not as expected");
4225 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4226 uint8_t op_mode, uint8_t verify)
4228 struct crypto_testsuite_params *ts_params = &testsuite_params;
4229 struct crypto_unittest_params *ut_params = &unittest_params;
4233 const uint8_t *plaintext = NULL;
4234 const uint8_t *ciphertext = NULL;
4235 const uint8_t *digest = NULL;
4236 unsigned int plaintext_pad_len;
4237 unsigned int plaintext_len;
4238 unsigned int ciphertext_pad_len;
4239 unsigned int ciphertext_len;
4240 uint8_t buffer[10000];
4241 uint8_t digest_buffer[10000];
4243 struct rte_cryptodev_info dev_info;
4245 /* Verify the capabilities */
4246 struct rte_cryptodev_sym_capability_idx cap_idx;
4247 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4248 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4249 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4252 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4253 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4254 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4258 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4260 uint64_t feat_flags = dev_info.feature_flags;
4262 if (op_mode == IN_PLACE) {
4263 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4264 printf("Device doesn't support in-place scatter-gather "
4265 "in both input and output mbufs.\n");
4269 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4270 printf("Device doesn't support out-of-place scatter-gather "
4271 "in both input and output mbufs.\n");
4274 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4275 printf("Device doesn't support digest encrypted.\n");
4280 /* Create SNOW 3G session */
4281 retval = create_wireless_algo_auth_cipher_session(
4282 ts_params->valid_devs[0],
4283 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4284 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4285 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4286 : RTE_CRYPTO_AUTH_OP_GENERATE),
4287 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4288 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4289 tdata->key.data, tdata->key.len,
4290 tdata->auth_iv.len, tdata->digest.len,
4291 tdata->cipher_iv.len);
4296 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4297 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4298 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4301 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4302 plaintext_pad_len, 15, 0);
4303 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4304 "Failed to allocate input buffer in mempool");
4306 if (op_mode == OUT_OF_PLACE) {
4307 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4308 plaintext_pad_len, 15, 0);
4309 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4310 "Failed to allocate output buffer in mempool");
4314 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4315 tdata->ciphertext.data);
4316 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4317 ciphertext_len, buffer);
4318 debug_hexdump(stdout, "ciphertext:", ciphertext,
4321 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4322 tdata->plaintext.data);
4323 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4324 plaintext_len, buffer);
4325 debug_hexdump(stdout, "plaintext:", plaintext,
4328 memset(buffer, 0, sizeof(buffer));
4330 /* Create SNOW 3G operation */
4331 retval = create_wireless_algo_auth_cipher_operation(
4332 tdata->digest.data, tdata->digest.len,
4333 tdata->cipher_iv.data, tdata->cipher_iv.len,
4334 tdata->auth_iv.data, tdata->auth_iv.len,
4335 (tdata->digest.offset_bytes == 0 ?
4336 (verify ? ciphertext_pad_len : plaintext_pad_len)
4337 : tdata->digest.offset_bytes),
4338 tdata->validCipherLenInBits.len,
4339 tdata->cipher.offset_bits,
4340 tdata->validAuthLenInBits.len,
4341 tdata->auth.offset_bits,
4342 op_mode, 1, verify);
4347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4350 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4352 ut_params->obuf = (op_mode == IN_PLACE ?
4353 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4356 if (ut_params->obuf)
4357 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4358 plaintext_len, buffer);
4360 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4361 plaintext_len, buffer);
4363 debug_hexdump(stdout, "plaintext:", plaintext,
4364 (tdata->plaintext.len >> 3) - tdata->digest.len);
4365 debug_hexdump(stdout, "plaintext expected:",
4366 tdata->plaintext.data,
4367 (tdata->plaintext.len >> 3) - tdata->digest.len);
4369 if (ut_params->obuf)
4370 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4371 ciphertext_len, buffer);
4373 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4374 ciphertext_len, buffer);
4376 debug_hexdump(stdout, "ciphertext:", ciphertext,
4378 debug_hexdump(stdout, "ciphertext expected:",
4379 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4381 if (ut_params->obuf)
4382 digest = rte_pktmbuf_read(ut_params->obuf,
4383 (tdata->digest.offset_bytes == 0 ?
4384 plaintext_pad_len : tdata->digest.offset_bytes),
4385 tdata->digest.len, digest_buffer);
4387 digest = rte_pktmbuf_read(ut_params->ibuf,
4388 (tdata->digest.offset_bytes == 0 ?
4389 plaintext_pad_len : tdata->digest.offset_bytes),
4390 tdata->digest.len, digest_buffer);
4392 debug_hexdump(stdout, "digest:", digest,
4394 debug_hexdump(stdout, "digest expected:",
4395 tdata->digest.data, tdata->digest.len);
4400 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4402 tdata->plaintext.data,
4403 tdata->plaintext.len >> 3,
4404 "SNOW 3G Plaintext data not as expected");
4406 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4408 tdata->ciphertext.data,
4409 tdata->validDataLenInBits.len,
4410 "SNOW 3G Ciphertext data not as expected");
4412 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4415 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4416 "SNOW 3G Generated auth tag not as expected");
4422 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4423 uint8_t op_mode, uint8_t verify)
4425 struct crypto_testsuite_params *ts_params = &testsuite_params;
4426 struct crypto_unittest_params *ut_params = &unittest_params;
4430 uint8_t *plaintext = NULL, *ciphertext = NULL;
4431 unsigned int plaintext_pad_len;
4432 unsigned int plaintext_len;
4433 unsigned int ciphertext_pad_len;
4434 unsigned int ciphertext_len;
4436 struct rte_cryptodev_info dev_info;
4438 /* Verify the capabilities */
4439 struct rte_cryptodev_sym_capability_idx cap_idx;
4440 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4441 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4442 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4446 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4451 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4453 uint64_t feat_flags = dev_info.feature_flags;
4455 if (op_mode == OUT_OF_PLACE) {
4456 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4457 printf("Device doesn't support digest encrypted.\n");
4462 /* Create KASUMI session */
4463 retval = create_wireless_algo_auth_cipher_session(
4464 ts_params->valid_devs[0],
4465 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4466 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4467 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4468 : RTE_CRYPTO_AUTH_OP_GENERATE),
4469 RTE_CRYPTO_AUTH_KASUMI_F9,
4470 RTE_CRYPTO_CIPHER_KASUMI_F8,
4471 tdata->key.data, tdata->key.len,
4472 0, tdata->digest.len,
4473 tdata->cipher_iv.len);
4478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4479 if (op_mode == OUT_OF_PLACE)
4480 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4482 /* clear mbuf payload */
4483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4484 rte_pktmbuf_tailroom(ut_params->ibuf));
4485 if (op_mode == OUT_OF_PLACE)
4486 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4487 rte_pktmbuf_tailroom(ut_params->obuf));
4489 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4490 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4491 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4492 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4495 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4496 ciphertext_pad_len);
4497 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4498 if (op_mode == OUT_OF_PLACE)
4499 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4500 debug_hexdump(stdout, "ciphertext:", ciphertext,
4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4506 if (op_mode == OUT_OF_PLACE)
4507 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4508 debug_hexdump(stdout, "plaintext:", plaintext,
4512 /* Create KASUMI operation */
4513 retval = create_wireless_algo_auth_cipher_operation(
4514 tdata->digest.data, tdata->digest.len,
4515 tdata->cipher_iv.data, tdata->cipher_iv.len,
4517 (tdata->digest.offset_bytes == 0 ?
4518 (verify ? ciphertext_pad_len : plaintext_pad_len)
4519 : tdata->digest.offset_bytes),
4520 tdata->validCipherLenInBits.len,
4521 tdata->validCipherOffsetInBits.len,
4522 tdata->validAuthLenInBits.len,
4524 op_mode, 0, verify);
4529 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4532 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4534 ut_params->obuf = (op_mode == IN_PLACE ?
4535 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4539 if (ut_params->obuf)
4540 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4543 plaintext = ciphertext;
4545 debug_hexdump(stdout, "plaintext:", plaintext,
4546 (tdata->plaintext.len >> 3) - tdata->digest.len);
4547 debug_hexdump(stdout, "plaintext expected:",
4548 tdata->plaintext.data,
4549 (tdata->plaintext.len >> 3) - tdata->digest.len);
4551 if (ut_params->obuf)
4552 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4555 ciphertext = plaintext;
4557 debug_hexdump(stdout, "ciphertext:", ciphertext,
4559 debug_hexdump(stdout, "ciphertext expected:",
4560 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4562 ut_params->digest = rte_pktmbuf_mtod(
4563 ut_params->obuf, uint8_t *) +
4564 (tdata->digest.offset_bytes == 0 ?
4565 plaintext_pad_len : tdata->digest.offset_bytes);
4567 debug_hexdump(stdout, "digest:", ut_params->digest,
4569 debug_hexdump(stdout, "digest expected:",
4570 tdata->digest.data, tdata->digest.len);
4575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4577 tdata->plaintext.data,
4578 tdata->plaintext.len >> 3,
4579 "KASUMI Plaintext data not as expected");
4581 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4583 tdata->ciphertext.data,
4584 tdata->ciphertext.len >> 3,
4585 "KASUMI Ciphertext data not as expected");
4587 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4590 DIGEST_BYTE_LENGTH_KASUMI_F9,
4591 "KASUMI Generated auth tag not as expected");
4597 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4598 uint8_t op_mode, uint8_t verify)
4600 struct crypto_testsuite_params *ts_params = &testsuite_params;
4601 struct crypto_unittest_params *ut_params = &unittest_params;
4605 const uint8_t *plaintext = NULL;
4606 const uint8_t *ciphertext = NULL;
4607 const uint8_t *digest = NULL;
4608 unsigned int plaintext_pad_len;
4609 unsigned int plaintext_len;
4610 unsigned int ciphertext_pad_len;
4611 unsigned int ciphertext_len;
4612 uint8_t buffer[10000];
4613 uint8_t digest_buffer[10000];
4615 struct rte_cryptodev_info dev_info;
4617 /* Verify the capabilities */
4618 struct rte_cryptodev_sym_capability_idx cap_idx;
4619 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4620 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4625 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4630 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4632 uint64_t feat_flags = dev_info.feature_flags;
4634 if (op_mode == IN_PLACE) {
4635 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4636 printf("Device doesn't support in-place scatter-gather "
4637 "in both input and output mbufs.\n");
4641 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4642 printf("Device doesn't support out-of-place scatter-gather "
4643 "in both input and output mbufs.\n");
4646 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4647 printf("Device doesn't support digest encrypted.\n");
4652 /* Create KASUMI session */
4653 retval = create_wireless_algo_auth_cipher_session(
4654 ts_params->valid_devs[0],
4655 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4656 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4657 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4658 : RTE_CRYPTO_AUTH_OP_GENERATE),
4659 RTE_CRYPTO_AUTH_KASUMI_F9,
4660 RTE_CRYPTO_CIPHER_KASUMI_F8,
4661 tdata->key.data, tdata->key.len,
4662 0, tdata->digest.len,
4663 tdata->cipher_iv.len);
4668 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4669 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4670 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4671 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4673 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4674 plaintext_pad_len, 15, 0);
4675 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4676 "Failed to allocate input buffer in mempool");
4678 if (op_mode == OUT_OF_PLACE) {
4679 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4680 plaintext_pad_len, 15, 0);
4681 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4682 "Failed to allocate output buffer in mempool");
4686 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4687 tdata->ciphertext.data);
4688 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4689 ciphertext_len, buffer);
4690 debug_hexdump(stdout, "ciphertext:", ciphertext,
4693 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4694 tdata->plaintext.data);
4695 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4696 plaintext_len, buffer);
4697 debug_hexdump(stdout, "plaintext:", plaintext,
4700 memset(buffer, 0, sizeof(buffer));
4702 /* Create KASUMI operation */
4703 retval = create_wireless_algo_auth_cipher_operation(
4704 tdata->digest.data, tdata->digest.len,
4705 tdata->cipher_iv.data, tdata->cipher_iv.len,
4707 (tdata->digest.offset_bytes == 0 ?
4708 (verify ? ciphertext_pad_len : plaintext_pad_len)
4709 : tdata->digest.offset_bytes),
4710 tdata->validCipherLenInBits.len,
4711 tdata->validCipherOffsetInBits.len,
4712 tdata->validAuthLenInBits.len,
4714 op_mode, 1, verify);
4719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4724 ut_params->obuf = (op_mode == IN_PLACE ?
4725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4728 if (ut_params->obuf)
4729 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4730 plaintext_len, buffer);
4732 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4733 plaintext_len, buffer);
4735 debug_hexdump(stdout, "plaintext:", plaintext,
4736 (tdata->plaintext.len >> 3) - tdata->digest.len);
4737 debug_hexdump(stdout, "plaintext expected:",
4738 tdata->plaintext.data,
4739 (tdata->plaintext.len >> 3) - tdata->digest.len);
4741 if (ut_params->obuf)
4742 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4743 ciphertext_len, buffer);
4745 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4746 ciphertext_len, buffer);
4748 debug_hexdump(stdout, "ciphertext:", ciphertext,
4750 debug_hexdump(stdout, "ciphertext expected:",
4751 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4753 if (ut_params->obuf)
4754 digest = rte_pktmbuf_read(ut_params->obuf,
4755 (tdata->digest.offset_bytes == 0 ?
4756 plaintext_pad_len : tdata->digest.offset_bytes),
4757 tdata->digest.len, digest_buffer);
4759 digest = rte_pktmbuf_read(ut_params->ibuf,
4760 (tdata->digest.offset_bytes == 0 ?
4761 plaintext_pad_len : tdata->digest.offset_bytes),
4762 tdata->digest.len, digest_buffer);
4764 debug_hexdump(stdout, "digest:", digest,
4766 debug_hexdump(stdout, "digest expected:",
4767 tdata->digest.data, tdata->digest.len);
4772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4774 tdata->plaintext.data,
4775 tdata->plaintext.len >> 3,
4776 "KASUMI Plaintext data not as expected");
4778 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4780 tdata->ciphertext.data,
4781 tdata->validDataLenInBits.len,
4782 "KASUMI Ciphertext data not as expected");
4784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4787 DIGEST_BYTE_LENGTH_KASUMI_F9,
4788 "KASUMI Generated auth tag not as expected");
4794 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4796 struct crypto_testsuite_params *ts_params = &testsuite_params;
4797 struct crypto_unittest_params *ut_params = &unittest_params;
4801 uint8_t *plaintext, *ciphertext;
4802 unsigned plaintext_pad_len;
4803 unsigned plaintext_len;
4805 /* Verify the capabilities */
4806 struct rte_cryptodev_sym_capability_idx cap_idx;
4807 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4808 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4809 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4813 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4818 /* Create KASUMI session */
4819 retval = create_wireless_algo_cipher_auth_session(
4820 ts_params->valid_devs[0],
4821 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4822 RTE_CRYPTO_AUTH_OP_GENERATE,
4823 RTE_CRYPTO_AUTH_KASUMI_F9,
4824 RTE_CRYPTO_CIPHER_KASUMI_F8,
4825 tdata->key.data, tdata->key.len,
4826 0, tdata->digest.len,
4827 tdata->cipher_iv.len);
4831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4833 /* clear mbuf payload */
4834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4835 rte_pktmbuf_tailroom(ut_params->ibuf));
4837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4838 /* Append data which is padded to a multiple of */
4839 /* the algorithms block size */
4840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4843 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4845 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4847 /* Create KASUMI operation */
4848 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4849 tdata->digest.len, NULL, 0,
4850 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4851 tdata->cipher_iv.data, tdata->cipher_iv.len,
4852 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4853 tdata->validCipherOffsetInBits.len,
4854 tdata->validAuthLenInBits.len,
4860 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4862 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4864 if (ut_params->op->sym->m_dst)
4865 ut_params->obuf = ut_params->op->sym->m_dst;
4867 ut_params->obuf = ut_params->op->sym->m_src;
4869 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4870 tdata->validCipherOffsetInBits.len >> 3);
4872 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4873 + plaintext_pad_len;
4875 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4876 (tdata->validCipherOffsetInBits.len >> 3);
4878 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4880 reference_ciphertext,
4881 tdata->validCipherLenInBits.len,
4882 "KASUMI Ciphertext data not as expected");
4885 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4888 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4889 "KASUMI Generated auth tag not as expected");
4894 test_zuc_encryption(const struct wireless_test_data *tdata)
4896 struct crypto_testsuite_params *ts_params = &testsuite_params;
4897 struct crypto_unittest_params *ut_params = &unittest_params;
4900 uint8_t *plaintext, *ciphertext;
4901 unsigned plaintext_pad_len;
4902 unsigned plaintext_len;
4904 struct rte_cryptodev_sym_capability_idx cap_idx;
4906 /* Check if device supports ZUC EEA3 */
4907 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4908 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4910 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4914 /* Create ZUC session */
4915 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4916 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4917 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4918 tdata->key.data, tdata->key.len,
4919 tdata->cipher_iv.len);
4923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4925 /* Clear mbuf payload */
4926 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4927 rte_pktmbuf_tailroom(ut_params->ibuf));
4929 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4930 /* Append data which is padded to a multiple */
4931 /* of the algorithms block size */
4932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4933 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4935 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4937 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4939 /* Create ZUC operation */
4940 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4941 tdata->cipher_iv.len,
4942 tdata->plaintext.len,
4947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4951 ut_params->obuf = ut_params->op->sym->m_dst;
4952 if (ut_params->obuf)
4953 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4955 ciphertext = plaintext;
4957 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4960 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4962 tdata->ciphertext.data,
4963 tdata->validCipherLenInBits.len,
4964 "ZUC Ciphertext data not as expected");
4969 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4971 struct crypto_testsuite_params *ts_params = &testsuite_params;
4972 struct crypto_unittest_params *ut_params = &unittest_params;
4976 unsigned int plaintext_pad_len;
4977 unsigned int plaintext_len;
4978 const uint8_t *ciphertext;
4979 uint8_t ciphertext_buffer[2048];
4980 struct rte_cryptodev_info dev_info;
4982 struct rte_cryptodev_sym_capability_idx cap_idx;
4984 /* Check if device supports ZUC EEA3 */
4985 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4986 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4988 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4992 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4994 uint64_t feat_flags = dev_info.feature_flags;
4996 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4997 printf("Device doesn't support in-place scatter-gather. "
5002 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5004 /* Append data which is padded to a multiple */
5005 /* of the algorithms block size */
5006 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5008 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5009 plaintext_pad_len, 10, 0);
5011 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5012 tdata->plaintext.data);
5014 /* Create ZUC session */
5015 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5016 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5017 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5018 tdata->key.data, tdata->key.len,
5019 tdata->cipher_iv.len);
5023 /* Clear mbuf payload */
5025 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5027 /* Create ZUC operation */
5028 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5029 tdata->cipher_iv.len, tdata->plaintext.len,
5034 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5036 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5038 ut_params->obuf = ut_params->op->sym->m_dst;
5039 if (ut_params->obuf)
5040 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5041 0, plaintext_len, ciphertext_buffer);
5043 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5044 0, plaintext_len, ciphertext_buffer);
5047 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5050 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5052 tdata->ciphertext.data,
5053 tdata->validCipherLenInBits.len,
5054 "ZUC Ciphertext data not as expected");
5060 test_zuc_authentication(const struct wireless_test_data *tdata)
5062 struct crypto_testsuite_params *ts_params = &testsuite_params;
5063 struct crypto_unittest_params *ut_params = &unittest_params;
5066 unsigned plaintext_pad_len;
5067 unsigned plaintext_len;
5070 struct rte_cryptodev_sym_capability_idx cap_idx;
5072 /* QAT PMD supports byte-aligned data only */
5073 if ((tdata->validAuthLenInBits.len % 8 != 0) &&
5074 (gbl_driver_id == rte_cryptodev_driver_id_get(
5075 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD))))
5078 /* Check if device supports ZUC EIA3 */
5079 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5080 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5082 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5086 /* Create ZUC session */
5087 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5088 tdata->key.data, tdata->key.len,
5089 tdata->auth_iv.len, tdata->digest.len,
5090 RTE_CRYPTO_AUTH_OP_GENERATE,
5091 RTE_CRYPTO_AUTH_ZUC_EIA3);
5095 /* alloc mbuf and set payload */
5096 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5098 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5099 rte_pktmbuf_tailroom(ut_params->ibuf));
5101 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5102 /* Append data which is padded to a multiple of */
5103 /* the algorithms block size */
5104 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5105 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5107 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5109 /* Create ZUC operation */
5110 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5111 tdata->auth_iv.data, tdata->auth_iv.len,
5112 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5113 tdata->validAuthLenInBits.len,
5118 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5120 ut_params->obuf = ut_params->op->sym->m_src;
5121 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5122 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5123 + plaintext_pad_len;
5126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5130 "ZUC Generated auth tag not as expected");
5136 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5137 uint8_t op_mode, uint8_t verify)
5139 struct crypto_testsuite_params *ts_params = &testsuite_params;
5140 struct crypto_unittest_params *ut_params = &unittest_params;
5144 uint8_t *plaintext = NULL, *ciphertext = NULL;
5145 unsigned int plaintext_pad_len;
5146 unsigned int plaintext_len;
5147 unsigned int ciphertext_pad_len;
5148 unsigned int ciphertext_len;
5150 struct rte_cryptodev_info dev_info;
5151 struct rte_cryptodev_sym_capability_idx cap_idx;
5153 /* Check if device supports ZUC EIA3 */
5154 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5155 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5157 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5161 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5163 uint64_t feat_flags = dev_info.feature_flags;
5165 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5166 printf("Device doesn't support digest encrypted.\n");
5170 /* Create ZUC session */
5171 retval = create_wireless_algo_auth_cipher_session(
5172 ts_params->valid_devs[0],
5173 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5174 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5175 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5176 : RTE_CRYPTO_AUTH_OP_GENERATE),
5177 RTE_CRYPTO_AUTH_ZUC_EIA3,
5178 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5179 tdata->key.data, tdata->key.len,
5180 tdata->auth_iv.len, tdata->digest.len,
5181 tdata->cipher_iv.len);
5186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5187 if (op_mode == OUT_OF_PLACE)
5188 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5190 /* clear mbuf payload */
5191 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5192 rte_pktmbuf_tailroom(ut_params->ibuf));
5193 if (op_mode == OUT_OF_PLACE)
5194 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5195 rte_pktmbuf_tailroom(ut_params->obuf));
5197 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5199 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5203 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5204 ciphertext_pad_len);
5205 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5206 if (op_mode == OUT_OF_PLACE)
5207 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5208 debug_hexdump(stdout, "ciphertext:", ciphertext,
5211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5213 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5214 if (op_mode == OUT_OF_PLACE)
5215 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5216 debug_hexdump(stdout, "plaintext:", plaintext,
5220 /* Create ZUC operation */
5221 retval = create_wireless_algo_auth_cipher_operation(
5222 tdata->digest.data, tdata->digest.len,
5223 tdata->cipher_iv.data, tdata->cipher_iv.len,
5224 tdata->auth_iv.data, tdata->auth_iv.len,
5225 (tdata->digest.offset_bytes == 0 ?
5226 (verify ? ciphertext_pad_len : plaintext_pad_len)
5227 : tdata->digest.offset_bytes),
5228 tdata->validCipherLenInBits.len,
5229 tdata->validCipherOffsetInBits.len,
5230 tdata->validAuthLenInBits.len,
5232 op_mode, 0, verify);
5237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5240 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5242 ut_params->obuf = (op_mode == IN_PLACE ?
5243 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5247 if (ut_params->obuf)
5248 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5251 plaintext = ciphertext;
5253 debug_hexdump(stdout, "plaintext:", plaintext,
5254 (tdata->plaintext.len >> 3) - tdata->digest.len);
5255 debug_hexdump(stdout, "plaintext expected:",
5256 tdata->plaintext.data,
5257 (tdata->plaintext.len >> 3) - tdata->digest.len);
5259 if (ut_params->obuf)
5260 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5263 ciphertext = plaintext;
5265 debug_hexdump(stdout, "ciphertext:", ciphertext,
5267 debug_hexdump(stdout, "ciphertext expected:",
5268 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5270 ut_params->digest = rte_pktmbuf_mtod(
5271 ut_params->obuf, uint8_t *) +
5272 (tdata->digest.offset_bytes == 0 ?
5273 plaintext_pad_len : tdata->digest.offset_bytes);
5275 debug_hexdump(stdout, "digest:", ut_params->digest,
5277 debug_hexdump(stdout, "digest expected:",
5278 tdata->digest.data, tdata->digest.len);
5283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5285 tdata->plaintext.data,
5286 tdata->plaintext.len >> 3,
5287 "ZUC Plaintext data not as expected");
5289 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5291 tdata->ciphertext.data,
5292 tdata->ciphertext.len >> 3,
5293 "ZUC Ciphertext data not as expected");
5295 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5298 DIGEST_BYTE_LENGTH_KASUMI_F9,
5299 "ZUC Generated auth tag not as expected");
5305 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5306 uint8_t op_mode, uint8_t verify)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5309 struct crypto_unittest_params *ut_params = &unittest_params;
5313 const uint8_t *plaintext = NULL;
5314 const uint8_t *ciphertext = NULL;
5315 const uint8_t *digest = NULL;
5316 unsigned int plaintext_pad_len;
5317 unsigned int plaintext_len;
5318 unsigned int ciphertext_pad_len;
5319 unsigned int ciphertext_len;
5320 uint8_t buffer[10000];
5321 uint8_t digest_buffer[10000];
5323 struct rte_cryptodev_info dev_info;
5324 struct rte_cryptodev_sym_capability_idx cap_idx;
5326 /* Check if device supports ZUC EIA3 */
5327 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5328 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5330 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5334 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5336 uint64_t feat_flags = dev_info.feature_flags;
5338 if (op_mode == IN_PLACE) {
5339 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5340 printf("Device doesn't support in-place scatter-gather "
5341 "in both input and output mbufs.\n");
5345 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5346 printf("Device doesn't support out-of-place scatter-gather "
5347 "in both input and output mbufs.\n");
5350 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5351 printf("Device doesn't support digest encrypted.\n");
5356 /* Create ZUC session */
5357 retval = create_wireless_algo_auth_cipher_session(
5358 ts_params->valid_devs[0],
5359 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5360 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5361 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5362 : RTE_CRYPTO_AUTH_OP_GENERATE),
5363 RTE_CRYPTO_AUTH_ZUC_EIA3,
5364 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5365 tdata->key.data, tdata->key.len,
5366 tdata->auth_iv.len, tdata->digest.len,
5367 tdata->cipher_iv.len);
5372 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5373 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5374 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5375 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5377 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5378 plaintext_pad_len, 15, 0);
5379 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5380 "Failed to allocate input buffer in mempool");
5382 if (op_mode == OUT_OF_PLACE) {
5383 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5384 plaintext_pad_len, 15, 0);
5385 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5386 "Failed to allocate output buffer in mempool");
5390 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5391 tdata->ciphertext.data);
5392 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5393 ciphertext_len, buffer);
5394 debug_hexdump(stdout, "ciphertext:", ciphertext,
5397 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5398 tdata->plaintext.data);
5399 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5400 plaintext_len, buffer);
5401 debug_hexdump(stdout, "plaintext:", plaintext,
5404 memset(buffer, 0, sizeof(buffer));
5406 /* Create ZUC operation */
5407 retval = create_wireless_algo_auth_cipher_operation(
5408 tdata->digest.data, tdata->digest.len,
5409 tdata->cipher_iv.data, tdata->cipher_iv.len,
5411 (tdata->digest.offset_bytes == 0 ?
5412 (verify ? ciphertext_pad_len : plaintext_pad_len)
5413 : tdata->digest.offset_bytes),
5414 tdata->validCipherLenInBits.len,
5415 tdata->validCipherOffsetInBits.len,
5416 tdata->validAuthLenInBits.len,
5418 op_mode, 1, verify);
5423 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5426 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5428 ut_params->obuf = (op_mode == IN_PLACE ?
5429 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5432 if (ut_params->obuf)
5433 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5434 plaintext_len, buffer);
5436 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5437 plaintext_len, buffer);
5439 debug_hexdump(stdout, "plaintext:", plaintext,
5440 (tdata->plaintext.len >> 3) - tdata->digest.len);
5441 debug_hexdump(stdout, "plaintext expected:",
5442 tdata->plaintext.data,
5443 (tdata->plaintext.len >> 3) - tdata->digest.len);
5445 if (ut_params->obuf)
5446 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5447 ciphertext_len, buffer);
5449 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5450 ciphertext_len, buffer);
5452 debug_hexdump(stdout, "ciphertext:", ciphertext,
5454 debug_hexdump(stdout, "ciphertext expected:",
5455 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5457 if (ut_params->obuf)
5458 digest = rte_pktmbuf_read(ut_params->obuf,
5459 (tdata->digest.offset_bytes == 0 ?
5460 plaintext_pad_len : tdata->digest.offset_bytes),
5461 tdata->digest.len, digest_buffer);
5463 digest = rte_pktmbuf_read(ut_params->ibuf,
5464 (tdata->digest.offset_bytes == 0 ?
5465 plaintext_pad_len : tdata->digest.offset_bytes),
5466 tdata->digest.len, digest_buffer);
5468 debug_hexdump(stdout, "digest:", digest,
5470 debug_hexdump(stdout, "digest expected:",
5471 tdata->digest.data, tdata->digest.len);
5476 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5478 tdata->plaintext.data,
5479 tdata->plaintext.len >> 3,
5480 "ZUC Plaintext data not as expected");
5482 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5484 tdata->ciphertext.data,
5485 tdata->validDataLenInBits.len,
5486 "ZUC Ciphertext data not as expected");
5488 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5491 DIGEST_BYTE_LENGTH_KASUMI_F9,
5492 "ZUC Generated auth tag not as expected");
5498 test_kasumi_encryption_test_case_1(void)
5500 return test_kasumi_encryption(&kasumi_test_case_1);
5504 test_kasumi_encryption_test_case_1_sgl(void)
5506 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5510 test_kasumi_encryption_test_case_1_oop(void)
5512 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5516 test_kasumi_encryption_test_case_1_oop_sgl(void)
5518 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5522 test_kasumi_encryption_test_case_2(void)
5524 return test_kasumi_encryption(&kasumi_test_case_2);
5528 test_kasumi_encryption_test_case_3(void)
5530 return test_kasumi_encryption(&kasumi_test_case_3);
5534 test_kasumi_encryption_test_case_4(void)
5536 return test_kasumi_encryption(&kasumi_test_case_4);
5540 test_kasumi_encryption_test_case_5(void)
5542 return test_kasumi_encryption(&kasumi_test_case_5);
5546 test_kasumi_decryption_test_case_1(void)
5548 return test_kasumi_decryption(&kasumi_test_case_1);
5552 test_kasumi_decryption_test_case_1_oop(void)
5554 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5558 test_kasumi_decryption_test_case_2(void)
5560 return test_kasumi_decryption(&kasumi_test_case_2);
5564 test_kasumi_decryption_test_case_3(void)
5566 return test_kasumi_decryption(&kasumi_test_case_3);
5570 test_kasumi_decryption_test_case_4(void)
5572 return test_kasumi_decryption(&kasumi_test_case_4);
5576 test_kasumi_decryption_test_case_5(void)
5578 return test_kasumi_decryption(&kasumi_test_case_5);
5581 test_snow3g_encryption_test_case_1(void)
5583 return test_snow3g_encryption(&snow3g_test_case_1);
5587 test_snow3g_encryption_test_case_1_oop(void)
5589 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5593 test_snow3g_encryption_test_case_1_oop_sgl(void)
5595 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5600 test_snow3g_encryption_test_case_1_offset_oop(void)
5602 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5606 test_snow3g_encryption_test_case_2(void)
5608 return test_snow3g_encryption(&snow3g_test_case_2);
5612 test_snow3g_encryption_test_case_3(void)
5614 return test_snow3g_encryption(&snow3g_test_case_3);
5618 test_snow3g_encryption_test_case_4(void)
5620 return test_snow3g_encryption(&snow3g_test_case_4);
5624 test_snow3g_encryption_test_case_5(void)
5626 return test_snow3g_encryption(&snow3g_test_case_5);
5630 test_snow3g_decryption_test_case_1(void)
5632 return test_snow3g_decryption(&snow3g_test_case_1);
5636 test_snow3g_decryption_test_case_1_oop(void)
5638 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5642 test_snow3g_decryption_test_case_2(void)
5644 return test_snow3g_decryption(&snow3g_test_case_2);
5648 test_snow3g_decryption_test_case_3(void)
5650 return test_snow3g_decryption(&snow3g_test_case_3);
5654 test_snow3g_decryption_test_case_4(void)
5656 return test_snow3g_decryption(&snow3g_test_case_4);
5660 test_snow3g_decryption_test_case_5(void)
5662 return test_snow3g_decryption(&snow3g_test_case_5);
5666 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5667 * Pattern digest from snow3g_test_data must be allocated as
5668 * 4 last bytes in plaintext.
5671 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5672 struct snow3g_hash_test_data *output)
5674 if ((pattern != NULL) && (output != NULL)) {
5675 output->key.len = pattern->key.len;
5677 memcpy(output->key.data,
5678 pattern->key.data, pattern->key.len);
5680 output->auth_iv.len = pattern->auth_iv.len;
5682 memcpy(output->auth_iv.data,
5683 pattern->auth_iv.data, pattern->auth_iv.len);
5685 output->plaintext.len = pattern->plaintext.len;
5687 memcpy(output->plaintext.data,
5688 pattern->plaintext.data, pattern->plaintext.len >> 3);
5690 output->digest.len = pattern->digest.len;
5692 memcpy(output->digest.data,
5693 &pattern->plaintext.data[pattern->digest.offset_bytes],
5694 pattern->digest.len);
5696 output->validAuthLenInBits.len =
5697 pattern->validAuthLenInBits.len;
5702 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5705 test_snow3g_decryption_with_digest_test_case_1(void)
5707 struct snow3g_hash_test_data snow3g_hash_data;
5710 * Function prepare data for hash veryfication test case.
5711 * Digest is allocated in 4 last bytes in plaintext, pattern.
5713 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5715 return test_snow3g_decryption(&snow3g_test_case_7) &
5716 test_snow3g_authentication_verify(&snow3g_hash_data);
5720 test_snow3g_cipher_auth_test_case_1(void)
5722 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5726 test_snow3g_auth_cipher_test_case_1(void)
5728 return test_snow3g_auth_cipher(
5729 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5733 test_snow3g_auth_cipher_test_case_2(void)
5735 return test_snow3g_auth_cipher(
5736 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5740 test_snow3g_auth_cipher_test_case_2_oop(void)
5742 return test_snow3g_auth_cipher(
5743 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5747 test_snow3g_auth_cipher_part_digest_enc(void)
5749 return test_snow3g_auth_cipher(
5750 &snow3g_auth_cipher_partial_digest_encryption,
5755 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5757 return test_snow3g_auth_cipher(
5758 &snow3g_auth_cipher_partial_digest_encryption,
5763 test_snow3g_auth_cipher_test_case_3_sgl(void)
5765 return test_snow3g_auth_cipher_sgl(
5766 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5770 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5772 return test_snow3g_auth_cipher_sgl(
5773 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5777 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5779 return test_snow3g_auth_cipher_sgl(
5780 &snow3g_auth_cipher_partial_digest_encryption,
5785 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5787 return test_snow3g_auth_cipher_sgl(
5788 &snow3g_auth_cipher_partial_digest_encryption,
5793 test_snow3g_auth_cipher_verify_test_case_1(void)
5795 return test_snow3g_auth_cipher(
5796 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5800 test_snow3g_auth_cipher_verify_test_case_2(void)
5802 return test_snow3g_auth_cipher(
5803 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5807 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5809 return test_snow3g_auth_cipher(
5810 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5814 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5816 return test_snow3g_auth_cipher(
5817 &snow3g_auth_cipher_partial_digest_encryption,
5822 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5824 return test_snow3g_auth_cipher(
5825 &snow3g_auth_cipher_partial_digest_encryption,
5830 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5832 return test_snow3g_auth_cipher_sgl(
5833 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5837 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5839 return test_snow3g_auth_cipher_sgl(
5840 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5844 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5846 return test_snow3g_auth_cipher_sgl(
5847 &snow3g_auth_cipher_partial_digest_encryption,
5852 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5854 return test_snow3g_auth_cipher_sgl(
5855 &snow3g_auth_cipher_partial_digest_encryption,
5860 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5862 return test_snow3g_auth_cipher(
5863 &snow3g_test_case_7, IN_PLACE, 0);
5867 test_kasumi_auth_cipher_test_case_1(void)
5869 return test_kasumi_auth_cipher(
5870 &kasumi_test_case_3, IN_PLACE, 0);
5874 test_kasumi_auth_cipher_test_case_2(void)
5876 return test_kasumi_auth_cipher(
5877 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5881 test_kasumi_auth_cipher_test_case_2_oop(void)
5883 return test_kasumi_auth_cipher(
5884 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5888 test_kasumi_auth_cipher_test_case_2_sgl(void)
5890 return test_kasumi_auth_cipher_sgl(
5891 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5895 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5897 return test_kasumi_auth_cipher_sgl(
5898 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5902 test_kasumi_auth_cipher_verify_test_case_1(void)
5904 return test_kasumi_auth_cipher(
5905 &kasumi_test_case_3, IN_PLACE, 1);
5909 test_kasumi_auth_cipher_verify_test_case_2(void)
5911 return test_kasumi_auth_cipher(
5912 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5916 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5918 return test_kasumi_auth_cipher(
5919 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5923 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5925 return test_kasumi_auth_cipher_sgl(
5926 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5930 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5932 return test_kasumi_auth_cipher_sgl(
5933 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5937 test_kasumi_cipher_auth_test_case_1(void)
5939 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5943 test_zuc_encryption_test_case_1(void)
5945 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5949 test_zuc_encryption_test_case_2(void)
5951 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5955 test_zuc_encryption_test_case_3(void)
5957 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5961 test_zuc_encryption_test_case_4(void)
5963 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5967 test_zuc_encryption_test_case_5(void)
5969 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5973 test_zuc_encryption_test_case_6_sgl(void)
5975 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5979 test_zuc_hash_generate_test_case_1(void)
5981 return test_zuc_authentication(&zuc_test_case_auth_1b);
5985 test_zuc_hash_generate_test_case_2(void)
5987 return test_zuc_authentication(&zuc_test_case_auth_90b);
5991 test_zuc_hash_generate_test_case_3(void)
5993 return test_zuc_authentication(&zuc_test_case_auth_577b);
5997 test_zuc_hash_generate_test_case_4(void)
5999 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6003 test_zuc_hash_generate_test_case_5(void)
6005 return test_zuc_authentication(&zuc_test_auth_5670b);
6009 test_zuc_hash_generate_test_case_6(void)
6011 return test_zuc_authentication(&zuc_test_case_auth_128b);
6015 test_zuc_hash_generate_test_case_7(void)
6017 /* This test is not for SW ZUC PMD */
6018 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6019 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6022 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6026 test_zuc_hash_generate_test_case_8(void)
6028 return test_zuc_authentication(&zuc_test_case_auth_584b);
6032 test_zuc_cipher_auth_test_case_1(void)
6034 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6038 test_zuc_cipher_auth_test_case_2(void)
6040 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6044 test_zuc_auth_cipher_test_case_1(void)
6046 /* This test is not for SW ZUC PMD */
6047 if (gbl_driver_id == rte_cryptodev_driver_id_get(
6048 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)))
6051 return test_zuc_auth_cipher(
6052 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6056 test_zuc_auth_cipher_test_case_1_oop(void)
6058 return test_zuc_auth_cipher(
6059 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6063 test_zuc_auth_cipher_test_case_1_sgl(void)
6065 return test_zuc_auth_cipher_sgl(
6066 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6070 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6072 return test_zuc_auth_cipher_sgl(
6073 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6077 test_zuc_auth_cipher_verify_test_case_1(void)
6079 return test_zuc_auth_cipher(
6080 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6084 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6086 return test_zuc_auth_cipher(
6087 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6091 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6093 return test_zuc_auth_cipher_sgl(
6094 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6098 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6100 return test_zuc_auth_cipher_sgl(
6101 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6105 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6107 uint8_t dev_id = testsuite_params.valid_devs[0];
6109 struct rte_cryptodev_sym_capability_idx cap_idx;
6111 /* Check if device supports particular cipher algorithm */
6112 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6113 cap_idx.algo.cipher = tdata->cipher_algo;
6114 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6117 /* Check if device supports particular hash algorithm */
6118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6119 cap_idx.algo.auth = tdata->auth_algo;
6120 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6127 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6128 uint8_t op_mode, uint8_t verify)
6130 struct crypto_testsuite_params *ts_params = &testsuite_params;
6131 struct crypto_unittest_params *ut_params = &unittest_params;
6135 uint8_t *plaintext = NULL, *ciphertext = NULL;
6136 unsigned int plaintext_pad_len;
6137 unsigned int plaintext_len;
6138 unsigned int ciphertext_pad_len;
6139 unsigned int ciphertext_len;
6141 struct rte_cryptodev_info dev_info;
6142 struct rte_crypto_op *op;
6144 /* Check if device supports particular algorithms separately */
6145 if (test_mixed_check_if_unsupported(tdata))
6148 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6150 uint64_t feat_flags = dev_info.feature_flags;
6152 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6153 printf("Device doesn't support digest encrypted.\n");
6157 /* Create the session */
6159 retval = create_wireless_algo_cipher_auth_session(
6160 ts_params->valid_devs[0],
6161 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6162 RTE_CRYPTO_AUTH_OP_VERIFY,
6165 tdata->auth_key.data, tdata->auth_key.len,
6166 tdata->auth_iv.len, tdata->digest_enc.len,
6167 tdata->cipher_iv.len);
6169 retval = create_wireless_algo_auth_cipher_session(
6170 ts_params->valid_devs[0],
6171 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6172 RTE_CRYPTO_AUTH_OP_GENERATE,
6175 tdata->auth_key.data, tdata->auth_key.len,
6176 tdata->auth_iv.len, tdata->digest_enc.len,
6177 tdata->cipher_iv.len);
6181 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6182 if (op_mode == OUT_OF_PLACE)
6183 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6185 /* clear mbuf payload */
6186 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6187 rte_pktmbuf_tailroom(ut_params->ibuf));
6188 if (op_mode == OUT_OF_PLACE)
6189 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6190 rte_pktmbuf_tailroom(ut_params->obuf));
6192 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6193 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6194 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6198 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6199 ciphertext_pad_len);
6200 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6201 if (op_mode == OUT_OF_PLACE)
6202 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6203 debug_hexdump(stdout, "ciphertext:", ciphertext,
6206 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6208 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6209 if (op_mode == OUT_OF_PLACE)
6210 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6211 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6214 /* Create the operation */
6215 retval = create_wireless_algo_auth_cipher_operation(
6216 tdata->digest_enc.data, tdata->digest_enc.len,
6217 tdata->cipher_iv.data, tdata->cipher_iv.len,
6218 tdata->auth_iv.data, tdata->auth_iv.len,
6219 (tdata->digest_enc.offset == 0 ?
6221 : tdata->digest_enc.offset),
6222 tdata->validCipherLen.len_bits,
6223 tdata->cipher.offset_bits,
6224 tdata->validAuthLen.len_bits,
6225 tdata->auth.offset_bits,
6226 op_mode, 0, verify);
6231 op = process_crypto_request(ts_params->valid_devs[0],
6234 /* Check if the op failed because the device doesn't */
6235 /* support this particular combination of algorithms */
6236 if (op == NULL && ut_params->op->status ==
6237 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6238 printf("Device doesn't support this mixed combination. "
6244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6246 ut_params->obuf = (op_mode == IN_PLACE ?
6247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6250 if (ut_params->obuf)
6251 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6254 plaintext = ciphertext +
6255 (tdata->cipher.offset_bits >> 3);
6257 debug_hexdump(stdout, "plaintext:", plaintext,
6258 tdata->plaintext.len_bits >> 3);
6259 debug_hexdump(stdout, "plaintext expected:",
6260 tdata->plaintext.data,
6261 tdata->plaintext.len_bits >> 3);
6263 if (ut_params->obuf)
6264 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6267 ciphertext = plaintext;
6269 debug_hexdump(stdout, "ciphertext:", ciphertext,
6271 debug_hexdump(stdout, "ciphertext expected:",
6272 tdata->ciphertext.data,
6273 tdata->ciphertext.len_bits >> 3);
6275 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6276 + (tdata->digest_enc.offset == 0 ?
6277 plaintext_pad_len : tdata->digest_enc.offset);
6279 debug_hexdump(stdout, "digest:", ut_params->digest,
6280 tdata->digest_enc.len);
6281 debug_hexdump(stdout, "digest expected:",
6282 tdata->digest_enc.data,
6283 tdata->digest_enc.len);
6288 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6290 tdata->plaintext.data,
6291 tdata->plaintext.len_bits >> 3,
6292 "Plaintext data not as expected");
6294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6296 tdata->ciphertext.data,
6297 tdata->validDataLen.len_bits,
6298 "Ciphertext data not as expected");
6300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6302 tdata->digest_enc.data,
6303 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6304 "Generated auth tag not as expected");
6307 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6308 "crypto op processing failed");
6314 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6315 uint8_t op_mode, uint8_t verify)
6317 struct crypto_testsuite_params *ts_params = &testsuite_params;
6318 struct crypto_unittest_params *ut_params = &unittest_params;
6322 const uint8_t *plaintext = NULL;
6323 const uint8_t *ciphertext = NULL;
6324 const uint8_t *digest = NULL;
6325 unsigned int plaintext_pad_len;
6326 unsigned int plaintext_len;
6327 unsigned int ciphertext_pad_len;
6328 unsigned int ciphertext_len;
6329 uint8_t buffer[10000];
6330 uint8_t digest_buffer[10000];
6332 struct rte_cryptodev_info dev_info;
6333 struct rte_crypto_op *op;
6335 /* Check if device supports particular algorithms */
6336 if (test_mixed_check_if_unsupported(tdata))
6339 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6341 uint64_t feat_flags = dev_info.feature_flags;
6343 if (op_mode == IN_PLACE) {
6344 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6345 printf("Device doesn't support in-place scatter-gather "
6346 "in both input and output mbufs.\n");
6350 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6351 printf("Device doesn't support out-of-place scatter-gather "
6352 "in both input and output mbufs.\n");
6355 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6356 printf("Device doesn't support digest encrypted.\n");
6361 /* Create the session */
6363 retval = create_wireless_algo_cipher_auth_session(
6364 ts_params->valid_devs[0],
6365 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6366 RTE_CRYPTO_AUTH_OP_VERIFY,
6369 tdata->auth_key.data, tdata->auth_key.len,
6370 tdata->auth_iv.len, tdata->digest_enc.len,
6371 tdata->cipher_iv.len);
6373 retval = create_wireless_algo_auth_cipher_session(
6374 ts_params->valid_devs[0],
6375 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6376 RTE_CRYPTO_AUTH_OP_GENERATE,
6379 tdata->auth_key.data, tdata->auth_key.len,
6380 tdata->auth_iv.len, tdata->digest_enc.len,
6381 tdata->cipher_iv.len);
6385 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6386 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6387 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6388 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6390 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6391 ciphertext_pad_len, 15, 0);
6392 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6393 "Failed to allocate input buffer in mempool");
6395 if (op_mode == OUT_OF_PLACE) {
6396 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6397 plaintext_pad_len, 15, 0);
6398 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6399 "Failed to allocate output buffer in mempool");
6403 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6404 tdata->ciphertext.data);
6405 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6406 ciphertext_len, buffer);
6407 debug_hexdump(stdout, "ciphertext:", ciphertext,
6410 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6411 tdata->plaintext.data);
6412 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6413 plaintext_len, buffer);
6414 debug_hexdump(stdout, "plaintext:", plaintext,
6417 memset(buffer, 0, sizeof(buffer));
6419 /* Create the operation */
6420 retval = create_wireless_algo_auth_cipher_operation(
6421 tdata->digest_enc.data, tdata->digest_enc.len,
6422 tdata->cipher_iv.data, tdata->cipher_iv.len,
6423 tdata->auth_iv.data, tdata->auth_iv.len,
6424 (tdata->digest_enc.offset == 0 ?
6426 : tdata->digest_enc.offset),
6427 tdata->validCipherLen.len_bits,
6428 tdata->cipher.offset_bits,
6429 tdata->validAuthLen.len_bits,
6430 tdata->auth.offset_bits,
6431 op_mode, 1, verify);
6436 op = process_crypto_request(ts_params->valid_devs[0],
6439 /* Check if the op failed because the device doesn't */
6440 /* support this particular combination of algorithms */
6441 if (op == NULL && ut_params->op->status ==
6442 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6443 printf("Device doesn't support this mixed combination. "
6450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6452 ut_params->obuf = (op_mode == IN_PLACE ?
6453 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6456 if (ut_params->obuf)
6457 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6458 plaintext_len, buffer);
6460 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6461 plaintext_len, buffer);
6463 debug_hexdump(stdout, "plaintext:", plaintext,
6464 (tdata->plaintext.len_bits >> 3) -
6465 tdata->digest_enc.len);
6466 debug_hexdump(stdout, "plaintext expected:",
6467 tdata->plaintext.data,
6468 (tdata->plaintext.len_bits >> 3) -
6469 tdata->digest_enc.len);
6471 if (ut_params->obuf)
6472 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6473 ciphertext_len, buffer);
6475 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6476 ciphertext_len, buffer);
6478 debug_hexdump(stdout, "ciphertext:", ciphertext,
6480 debug_hexdump(stdout, "ciphertext expected:",
6481 tdata->ciphertext.data,
6482 tdata->ciphertext.len_bits >> 3);
6484 if (ut_params->obuf)
6485 digest = rte_pktmbuf_read(ut_params->obuf,
6486 (tdata->digest_enc.offset == 0 ?
6488 tdata->digest_enc.offset),
6489 tdata->digest_enc.len, digest_buffer);
6491 digest = rte_pktmbuf_read(ut_params->ibuf,
6492 (tdata->digest_enc.offset == 0 ?
6494 tdata->digest_enc.offset),
6495 tdata->digest_enc.len, digest_buffer);
6497 debug_hexdump(stdout, "digest:", digest,
6498 tdata->digest_enc.len);
6499 debug_hexdump(stdout, "digest expected:",
6500 tdata->digest_enc.data, tdata->digest_enc.len);
6505 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6507 tdata->plaintext.data,
6508 tdata->plaintext.len_bits >> 3,
6509 "Plaintext data not as expected");
6511 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6513 tdata->ciphertext.data,
6514 tdata->validDataLen.len_bits,
6515 "Ciphertext data not as expected");
6516 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6518 tdata->digest_enc.data,
6519 tdata->digest_enc.len,
6520 "Generated auth tag not as expected");
6523 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6524 "crypto op processing failed");
6529 /** AUTH AES CMAC + CIPHER AES CTR */
6532 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6534 return test_mixed_auth_cipher(
6535 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6541 return test_mixed_auth_cipher(
6542 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6546 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6548 return test_mixed_auth_cipher_sgl(
6549 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6553 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6555 return test_mixed_auth_cipher_sgl(
6556 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6560 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6562 return test_mixed_auth_cipher(
6563 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6567 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6569 return test_mixed_auth_cipher(
6570 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6574 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6576 return test_mixed_auth_cipher_sgl(
6577 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6581 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6583 return test_mixed_auth_cipher_sgl(
6584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6587 /** MIXED AUTH + CIPHER */
6590 test_auth_zuc_cipher_snow_test_case_1(void)
6592 return test_mixed_auth_cipher(
6593 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6597 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6599 return test_mixed_auth_cipher(
6600 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6604 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6606 return test_mixed_auth_cipher(
6607 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6611 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6613 return test_mixed_auth_cipher(
6614 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6618 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6620 return test_mixed_auth_cipher(
6621 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6625 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6627 return test_mixed_auth_cipher(
6628 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6632 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6634 return test_mixed_auth_cipher(
6635 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6639 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6641 return test_mixed_auth_cipher(
6642 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6646 test_auth_snow_cipher_zuc_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6653 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6655 return test_mixed_auth_cipher(
6656 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6660 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6667 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6669 return test_mixed_auth_cipher(
6670 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6674 test_auth_null_cipher_snow_test_case_1(void)
6676 return test_mixed_auth_cipher(
6677 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6681 test_verify_auth_null_cipher_snow_test_case_1(void)
6683 return test_mixed_auth_cipher(
6684 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6688 test_auth_null_cipher_zuc_test_case_1(void)
6690 return test_mixed_auth_cipher(
6691 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6695 test_verify_auth_null_cipher_zuc_test_case_1(void)
6697 return test_mixed_auth_cipher(
6698 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6702 test_auth_snow_cipher_null_test_case_1(void)
6704 return test_mixed_auth_cipher(
6705 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6709 test_verify_auth_snow_cipher_null_test_case_1(void)
6711 return test_mixed_auth_cipher(
6712 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6716 test_auth_zuc_cipher_null_test_case_1(void)
6718 return test_mixed_auth_cipher(
6719 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6723 test_verify_auth_zuc_cipher_null_test_case_1(void)
6725 return test_mixed_auth_cipher(
6726 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6730 test_auth_null_cipher_aes_ctr_test_case_1(void)
6732 return test_mixed_auth_cipher(
6733 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6737 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6739 return test_mixed_auth_cipher(
6740 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6744 test_auth_aes_cmac_cipher_null_test_case_1(void)
6746 return test_mixed_auth_cipher(
6747 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6751 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6753 return test_mixed_auth_cipher(
6754 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6757 /* ***** AEAD algorithm Tests ***** */
6760 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6761 enum rte_crypto_aead_operation op,
6762 const uint8_t *key, const uint8_t key_len,
6763 const uint16_t aad_len, const uint8_t auth_len,
6766 uint8_t aead_key[key_len];
6768 struct crypto_testsuite_params *ts_params = &testsuite_params;
6769 struct crypto_unittest_params *ut_params = &unittest_params;
6771 memcpy(aead_key, key, key_len);
6773 /* Setup AEAD Parameters */
6774 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6775 ut_params->aead_xform.next = NULL;
6776 ut_params->aead_xform.aead.algo = algo;
6777 ut_params->aead_xform.aead.op = op;
6778 ut_params->aead_xform.aead.key.data = aead_key;
6779 ut_params->aead_xform.aead.key.length = key_len;
6780 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6781 ut_params->aead_xform.aead.iv.length = iv_len;
6782 ut_params->aead_xform.aead.digest_length = auth_len;
6783 ut_params->aead_xform.aead.aad_length = aad_len;
6785 debug_hexdump(stdout, "key:", key, key_len);
6787 /* Create Crypto session*/
6788 ut_params->sess = rte_cryptodev_sym_session_create(
6789 ts_params->session_mpool);
6791 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6792 &ut_params->aead_xform,
6793 ts_params->session_priv_mpool);
6795 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6801 create_aead_xform(struct rte_crypto_op *op,
6802 enum rte_crypto_aead_algorithm algo,
6803 enum rte_crypto_aead_operation aead_op,
6804 uint8_t *key, const uint8_t key_len,
6805 const uint8_t aad_len, const uint8_t auth_len,
6808 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6809 "failed to allocate space for crypto transform");
6811 struct rte_crypto_sym_op *sym_op = op->sym;
6813 /* Setup AEAD Parameters */
6814 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6815 sym_op->xform->next = NULL;
6816 sym_op->xform->aead.algo = algo;
6817 sym_op->xform->aead.op = aead_op;
6818 sym_op->xform->aead.key.data = key;
6819 sym_op->xform->aead.key.length = key_len;
6820 sym_op->xform->aead.iv.offset = IV_OFFSET;
6821 sym_op->xform->aead.iv.length = iv_len;
6822 sym_op->xform->aead.digest_length = auth_len;
6823 sym_op->xform->aead.aad_length = aad_len;
6825 debug_hexdump(stdout, "key:", key, key_len);
6831 create_aead_operation(enum rte_crypto_aead_operation op,
6832 const struct aead_test_data *tdata)
6834 struct crypto_testsuite_params *ts_params = &testsuite_params;
6835 struct crypto_unittest_params *ut_params = &unittest_params;
6837 uint8_t *plaintext, *ciphertext;
6838 unsigned int aad_pad_len, plaintext_pad_len;
6840 /* Generate Crypto op data structure */
6841 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6842 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6843 TEST_ASSERT_NOT_NULL(ut_params->op,
6844 "Failed to allocate symmetric crypto operation struct");
6846 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6848 /* Append aad data */
6849 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6850 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6851 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6853 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6854 "no room to append aad");
6856 sym_op->aead.aad.phys_addr =
6857 rte_pktmbuf_iova(ut_params->ibuf);
6858 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6859 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6860 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6863 /* Append IV at the end of the crypto operation*/
6864 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6865 uint8_t *, IV_OFFSET);
6867 /* Copy IV 1 byte after the IV pointer, according to the API */
6868 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6869 debug_hexdump(stdout, "iv:", iv_ptr,
6872 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6873 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6875 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6876 "no room to append aad");
6878 sym_op->aead.aad.phys_addr =
6879 rte_pktmbuf_iova(ut_params->ibuf);
6880 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6881 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6884 /* Append IV at the end of the crypto operation*/
6885 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6886 uint8_t *, IV_OFFSET);
6888 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6889 debug_hexdump(stdout, "iv:", iv_ptr,
6893 /* Append plaintext/ciphertext */
6894 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6895 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6896 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6898 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6900 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6901 debug_hexdump(stdout, "plaintext:", plaintext,
6902 tdata->plaintext.len);
6904 if (ut_params->obuf) {
6905 ciphertext = (uint8_t *)rte_pktmbuf_append(
6907 plaintext_pad_len + aad_pad_len);
6908 TEST_ASSERT_NOT_NULL(ciphertext,
6909 "no room to append ciphertext");
6911 memset(ciphertext + aad_pad_len, 0,
6912 tdata->ciphertext.len);
6915 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6916 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6918 TEST_ASSERT_NOT_NULL(ciphertext,
6919 "no room to append ciphertext");
6921 memcpy(ciphertext, tdata->ciphertext.data,
6922 tdata->ciphertext.len);
6923 debug_hexdump(stdout, "ciphertext:", ciphertext,
6924 tdata->ciphertext.len);
6926 if (ut_params->obuf) {
6927 plaintext = (uint8_t *)rte_pktmbuf_append(
6929 plaintext_pad_len + aad_pad_len);
6930 TEST_ASSERT_NOT_NULL(plaintext,
6931 "no room to append plaintext");
6933 memset(plaintext + aad_pad_len, 0,
6934 tdata->plaintext.len);
6938 /* Append digest data */
6939 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6940 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6941 ut_params->obuf ? ut_params->obuf :
6943 tdata->auth_tag.len);
6944 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6945 "no room to append digest");
6946 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6947 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6948 ut_params->obuf ? ut_params->obuf :
6953 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6954 ut_params->ibuf, tdata->auth_tag.len);
6955 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6956 "no room to append digest");
6957 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6959 plaintext_pad_len + aad_pad_len);
6961 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6962 tdata->auth_tag.len);
6963 debug_hexdump(stdout, "digest:",
6964 sym_op->aead.digest.data,
6965 tdata->auth_tag.len);
6968 sym_op->aead.data.length = tdata->plaintext.len;
6969 sym_op->aead.data.offset = aad_pad_len;
6975 test_authenticated_encryption(const struct aead_test_data *tdata)
6977 struct crypto_testsuite_params *ts_params = &testsuite_params;
6978 struct crypto_unittest_params *ut_params = &unittest_params;
6981 uint8_t *ciphertext, *auth_tag;
6982 uint16_t plaintext_pad_len;
6985 /* Verify the capabilities */
6986 struct rte_cryptodev_sym_capability_idx cap_idx;
6987 const struct rte_cryptodev_symmetric_capability *capability;
6988 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6989 cap_idx.algo.aead = tdata->algo;
6990 capability = rte_cryptodev_sym_capability_get(
6991 ts_params->valid_devs[0], &cap_idx);
6992 if (capability == NULL)
6994 if (rte_cryptodev_sym_capability_check_aead(
6995 capability, tdata->key.len, tdata->auth_tag.len,
6996 tdata->aad.len, tdata->iv.len))
6999 /* Create AEAD session */
7000 retval = create_aead_session(ts_params->valid_devs[0],
7002 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7003 tdata->key.data, tdata->key.len,
7004 tdata->aad.len, tdata->auth_tag.len,
7009 if (tdata->aad.len > MBUF_SIZE) {
7010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7011 /* Populate full size of add data */
7012 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7013 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7015 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7017 /* clear mbuf payload */
7018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7019 rte_pktmbuf_tailroom(ut_params->ibuf));
7021 /* Create AEAD operation */
7022 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7026 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7028 ut_params->op->sym->m_src = ut_params->ibuf;
7030 /* Process crypto operation */
7031 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7032 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7034 TEST_ASSERT_NOT_NULL(
7035 process_crypto_request(ts_params->valid_devs[0],
7036 ut_params->op), "failed to process sym crypto op");
7038 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7039 "crypto op processing failed");
7041 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7043 if (ut_params->op->sym->m_dst) {
7044 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7046 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7047 uint8_t *, plaintext_pad_len);
7049 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7051 ut_params->op->sym->cipher.data.offset);
7052 auth_tag = ciphertext + plaintext_pad_len;
7055 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7056 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7059 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7061 tdata->ciphertext.data,
7062 tdata->ciphertext.len,
7063 "Ciphertext data not as expected");
7065 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7067 tdata->auth_tag.data,
7068 tdata->auth_tag.len,
7069 "Generated auth tag not as expected");
7075 #ifdef RTE_LIBRTE_SECURITY
7076 /* Basic algorithm run function for async inplace mode.
7077 * Creates a session from input parameters and runs one operation
7078 * on input_vec. Checks the output of the crypto operation against
7082 test_pdcp_proto(int i, int oop,
7083 enum rte_crypto_cipher_operation opc,
7084 enum rte_crypto_auth_operation opa,
7086 unsigned int input_vec_len,
7087 uint8_t *output_vec,
7088 unsigned int output_vec_len)
7090 struct crypto_testsuite_params *ts_params = &testsuite_params;
7091 struct crypto_unittest_params *ut_params = &unittest_params;
7093 int ret = TEST_SUCCESS;
7094 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7095 rte_cryptodev_get_sec_ctx(
7096 ts_params->valid_devs[0]);
7098 /* Verify the capabilities */
7099 struct rte_security_capability_idx sec_cap_idx;
7101 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7102 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7103 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7104 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7107 /* Generate test mbuf data */
7108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7110 /* clear mbuf payload */
7111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7112 rte_pktmbuf_tailroom(ut_params->ibuf));
7114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7116 memcpy(plaintext, input_vec, input_vec_len);
7118 /* Out of place support */
7121 * For out-op-place we need to alloc another mbuf
7123 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7124 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7127 /* Set crypto type as IPSEC */
7128 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7130 /* Setup Cipher Parameters */
7131 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7132 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7133 ut_params->cipher_xform.cipher.op = opc;
7134 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7135 ut_params->cipher_xform.cipher.key.length =
7136 pdcp_test_params[i].cipher_key_len;
7137 ut_params->cipher_xform.cipher.iv.length = 0;
7139 /* Setup HMAC Parameters if ICV header is required */
7140 if (pdcp_test_params[i].auth_alg != 0) {
7141 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7142 ut_params->auth_xform.next = NULL;
7143 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7144 ut_params->auth_xform.auth.op = opa;
7145 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7146 ut_params->auth_xform.auth.key.length =
7147 pdcp_test_params[i].auth_key_len;
7149 ut_params->cipher_xform.next = &ut_params->auth_xform;
7151 ut_params->cipher_xform.next = NULL;
7154 struct rte_security_session_conf sess_conf = {
7155 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7156 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7158 .bearer = pdcp_test_bearer[i],
7159 .domain = pdcp_test_params[i].domain,
7160 .pkt_dir = pdcp_test_packet_direction[i],
7161 .sn_size = pdcp_test_data_sn_size[i],
7162 .hfn = pdcp_test_hfn[i],
7163 .hfn_threshold = pdcp_test_hfn_threshold[i],
7165 .crypto_xform = &ut_params->cipher_xform
7168 /* Create security session */
7169 ut_params->sec_session = rte_security_session_create(ctx,
7170 &sess_conf, ts_params->session_priv_mpool);
7172 if (!ut_params->sec_session) {
7173 printf("TestCase %s()-%d line %d failed %s: ",
7174 __func__, i, __LINE__, "Failed to allocate session");
7179 /* Generate crypto op data structure */
7180 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7181 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7182 if (!ut_params->op) {
7183 printf("TestCase %s()-%d line %d failed %s: ",
7184 __func__, i, __LINE__,
7185 "Failed to allocate symmetric crypto operation struct");
7190 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7192 /* set crypto operation source mbuf */
7193 ut_params->op->sym->m_src = ut_params->ibuf;
7195 ut_params->op->sym->m_dst = ut_params->obuf;
7197 /* Process crypto operation */
7198 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7200 printf("TestCase %s()-%d line %d failed %s: ",
7201 __func__, i, __LINE__,
7202 "failed to process sym crypto op");
7207 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7208 printf("TestCase %s()-%d line %d failed %s: ",
7209 __func__, i, __LINE__, "crypto op processing failed");
7215 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7218 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7222 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7223 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7224 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7225 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7231 rte_crypto_op_free(ut_params->op);
7232 ut_params->op = NULL;
7234 if (ut_params->sec_session)
7235 rte_security_session_destroy(ctx, ut_params->sec_session);
7236 ut_params->sec_session = NULL;
7238 rte_pktmbuf_free(ut_params->ibuf);
7239 ut_params->ibuf = NULL;
7241 rte_pktmbuf_free(ut_params->obuf);
7242 ut_params->obuf = NULL;
7249 test_pdcp_proto_SGL(int i, int oop,
7250 enum rte_crypto_cipher_operation opc,
7251 enum rte_crypto_auth_operation opa,
7253 unsigned int input_vec_len,
7254 uint8_t *output_vec,
7255 unsigned int output_vec_len,
7257 uint32_t fragsz_oop)
7259 struct crypto_testsuite_params *ts_params = &testsuite_params;
7260 struct crypto_unittest_params *ut_params = &unittest_params;
7262 struct rte_mbuf *buf, *buf_oop = NULL;
7263 int ret = TEST_SUCCESS;
7267 unsigned int trn_data = 0;
7268 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7269 rte_cryptodev_get_sec_ctx(
7270 ts_params->valid_devs[0]);
7272 /* Verify the capabilities */
7273 struct rte_security_capability_idx sec_cap_idx;
7275 sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7276 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7277 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7278 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7281 if (fragsz > input_vec_len)
7282 fragsz = input_vec_len;
7284 uint16_t plaintext_len = fragsz;
7285 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7287 if (fragsz_oop > output_vec_len)
7288 frag_size_oop = output_vec_len;
7291 if (input_vec_len % fragsz != 0) {
7292 if (input_vec_len / fragsz + 1 > 16)
7294 } else if (input_vec_len / fragsz > 16)
7297 /* Out of place support */
7300 * For out-op-place we need to alloc another mbuf
7302 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7303 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7304 buf_oop = ut_params->obuf;
7307 /* Generate test mbuf data */
7308 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7310 /* clear mbuf payload */
7311 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7312 rte_pktmbuf_tailroom(ut_params->ibuf));
7314 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7316 memcpy(plaintext, input_vec, plaintext_len);
7317 trn_data += plaintext_len;
7319 buf = ut_params->ibuf;
7322 * Loop until no more fragments
7325 while (trn_data < input_vec_len) {
7327 to_trn = (input_vec_len - trn_data < fragsz) ?
7328 (input_vec_len - trn_data) : fragsz;
7330 to_trn_tbl[ecx++] = to_trn;
7332 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7335 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7336 rte_pktmbuf_tailroom(buf));
7339 if (oop && !fragsz_oop) {
7341 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7342 buf_oop = buf_oop->next;
7343 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7344 0, rte_pktmbuf_tailroom(buf_oop));
7345 rte_pktmbuf_append(buf_oop, to_trn);
7348 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7351 memcpy(plaintext, input_vec + trn_data, to_trn);
7355 ut_params->ibuf->nb_segs = segs;
7358 if (fragsz_oop && oop) {
7362 trn_data = frag_size_oop;
7363 while (trn_data < output_vec_len) {
7366 (output_vec_len - trn_data <
7368 (output_vec_len - trn_data) :
7371 to_trn_tbl[ecx++] = to_trn;
7374 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7375 buf_oop = buf_oop->next;
7376 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7377 0, rte_pktmbuf_tailroom(buf_oop));
7378 rte_pktmbuf_append(buf_oop, to_trn);
7382 ut_params->obuf->nb_segs = segs;
7385 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7387 /* Setup Cipher Parameters */
7388 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7389 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7390 ut_params->cipher_xform.cipher.op = opc;
7391 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7392 ut_params->cipher_xform.cipher.key.length =
7393 pdcp_test_params[i].cipher_key_len;
7394 ut_params->cipher_xform.cipher.iv.length = 0;
7396 /* Setup HMAC Parameters if ICV header is required */
7397 if (pdcp_test_params[i].auth_alg != 0) {
7398 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7399 ut_params->auth_xform.next = NULL;
7400 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7401 ut_params->auth_xform.auth.op = opa;
7402 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7403 ut_params->auth_xform.auth.key.length =
7404 pdcp_test_params[i].auth_key_len;
7406 ut_params->cipher_xform.next = &ut_params->auth_xform;
7408 ut_params->cipher_xform.next = NULL;
7411 struct rte_security_session_conf sess_conf = {
7412 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7413 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7415 .bearer = pdcp_test_bearer[i],
7416 .domain = pdcp_test_params[i].domain,
7417 .pkt_dir = pdcp_test_packet_direction[i],
7418 .sn_size = pdcp_test_data_sn_size[i],
7419 .hfn = pdcp_test_hfn[i],
7420 .hfn_threshold = pdcp_test_hfn_threshold[i],
7422 .crypto_xform = &ut_params->cipher_xform
7425 /* Create security session */
7426 ut_params->sec_session = rte_security_session_create(ctx,
7427 &sess_conf, ts_params->session_priv_mpool);
7429 if (!ut_params->sec_session) {
7430 printf("TestCase %s()-%d line %d failed %s: ",
7431 __func__, i, __LINE__, "Failed to allocate session");
7436 /* Generate crypto op data structure */
7437 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7438 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7439 if (!ut_params->op) {
7440 printf("TestCase %s()-%d line %d failed %s: ",
7441 __func__, i, __LINE__,
7442 "Failed to allocate symmetric crypto operation struct");
7447 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7449 /* set crypto operation source mbuf */
7450 ut_params->op->sym->m_src = ut_params->ibuf;
7452 ut_params->op->sym->m_dst = ut_params->obuf;
7454 /* Process crypto operation */
7455 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7457 printf("TestCase %s()-%d line %d failed %s: ",
7458 __func__, i, __LINE__,
7459 "failed to process sym crypto op");
7464 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7465 printf("TestCase %s()-%d line %d failed %s: ",
7466 __func__, i, __LINE__, "crypto op processing failed");
7472 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7475 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7479 fragsz = frag_size_oop;
7480 if (memcmp(ciphertext, output_vec, fragsz)) {
7481 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7482 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7483 rte_hexdump(stdout, "reference", output_vec, fragsz);
7488 buf = ut_params->op->sym->m_src->next;
7490 buf = ut_params->op->sym->m_dst->next;
7492 unsigned int off = fragsz;
7496 ciphertext = rte_pktmbuf_mtod(buf,
7498 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7499 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7500 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7501 rte_hexdump(stdout, "reference", output_vec + off,
7506 off += to_trn_tbl[ecx++];
7510 rte_crypto_op_free(ut_params->op);
7511 ut_params->op = NULL;
7513 if (ut_params->sec_session)
7514 rte_security_session_destroy(ctx, ut_params->sec_session);
7515 ut_params->sec_session = NULL;
7517 rte_pktmbuf_free(ut_params->ibuf);
7518 ut_params->ibuf = NULL;
7520 rte_pktmbuf_free(ut_params->obuf);
7521 ut_params->obuf = NULL;
7528 test_pdcp_proto_cplane_encap(int i)
7530 return test_pdcp_proto(i, 0,
7531 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7532 RTE_CRYPTO_AUTH_OP_GENERATE,
7533 pdcp_test_data_in[i],
7534 pdcp_test_data_in_len[i],
7535 pdcp_test_data_out[i],
7536 pdcp_test_data_in_len[i]+4);
7540 test_pdcp_proto_uplane_encap(int i)
7542 return test_pdcp_proto(i, 0,
7543 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7544 RTE_CRYPTO_AUTH_OP_GENERATE,
7545 pdcp_test_data_in[i],
7546 pdcp_test_data_in_len[i],
7547 pdcp_test_data_out[i],
7548 pdcp_test_data_in_len[i]);
7553 test_pdcp_proto_uplane_encap_with_int(int i)
7555 return test_pdcp_proto(i, 0,
7556 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7557 RTE_CRYPTO_AUTH_OP_GENERATE,
7558 pdcp_test_data_in[i],
7559 pdcp_test_data_in_len[i],
7560 pdcp_test_data_out[i],
7561 pdcp_test_data_in_len[i] + 4);
7565 test_pdcp_proto_cplane_decap(int i)
7567 return test_pdcp_proto(i, 0,
7568 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7569 RTE_CRYPTO_AUTH_OP_VERIFY,
7570 pdcp_test_data_out[i],
7571 pdcp_test_data_in_len[i] + 4,
7572 pdcp_test_data_in[i],
7573 pdcp_test_data_in_len[i]);
7577 test_pdcp_proto_uplane_decap(int i)
7579 return test_pdcp_proto(i, 0,
7580 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7581 RTE_CRYPTO_AUTH_OP_VERIFY,
7582 pdcp_test_data_out[i],
7583 pdcp_test_data_in_len[i],
7584 pdcp_test_data_in[i],
7585 pdcp_test_data_in_len[i]);
7589 test_pdcp_proto_uplane_decap_with_int(int i)
7591 return test_pdcp_proto(i, 0,
7592 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7593 RTE_CRYPTO_AUTH_OP_VERIFY,
7594 pdcp_test_data_out[i],
7595 pdcp_test_data_in_len[i] + 4,
7596 pdcp_test_data_in[i],
7597 pdcp_test_data_in_len[i]);
7601 test_PDCP_PROTO_SGL_in_place_32B(void)
7603 /* i can be used for running any PDCP case
7604 * In this case it is uplane 12-bit AES-SNOW DL encap
7606 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7607 return test_pdcp_proto_SGL(i, IN_PLACE,
7608 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7609 RTE_CRYPTO_AUTH_OP_GENERATE,
7610 pdcp_test_data_in[i],
7611 pdcp_test_data_in_len[i],
7612 pdcp_test_data_out[i],
7613 pdcp_test_data_in_len[i]+4,
7617 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7619 /* i can be used for running any PDCP case
7620 * In this case it is uplane 18-bit NULL-NULL DL encap
7622 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7623 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7624 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7625 RTE_CRYPTO_AUTH_OP_GENERATE,
7626 pdcp_test_data_in[i],
7627 pdcp_test_data_in_len[i],
7628 pdcp_test_data_out[i],
7629 pdcp_test_data_in_len[i]+4,
7633 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7635 /* i can be used for running any PDCP case
7636 * In this case it is uplane 18-bit AES DL encap
7638 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7640 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7641 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7642 RTE_CRYPTO_AUTH_OP_GENERATE,
7643 pdcp_test_data_in[i],
7644 pdcp_test_data_in_len[i],
7645 pdcp_test_data_out[i],
7646 pdcp_test_data_in_len[i],
7650 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7652 /* i can be used for running any PDCP case
7653 * In this case it is cplane 12-bit AES-ZUC DL encap
7655 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7656 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7657 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7658 RTE_CRYPTO_AUTH_OP_GENERATE,
7659 pdcp_test_data_in[i],
7660 pdcp_test_data_in_len[i],
7661 pdcp_test_data_out[i],
7662 pdcp_test_data_in_len[i]+4,
7668 test_AES_GCM_authenticated_encryption_test_case_1(void)
7670 return test_authenticated_encryption(&gcm_test_case_1);
7674 test_AES_GCM_authenticated_encryption_test_case_2(void)
7676 return test_authenticated_encryption(&gcm_test_case_2);
7680 test_AES_GCM_authenticated_encryption_test_case_3(void)
7682 return test_authenticated_encryption(&gcm_test_case_3);
7686 test_AES_GCM_authenticated_encryption_test_case_4(void)
7688 return test_authenticated_encryption(&gcm_test_case_4);
7692 test_AES_GCM_authenticated_encryption_test_case_5(void)
7694 return test_authenticated_encryption(&gcm_test_case_5);
7698 test_AES_GCM_authenticated_encryption_test_case_6(void)
7700 return test_authenticated_encryption(&gcm_test_case_6);
7704 test_AES_GCM_authenticated_encryption_test_case_7(void)
7706 return test_authenticated_encryption(&gcm_test_case_7);
7710 test_AES_GCM_authenticated_encryption_test_case_8(void)
7712 return test_authenticated_encryption(&gcm_test_case_8);
7716 test_AES_GCM_auth_encryption_test_case_192_1(void)
7718 return test_authenticated_encryption(&gcm_test_case_192_1);
7722 test_AES_GCM_auth_encryption_test_case_192_2(void)
7724 return test_authenticated_encryption(&gcm_test_case_192_2);
7728 test_AES_GCM_auth_encryption_test_case_192_3(void)
7730 return test_authenticated_encryption(&gcm_test_case_192_3);
7734 test_AES_GCM_auth_encryption_test_case_192_4(void)
7736 return test_authenticated_encryption(&gcm_test_case_192_4);
7740 test_AES_GCM_auth_encryption_test_case_192_5(void)
7742 return test_authenticated_encryption(&gcm_test_case_192_5);
7746 test_AES_GCM_auth_encryption_test_case_192_6(void)
7748 return test_authenticated_encryption(&gcm_test_case_192_6);
7752 test_AES_GCM_auth_encryption_test_case_192_7(void)
7754 return test_authenticated_encryption(&gcm_test_case_192_7);
7758 test_AES_GCM_auth_encryption_test_case_256_1(void)
7760 return test_authenticated_encryption(&gcm_test_case_256_1);
7764 test_AES_GCM_auth_encryption_test_case_256_2(void)
7766 return test_authenticated_encryption(&gcm_test_case_256_2);
7770 test_AES_GCM_auth_encryption_test_case_256_3(void)
7772 return test_authenticated_encryption(&gcm_test_case_256_3);
7776 test_AES_GCM_auth_encryption_test_case_256_4(void)
7778 return test_authenticated_encryption(&gcm_test_case_256_4);
7782 test_AES_GCM_auth_encryption_test_case_256_5(void)
7784 return test_authenticated_encryption(&gcm_test_case_256_5);
7788 test_AES_GCM_auth_encryption_test_case_256_6(void)
7790 return test_authenticated_encryption(&gcm_test_case_256_6);
7794 test_AES_GCM_auth_encryption_test_case_256_7(void)
7796 return test_authenticated_encryption(&gcm_test_case_256_7);
7800 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7802 return test_authenticated_encryption(&gcm_test_case_aad_1);
7806 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7808 return test_authenticated_encryption(&gcm_test_case_aad_2);
7812 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
7814 struct aead_test_data tdata;
7817 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7818 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7819 tdata.iv.data[0] += 1;
7820 res = test_authenticated_encryption(&tdata);
7821 if (res == -ENOTSUP)
7823 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7824 return TEST_SUCCESS;
7828 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
7830 struct aead_test_data tdata;
7833 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7834 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7835 tdata.plaintext.data[0] += 1;
7836 res = test_authenticated_encryption(&tdata);
7837 if (res == -ENOTSUP)
7839 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7840 return TEST_SUCCESS;
7844 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
7846 struct aead_test_data tdata;
7849 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7850 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7851 tdata.ciphertext.data[0] += 1;
7852 res = test_authenticated_encryption(&tdata);
7853 if (res == -ENOTSUP)
7855 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7856 return TEST_SUCCESS;
7860 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
7862 struct aead_test_data tdata;
7865 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7866 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7868 res = test_authenticated_encryption(&tdata);
7869 if (res == -ENOTSUP)
7871 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7872 return TEST_SUCCESS;
7876 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
7878 struct aead_test_data tdata;
7879 uint8_t aad[gcm_test_case_7.aad.len];
7882 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7883 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7884 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
7886 tdata.aad.data = aad;
7887 res = test_authenticated_encryption(&tdata);
7888 if (res == -ENOTSUP)
7890 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7891 return TEST_SUCCESS;
7895 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
7897 struct aead_test_data tdata;
7900 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
7901 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
7902 tdata.auth_tag.data[0] += 1;
7903 res = test_authenticated_encryption(&tdata);
7904 if (res == -ENOTSUP)
7906 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
7907 return TEST_SUCCESS;
7911 test_authenticated_decryption(const struct aead_test_data *tdata)
7913 struct crypto_testsuite_params *ts_params = &testsuite_params;
7914 struct crypto_unittest_params *ut_params = &unittest_params;
7920 /* Verify the capabilities */
7921 struct rte_cryptodev_sym_capability_idx cap_idx;
7922 const struct rte_cryptodev_symmetric_capability *capability;
7923 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7924 cap_idx.algo.aead = tdata->algo;
7925 capability = rte_cryptodev_sym_capability_get(
7926 ts_params->valid_devs[0], &cap_idx);
7927 if (capability == NULL)
7929 if (rte_cryptodev_sym_capability_check_aead(
7930 capability, tdata->key.len, tdata->auth_tag.len,
7931 tdata->aad.len, tdata->iv.len))
7934 /* Create AEAD session */
7935 retval = create_aead_session(ts_params->valid_devs[0],
7937 RTE_CRYPTO_AEAD_OP_DECRYPT,
7938 tdata->key.data, tdata->key.len,
7939 tdata->aad.len, tdata->auth_tag.len,
7944 /* alloc mbuf and set payload */
7945 if (tdata->aad.len > MBUF_SIZE) {
7946 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7947 /* Populate full size of add data */
7948 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7949 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7951 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7954 rte_pktmbuf_tailroom(ut_params->ibuf));
7956 /* Create AEAD operation */
7957 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7961 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7963 ut_params->op->sym->m_src = ut_params->ibuf;
7965 /* Process crypto operation */
7966 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7967 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7969 TEST_ASSERT_NOT_NULL(
7970 process_crypto_request(ts_params->valid_devs[0],
7971 ut_params->op), "failed to process sym crypto op");
7973 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7974 "crypto op processing failed");
7976 if (ut_params->op->sym->m_dst)
7977 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7980 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7982 ut_params->op->sym->cipher.data.offset);
7984 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7987 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7989 tdata->plaintext.data,
7990 tdata->plaintext.len,
7991 "Plaintext data not as expected");
7993 TEST_ASSERT_EQUAL(ut_params->op->status,
7994 RTE_CRYPTO_OP_STATUS_SUCCESS,
7995 "Authentication failed");
8001 test_AES_GCM_authenticated_decryption_test_case_1(void)
8003 return test_authenticated_decryption(&gcm_test_case_1);
8007 test_AES_GCM_authenticated_decryption_test_case_2(void)
8009 return test_authenticated_decryption(&gcm_test_case_2);
8013 test_AES_GCM_authenticated_decryption_test_case_3(void)
8015 return test_authenticated_decryption(&gcm_test_case_3);
8019 test_AES_GCM_authenticated_decryption_test_case_4(void)
8021 return test_authenticated_decryption(&gcm_test_case_4);
8025 test_AES_GCM_authenticated_decryption_test_case_5(void)
8027 return test_authenticated_decryption(&gcm_test_case_5);
8031 test_AES_GCM_authenticated_decryption_test_case_6(void)
8033 return test_authenticated_decryption(&gcm_test_case_6);
8037 test_AES_GCM_authenticated_decryption_test_case_7(void)
8039 return test_authenticated_decryption(&gcm_test_case_7);
8043 test_AES_GCM_authenticated_decryption_test_case_8(void)
8045 return test_authenticated_decryption(&gcm_test_case_8);
8049 test_AES_GCM_auth_decryption_test_case_192_1(void)
8051 return test_authenticated_decryption(&gcm_test_case_192_1);
8055 test_AES_GCM_auth_decryption_test_case_192_2(void)
8057 return test_authenticated_decryption(&gcm_test_case_192_2);
8061 test_AES_GCM_auth_decryption_test_case_192_3(void)
8063 return test_authenticated_decryption(&gcm_test_case_192_3);
8067 test_AES_GCM_auth_decryption_test_case_192_4(void)
8069 return test_authenticated_decryption(&gcm_test_case_192_4);
8073 test_AES_GCM_auth_decryption_test_case_192_5(void)
8075 return test_authenticated_decryption(&gcm_test_case_192_5);
8079 test_AES_GCM_auth_decryption_test_case_192_6(void)
8081 return test_authenticated_decryption(&gcm_test_case_192_6);
8085 test_AES_GCM_auth_decryption_test_case_192_7(void)
8087 return test_authenticated_decryption(&gcm_test_case_192_7);
8091 test_AES_GCM_auth_decryption_test_case_256_1(void)
8093 return test_authenticated_decryption(&gcm_test_case_256_1);
8097 test_AES_GCM_auth_decryption_test_case_256_2(void)
8099 return test_authenticated_decryption(&gcm_test_case_256_2);
8103 test_AES_GCM_auth_decryption_test_case_256_3(void)
8105 return test_authenticated_decryption(&gcm_test_case_256_3);
8109 test_AES_GCM_auth_decryption_test_case_256_4(void)
8111 return test_authenticated_decryption(&gcm_test_case_256_4);
8115 test_AES_GCM_auth_decryption_test_case_256_5(void)
8117 return test_authenticated_decryption(&gcm_test_case_256_5);
8121 test_AES_GCM_auth_decryption_test_case_256_6(void)
8123 return test_authenticated_decryption(&gcm_test_case_256_6);
8127 test_AES_GCM_auth_decryption_test_case_256_7(void)
8129 return test_authenticated_decryption(&gcm_test_case_256_7);
8133 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8135 return test_authenticated_decryption(&gcm_test_case_aad_1);
8139 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8141 return test_authenticated_decryption(&gcm_test_case_aad_2);
8145 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8147 struct aead_test_data tdata;
8150 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8151 tdata.iv.data[0] += 1;
8152 res = test_authenticated_decryption(&tdata);
8153 if (res == -ENOTSUP)
8155 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8156 return TEST_SUCCESS;
8160 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8162 struct aead_test_data tdata;
8165 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8166 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8167 tdata.plaintext.data[0] += 1;
8168 res = test_authenticated_decryption(&tdata);
8169 if (res == -ENOTSUP)
8171 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8172 return TEST_SUCCESS;
8176 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8178 struct aead_test_data tdata;
8181 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8182 tdata.ciphertext.data[0] += 1;
8183 res = test_authenticated_decryption(&tdata);
8184 if (res == -ENOTSUP)
8186 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8187 return TEST_SUCCESS;
8191 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8193 struct aead_test_data tdata;
8196 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8198 res = test_authenticated_decryption(&tdata);
8199 if (res == -ENOTSUP)
8201 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8202 return TEST_SUCCESS;
8206 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8208 struct aead_test_data tdata;
8209 uint8_t aad[gcm_test_case_7.aad.len];
8212 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8213 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8215 tdata.aad.data = aad;
8216 res = test_authenticated_decryption(&tdata);
8217 if (res == -ENOTSUP)
8219 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8220 return TEST_SUCCESS;
8224 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8226 struct aead_test_data tdata;
8229 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8230 tdata.auth_tag.data[0] += 1;
8231 res = test_authenticated_decryption(&tdata);
8232 if (res == -ENOTSUP)
8234 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8235 return TEST_SUCCESS;
8239 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8241 struct crypto_testsuite_params *ts_params = &testsuite_params;
8242 struct crypto_unittest_params *ut_params = &unittest_params;
8245 uint8_t *ciphertext, *auth_tag;
8246 uint16_t plaintext_pad_len;
8248 /* Verify the capabilities */
8249 struct rte_cryptodev_sym_capability_idx cap_idx;
8250 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8251 cap_idx.algo.aead = tdata->algo;
8252 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8256 /* not supported with CPU crypto */
8257 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8260 /* Create AEAD session */
8261 retval = create_aead_session(ts_params->valid_devs[0],
8263 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8264 tdata->key.data, tdata->key.len,
8265 tdata->aad.len, tdata->auth_tag.len,
8270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8271 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8273 /* clear mbuf payload */
8274 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8275 rte_pktmbuf_tailroom(ut_params->ibuf));
8276 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8277 rte_pktmbuf_tailroom(ut_params->obuf));
8279 /* Create AEAD operation */
8280 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8284 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8286 ut_params->op->sym->m_src = ut_params->ibuf;
8287 ut_params->op->sym->m_dst = ut_params->obuf;
8289 /* Process crypto operation */
8290 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8291 ut_params->op), "failed to process sym crypto op");
8293 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8294 "crypto op processing failed");
8296 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8298 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8299 ut_params->op->sym->cipher.data.offset);
8300 auth_tag = ciphertext + plaintext_pad_len;
8302 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8303 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8306 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8308 tdata->ciphertext.data,
8309 tdata->ciphertext.len,
8310 "Ciphertext data not as expected");
8312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8314 tdata->auth_tag.data,
8315 tdata->auth_tag.len,
8316 "Generated auth tag not as expected");
8323 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8325 return test_authenticated_encryption_oop(&gcm_test_case_5);
8329 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8331 struct crypto_testsuite_params *ts_params = &testsuite_params;
8332 struct crypto_unittest_params *ut_params = &unittest_params;
8337 /* Verify the capabilities */
8338 struct rte_cryptodev_sym_capability_idx cap_idx;
8339 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8340 cap_idx.algo.aead = tdata->algo;
8341 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8345 /* not supported with CPU crypto */
8346 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8349 /* Create AEAD session */
8350 retval = create_aead_session(ts_params->valid_devs[0],
8352 RTE_CRYPTO_AEAD_OP_DECRYPT,
8353 tdata->key.data, tdata->key.len,
8354 tdata->aad.len, tdata->auth_tag.len,
8359 /* alloc mbuf and set payload */
8360 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8361 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8363 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8364 rte_pktmbuf_tailroom(ut_params->ibuf));
8365 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8366 rte_pktmbuf_tailroom(ut_params->obuf));
8368 /* Create AEAD operation */
8369 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8373 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8375 ut_params->op->sym->m_src = ut_params->ibuf;
8376 ut_params->op->sym->m_dst = ut_params->obuf;
8378 /* Process crypto operation */
8379 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8380 ut_params->op), "failed to process sym crypto op");
8382 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8383 "crypto op processing failed");
8385 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8386 ut_params->op->sym->cipher.data.offset);
8388 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8391 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8393 tdata->plaintext.data,
8394 tdata->plaintext.len,
8395 "Plaintext data not as expected");
8397 TEST_ASSERT_EQUAL(ut_params->op->status,
8398 RTE_CRYPTO_OP_STATUS_SUCCESS,
8399 "Authentication failed");
8404 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8406 return test_authenticated_decryption_oop(&gcm_test_case_5);
8410 test_authenticated_encryption_sessionless(
8411 const struct aead_test_data *tdata)
8413 struct crypto_testsuite_params *ts_params = &testsuite_params;
8414 struct crypto_unittest_params *ut_params = &unittest_params;
8417 uint8_t *ciphertext, *auth_tag;
8418 uint16_t plaintext_pad_len;
8419 uint8_t key[tdata->key.len + 1];
8421 /* This test is for AESNI MB and AESNI GCM PMDs only */
8422 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8423 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8424 (gbl_driver_id != rte_cryptodev_driver_id_get(
8425 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8428 /* not supported with CPU crypto */
8429 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8432 /* Verify the capabilities */
8433 struct rte_cryptodev_sym_capability_idx cap_idx;
8434 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8435 cap_idx.algo.aead = tdata->algo;
8436 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8440 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8442 /* clear mbuf payload */
8443 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8444 rte_pktmbuf_tailroom(ut_params->ibuf));
8446 /* Create AEAD operation */
8447 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8451 /* Create GCM xform */
8452 memcpy(key, tdata->key.data, tdata->key.len);
8453 retval = create_aead_xform(ut_params->op,
8455 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8456 key, tdata->key.len,
8457 tdata->aad.len, tdata->auth_tag.len,
8462 ut_params->op->sym->m_src = ut_params->ibuf;
8464 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8465 RTE_CRYPTO_OP_SESSIONLESS,
8466 "crypto op session type not sessionless");
8468 /* Process crypto operation */
8469 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8470 ut_params->op), "failed to process sym crypto op");
8472 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8474 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8475 "crypto op status not success");
8477 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8479 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8480 ut_params->op->sym->cipher.data.offset);
8481 auth_tag = ciphertext + plaintext_pad_len;
8483 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8484 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8487 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8489 tdata->ciphertext.data,
8490 tdata->ciphertext.len,
8491 "Ciphertext data not as expected");
8493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8495 tdata->auth_tag.data,
8496 tdata->auth_tag.len,
8497 "Generated auth tag not as expected");
8504 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8506 return test_authenticated_encryption_sessionless(
8511 test_authenticated_decryption_sessionless(
8512 const struct aead_test_data *tdata)
8514 struct crypto_testsuite_params *ts_params = &testsuite_params;
8515 struct crypto_unittest_params *ut_params = &unittest_params;
8519 uint8_t key[tdata->key.len + 1];
8521 /* This test is for AESNI MB and AESNI GCM PMDs only */
8522 if ((gbl_driver_id != rte_cryptodev_driver_id_get(
8523 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) &&
8524 (gbl_driver_id != rte_cryptodev_driver_id_get(
8525 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))))
8528 /* not supported with CPU crypto */
8529 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8532 /* Verify the capabilities */
8533 struct rte_cryptodev_sym_capability_idx cap_idx;
8534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8535 cap_idx.algo.aead = tdata->algo;
8536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8540 /* alloc mbuf and set payload */
8541 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8543 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8544 rte_pktmbuf_tailroom(ut_params->ibuf));
8546 /* Create AEAD operation */
8547 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8551 /* Create AEAD xform */
8552 memcpy(key, tdata->key.data, tdata->key.len);
8553 retval = create_aead_xform(ut_params->op,
8555 RTE_CRYPTO_AEAD_OP_DECRYPT,
8556 key, tdata->key.len,
8557 tdata->aad.len, tdata->auth_tag.len,
8562 ut_params->op->sym->m_src = ut_params->ibuf;
8564 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8565 RTE_CRYPTO_OP_SESSIONLESS,
8566 "crypto op session type not sessionless");
8568 /* Process crypto operation */
8569 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8570 ut_params->op), "failed to process sym crypto op");
8572 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8575 "crypto op status not success");
8577 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8578 ut_params->op->sym->cipher.data.offset);
8580 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8583 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8585 tdata->plaintext.data,
8586 tdata->plaintext.len,
8587 "Plaintext data not as expected");
8589 TEST_ASSERT_EQUAL(ut_params->op->status,
8590 RTE_CRYPTO_OP_STATUS_SUCCESS,
8591 "Authentication failed");
8596 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8598 return test_authenticated_decryption_sessionless(
8603 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8605 return test_authenticated_encryption(&ccm_test_case_128_1);
8609 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8611 return test_authenticated_encryption(&ccm_test_case_128_2);
8615 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8617 return test_authenticated_encryption(&ccm_test_case_128_3);
8621 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8623 return test_authenticated_decryption(&ccm_test_case_128_1);
8627 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8629 return test_authenticated_decryption(&ccm_test_case_128_2);
8633 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8635 return test_authenticated_decryption(&ccm_test_case_128_3);
8639 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8641 return test_authenticated_encryption(&ccm_test_case_192_1);
8645 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8647 return test_authenticated_encryption(&ccm_test_case_192_2);
8651 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8653 return test_authenticated_encryption(&ccm_test_case_192_3);
8657 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8659 return test_authenticated_decryption(&ccm_test_case_192_1);
8663 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8665 return test_authenticated_decryption(&ccm_test_case_192_2);
8669 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8671 return test_authenticated_decryption(&ccm_test_case_192_3);
8675 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8677 return test_authenticated_encryption(&ccm_test_case_256_1);
8681 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8683 return test_authenticated_encryption(&ccm_test_case_256_2);
8687 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8689 return test_authenticated_encryption(&ccm_test_case_256_3);
8693 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8695 return test_authenticated_decryption(&ccm_test_case_256_1);
8699 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8701 return test_authenticated_decryption(&ccm_test_case_256_2);
8705 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8707 return test_authenticated_decryption(&ccm_test_case_256_3);
8713 struct crypto_testsuite_params *ts_params = &testsuite_params;
8714 struct rte_cryptodev_stats stats;
8715 struct rte_cryptodev *dev;
8716 cryptodev_stats_get_t temp_pfn;
8718 /* Verify the capabilities */
8719 struct rte_cryptodev_sym_capability_idx cap_idx;
8720 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8721 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
8722 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8725 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8726 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8727 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8731 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8732 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8733 &stats) == -ENODEV),
8734 "rte_cryptodev_stats_get invalid dev failed");
8735 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8736 "rte_cryptodev_stats_get invalid Param failed");
8737 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8738 temp_pfn = dev->dev_ops->stats_get;
8739 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8740 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8742 "rte_cryptodev_stats_get invalid Param failed");
8743 dev->dev_ops->stats_get = temp_pfn;
8745 /* Test expected values */
8747 test_AES_CBC_HMAC_SHA1_encrypt_digest();
8749 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8751 "rte_cryptodev_stats_get failed");
8752 TEST_ASSERT((stats.enqueued_count == 1),
8753 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8754 TEST_ASSERT((stats.dequeued_count == 1),
8755 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8756 TEST_ASSERT((stats.enqueue_err_count == 0),
8757 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8758 TEST_ASSERT((stats.dequeue_err_count == 0),
8759 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8761 /* invalid device but should ignore and not reset device stats*/
8762 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8763 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8765 "rte_cryptodev_stats_get failed");
8766 TEST_ASSERT((stats.enqueued_count == 1),
8767 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8769 /* check that a valid reset clears stats */
8770 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8771 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8773 "rte_cryptodev_stats_get failed");
8774 TEST_ASSERT((stats.enqueued_count == 0),
8775 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8776 TEST_ASSERT((stats.dequeued_count == 0),
8777 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8779 return TEST_SUCCESS;
8782 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8783 struct crypto_unittest_params *ut_params,
8784 enum rte_crypto_auth_operation op,
8785 const struct HMAC_MD5_vector *test_case)
8789 memcpy(key, test_case->key.data, test_case->key.len);
8791 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8792 ut_params->auth_xform.next = NULL;
8793 ut_params->auth_xform.auth.op = op;
8795 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8797 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8798 ut_params->auth_xform.auth.key.length = test_case->key.len;
8799 ut_params->auth_xform.auth.key.data = key;
8801 ut_params->sess = rte_cryptodev_sym_session_create(
8802 ts_params->session_mpool);
8804 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8805 ut_params->sess, &ut_params->auth_xform,
8806 ts_params->session_priv_mpool);
8808 if (ut_params->sess == NULL)
8811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8814 rte_pktmbuf_tailroom(ut_params->ibuf));
8819 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8820 const struct HMAC_MD5_vector *test_case,
8821 uint8_t **plaintext)
8823 uint16_t plaintext_pad_len;
8825 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8827 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8830 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8832 memcpy(*plaintext, test_case->plaintext.data,
8833 test_case->plaintext.len);
8835 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8836 ut_params->ibuf, MD5_DIGEST_LEN);
8837 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8838 "no room to append digest");
8839 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8840 ut_params->ibuf, plaintext_pad_len);
8842 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8843 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8844 test_case->auth_tag.len);
8847 sym_op->auth.data.offset = 0;
8848 sym_op->auth.data.length = test_case->plaintext.len;
8850 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8851 ut_params->op->sym->m_src = ut_params->ibuf;
8857 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8859 uint16_t plaintext_pad_len;
8860 uint8_t *plaintext, *auth_tag;
8862 struct crypto_testsuite_params *ts_params = &testsuite_params;
8863 struct crypto_unittest_params *ut_params = &unittest_params;
8865 /* Verify the capabilities */
8866 struct rte_cryptodev_sym_capability_idx cap_idx;
8867 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8868 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8869 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8873 if (MD5_HMAC_create_session(ts_params, ut_params,
8874 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8877 /* Generate Crypto op data structure */
8878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8880 TEST_ASSERT_NOT_NULL(ut_params->op,
8881 "Failed to allocate symmetric crypto operation struct");
8883 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8886 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8889 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8890 ut_params->op), "failed to process sym crypto op");
8892 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8893 "crypto op processing failed");
8895 if (ut_params->op->sym->m_dst) {
8896 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8897 uint8_t *, plaintext_pad_len);
8899 auth_tag = plaintext + plaintext_pad_len;
8902 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8904 test_case->auth_tag.data,
8905 test_case->auth_tag.len,
8906 "HMAC_MD5 generated tag not as expected");
8908 return TEST_SUCCESS;
8912 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8916 struct crypto_testsuite_params *ts_params = &testsuite_params;
8917 struct crypto_unittest_params *ut_params = &unittest_params;
8919 /* Verify the capabilities */
8920 struct rte_cryptodev_sym_capability_idx cap_idx;
8921 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8922 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
8923 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8927 if (MD5_HMAC_create_session(ts_params, ut_params,
8928 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8932 /* Generate Crypto op data structure */
8933 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8934 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8935 TEST_ASSERT_NOT_NULL(ut_params->op,
8936 "Failed to allocate symmetric crypto operation struct");
8938 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8941 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8942 ut_params->op), "failed to process sym crypto op");
8944 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8945 "HMAC_MD5 crypto op processing failed");
8947 return TEST_SUCCESS;
8951 test_MD5_HMAC_generate_case_1(void)
8953 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8957 test_MD5_HMAC_verify_case_1(void)
8959 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8963 test_MD5_HMAC_generate_case_2(void)
8965 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8969 test_MD5_HMAC_verify_case_2(void)
8971 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8975 test_multi_session(void)
8977 struct crypto_testsuite_params *ts_params = &testsuite_params;
8978 struct crypto_unittest_params *ut_params = &unittest_params;
8980 struct rte_cryptodev_info dev_info;
8981 struct rte_cryptodev_sym_session **sessions;
8985 /* Verify the capabilities */
8986 struct rte_cryptodev_sym_capability_idx cap_idx;
8987 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8988 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
8989 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8992 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8993 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
8994 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8998 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8999 aes_cbc_key, hmac_sha512_key);
9002 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9004 sessions = rte_malloc(NULL,
9005 (sizeof(struct rte_cryptodev_sym_session *) *
9006 MAX_NB_SESSIONS) + 1, 0);
9008 /* Create multiple crypto sessions*/
9009 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9011 sessions[i] = rte_cryptodev_sym_session_create(
9012 ts_params->session_mpool);
9014 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9015 sessions[i], &ut_params->auth_xform,
9016 ts_params->session_priv_mpool);
9017 TEST_ASSERT_NOT_NULL(sessions[i],
9018 "Session creation failed at session number %u",
9021 /* Attempt to send a request on each session */
9022 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9026 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9027 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9029 "Failed to perform decrypt on request number %u.", i);
9030 /* free crypto operation structure */
9032 rte_crypto_op_free(ut_params->op);
9035 * free mbuf - both obuf and ibuf are usually the same,
9036 * so check if they point at the same address is necessary,
9037 * to avoid freeing the mbuf twice.
9039 if (ut_params->obuf) {
9040 rte_pktmbuf_free(ut_params->obuf);
9041 if (ut_params->ibuf == ut_params->obuf)
9042 ut_params->ibuf = 0;
9043 ut_params->obuf = 0;
9045 if (ut_params->ibuf) {
9046 rte_pktmbuf_free(ut_params->ibuf);
9047 ut_params->ibuf = 0;
9051 /* Next session create should fail */
9052 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9053 sessions[i], &ut_params->auth_xform,
9054 ts_params->session_priv_mpool);
9055 TEST_ASSERT_NULL(sessions[i],
9056 "Session creation succeeded unexpectedly!");
9058 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9059 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9061 rte_cryptodev_sym_session_free(sessions[i]);
9066 return TEST_SUCCESS;
9069 struct multi_session_params {
9070 struct crypto_unittest_params ut_params;
9071 uint8_t *cipher_key;
9073 const uint8_t *cipher;
9074 const uint8_t *digest;
9078 #define MB_SESSION_NUMBER 3
9081 test_multi_session_random_usage(void)
9083 struct crypto_testsuite_params *ts_params = &testsuite_params;
9084 struct rte_cryptodev_info dev_info;
9085 struct rte_cryptodev_sym_session **sessions;
9087 struct multi_session_params ut_paramz[] = {
9090 .cipher_key = ms_aes_cbc_key0,
9091 .hmac_key = ms_hmac_key0,
9092 .cipher = ms_aes_cbc_cipher0,
9093 .digest = ms_hmac_digest0,
9094 .iv = ms_aes_cbc_iv0
9097 .cipher_key = ms_aes_cbc_key1,
9098 .hmac_key = ms_hmac_key1,
9099 .cipher = ms_aes_cbc_cipher1,
9100 .digest = ms_hmac_digest1,
9101 .iv = ms_aes_cbc_iv1
9104 .cipher_key = ms_aes_cbc_key2,
9105 .hmac_key = ms_hmac_key2,
9106 .cipher = ms_aes_cbc_cipher2,
9107 .digest = ms_hmac_digest2,
9108 .iv = ms_aes_cbc_iv2
9113 /* Verify the capabilities */
9114 struct rte_cryptodev_sym_capability_idx cap_idx;
9115 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9116 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9117 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9120 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9121 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9122 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9126 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9128 sessions = rte_malloc(NULL,
9129 (sizeof(struct rte_cryptodev_sym_session *)
9130 * MAX_NB_SESSIONS) + 1, 0);
9132 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9133 sessions[i] = rte_cryptodev_sym_session_create(
9134 ts_params->session_mpool);
9136 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9137 sizeof(struct crypto_unittest_params));
9139 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9140 &ut_paramz[i].ut_params,
9141 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9143 /* Create multiple crypto sessions*/
9144 rte_cryptodev_sym_session_init(
9145 ts_params->valid_devs[0],
9147 &ut_paramz[i].ut_params.auth_xform,
9148 ts_params->session_priv_mpool);
9150 TEST_ASSERT_NOT_NULL(sessions[i],
9151 "Session creation failed at session number %u",
9157 for (i = 0; i < 40000; i++) {
9159 j = rand() % MB_SESSION_NUMBER;
9161 TEST_ASSERT_SUCCESS(
9162 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9164 &ut_paramz[j].ut_params,
9165 ts_params, ut_paramz[j].cipher,
9166 ut_paramz[j].digest,
9168 "Failed to perform decrypt on request number %u.", i);
9170 if (ut_paramz[j].ut_params.op)
9171 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9174 * free mbuf - both obuf and ibuf are usually the same,
9175 * so check if they point at the same address is necessary,
9176 * to avoid freeing the mbuf twice.
9178 if (ut_paramz[j].ut_params.obuf) {
9179 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9180 if (ut_paramz[j].ut_params.ibuf
9181 == ut_paramz[j].ut_params.obuf)
9182 ut_paramz[j].ut_params.ibuf = 0;
9183 ut_paramz[j].ut_params.obuf = 0;
9185 if (ut_paramz[j].ut_params.ibuf) {
9186 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9187 ut_paramz[j].ut_params.ibuf = 0;
9191 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9192 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9194 rte_cryptodev_sym_session_free(sessions[i]);
9199 return TEST_SUCCESS;
9203 test_null_cipher_only_operation(void)
9205 struct crypto_testsuite_params *ts_params = &testsuite_params;
9206 struct crypto_unittest_params *ut_params = &unittest_params;
9208 /* Verify the capabilities */
9209 struct rte_cryptodev_sym_capability_idx cap_idx;
9210 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9211 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9212 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9216 /* Generate test mbuf data and space for digest */
9217 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9218 catch_22_quote, QUOTE_512_BYTES, 0);
9220 /* Setup Cipher Parameters */
9221 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9222 ut_params->cipher_xform.next = NULL;
9224 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9225 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9227 ut_params->sess = rte_cryptodev_sym_session_create(
9228 ts_params->session_mpool);
9230 /* Create Crypto session*/
9231 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9233 &ut_params->cipher_xform,
9234 ts_params->session_priv_mpool);
9235 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9237 /* Generate Crypto op data structure */
9238 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9239 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9240 TEST_ASSERT_NOT_NULL(ut_params->op,
9241 "Failed to allocate symmetric crypto operation struct");
9243 /* Set crypto operation data parameters */
9244 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9246 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9248 /* set crypto operation source mbuf */
9249 sym_op->m_src = ut_params->ibuf;
9251 sym_op->cipher.data.offset = 0;
9252 sym_op->cipher.data.length = QUOTE_512_BYTES;
9254 /* Process crypto operation */
9255 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9257 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9259 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9260 "crypto operation processing failed");
9263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9264 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9267 "Ciphertext data not as expected");
9269 return TEST_SUCCESS;
9271 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9272 0xab, 0xab, 0xab, 0xab,
9273 0xab, 0xab, 0xab, 0xab,
9274 0xab, 0xab, 0xab, 0xab};
9276 test_null_auth_only_operation(void)
9278 struct crypto_testsuite_params *ts_params = &testsuite_params;
9279 struct crypto_unittest_params *ut_params = &unittest_params;
9282 /* Verify the capabilities */
9283 struct rte_cryptodev_sym_capability_idx cap_idx;
9284 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9285 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9286 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9290 /* Generate test mbuf data and space for digest */
9291 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9292 catch_22_quote, QUOTE_512_BYTES, 0);
9294 /* create a pointer for digest, but don't expect anything to be written
9295 * here in a NULL auth algo so no mbuf append done.
9297 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9299 /* prefill the memory pointed to by digest */
9300 memcpy(digest, orig_data, sizeof(orig_data));
9302 /* Setup HMAC Parameters */
9303 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9304 ut_params->auth_xform.next = NULL;
9306 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9307 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9309 ut_params->sess = rte_cryptodev_sym_session_create(
9310 ts_params->session_mpool);
9312 /* Create Crypto session*/
9313 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9314 ut_params->sess, &ut_params->auth_xform,
9315 ts_params->session_priv_mpool);
9316 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9318 /* Generate Crypto op data structure */
9319 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9320 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9321 TEST_ASSERT_NOT_NULL(ut_params->op,
9322 "Failed to allocate symmetric crypto operation struct");
9324 /* Set crypto operation data parameters */
9325 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9327 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9329 sym_op->m_src = ut_params->ibuf;
9331 sym_op->auth.data.offset = 0;
9332 sym_op->auth.data.length = QUOTE_512_BYTES;
9333 sym_op->auth.digest.data = digest;
9334 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9337 /* Process crypto operation */
9338 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9340 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9343 "crypto operation processing failed");
9344 /* Make sure memory pointed to by digest hasn't been overwritten */
9345 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9349 "Memory at digest ptr overwritten unexpectedly");
9351 return TEST_SUCCESS;
9356 test_null_cipher_auth_operation(void)
9358 struct crypto_testsuite_params *ts_params = &testsuite_params;
9359 struct crypto_unittest_params *ut_params = &unittest_params;
9362 /* Verify the capabilities */
9363 struct rte_cryptodev_sym_capability_idx cap_idx;
9364 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9365 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9366 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9369 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9370 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9371 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9375 /* Generate test mbuf data and space for digest */
9376 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9377 catch_22_quote, QUOTE_512_BYTES, 0);
9379 /* create a pointer for digest, but don't expect anything to be written
9380 * here in a NULL auth algo so no mbuf append done.
9382 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9384 /* prefill the memory pointed to by digest */
9385 memcpy(digest, orig_data, sizeof(orig_data));
9387 /* Setup Cipher Parameters */
9388 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9389 ut_params->cipher_xform.next = &ut_params->auth_xform;
9391 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9392 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9394 /* Setup HMAC Parameters */
9395 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9396 ut_params->auth_xform.next = NULL;
9398 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9399 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9401 ut_params->sess = rte_cryptodev_sym_session_create(
9402 ts_params->session_mpool);
9404 /* Create Crypto session*/
9405 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9406 ut_params->sess, &ut_params->cipher_xform,
9407 ts_params->session_priv_mpool);
9408 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9410 /* Generate Crypto op data structure */
9411 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9412 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9413 TEST_ASSERT_NOT_NULL(ut_params->op,
9414 "Failed to allocate symmetric crypto operation struct");
9416 /* Set crypto operation data parameters */
9417 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9419 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9421 sym_op->m_src = ut_params->ibuf;
9423 sym_op->cipher.data.offset = 0;
9424 sym_op->cipher.data.length = QUOTE_512_BYTES;
9426 sym_op->auth.data.offset = 0;
9427 sym_op->auth.data.length = QUOTE_512_BYTES;
9428 sym_op->auth.digest.data = digest;
9429 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9432 /* Process crypto operation */
9433 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9435 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9437 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9438 "crypto operation processing failed");
9441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9442 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9445 "Ciphertext data not as expected");
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;
9457 test_null_auth_cipher_operation(void)
9459 struct crypto_testsuite_params *ts_params = &testsuite_params;
9460 struct crypto_unittest_params *ut_params = &unittest_params;
9463 /* Verify the capabilities */
9464 struct rte_cryptodev_sym_capability_idx cap_idx;
9465 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9466 cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
9467 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9470 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9471 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
9472 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9476 /* Generate test mbuf data */
9477 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9478 catch_22_quote, QUOTE_512_BYTES, 0);
9480 /* create a pointer for digest, but don't expect anything to be written
9481 * here in a NULL auth algo so no mbuf append done.
9483 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9485 /* prefill the memory pointed to by digest */
9486 memcpy(digest, orig_data, sizeof(orig_data));
9488 /* Setup Cipher Parameters */
9489 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9490 ut_params->cipher_xform.next = NULL;
9492 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9493 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9495 /* Setup HMAC Parameters */
9496 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9497 ut_params->auth_xform.next = &ut_params->cipher_xform;
9499 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9500 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9502 ut_params->sess = rte_cryptodev_sym_session_create(
9503 ts_params->session_mpool);
9505 /* Create Crypto session*/
9506 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9507 ut_params->sess, &ut_params->cipher_xform,
9508 ts_params->session_priv_mpool);
9509 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9511 /* Generate Crypto op data structure */
9512 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9513 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9514 TEST_ASSERT_NOT_NULL(ut_params->op,
9515 "Failed to allocate symmetric crypto operation struct");
9517 /* Set crypto operation data parameters */
9518 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9520 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9522 sym_op->m_src = ut_params->ibuf;
9524 sym_op->cipher.data.offset = 0;
9525 sym_op->cipher.data.length = QUOTE_512_BYTES;
9527 sym_op->auth.data.offset = 0;
9528 sym_op->auth.data.length = QUOTE_512_BYTES;
9529 sym_op->auth.digest.data = digest;
9530 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9533 /* Process crypto operation */
9534 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9536 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9538 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9539 "crypto operation processing failed");
9542 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9543 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9546 "Ciphertext data not as expected");
9547 /* Make sure memory pointed to by digest hasn't been overwritten */
9548 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9552 "Memory at digest ptr overwritten unexpectedly");
9554 return TEST_SUCCESS;
9559 test_null_invalid_operation(void)
9561 struct crypto_testsuite_params *ts_params = &testsuite_params;
9562 struct crypto_unittest_params *ut_params = &unittest_params;
9565 /* This test is for NULL PMD only */
9566 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9567 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9570 /* Setup Cipher Parameters */
9571 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9572 ut_params->cipher_xform.next = NULL;
9574 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9575 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9577 ut_params->sess = rte_cryptodev_sym_session_create(
9578 ts_params->session_mpool);
9580 /* Create Crypto session*/
9581 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9582 ut_params->sess, &ut_params->cipher_xform,
9583 ts_params->session_priv_mpool);
9584 TEST_ASSERT(ret < 0,
9585 "Session creation succeeded unexpectedly");
9588 /* Setup HMAC Parameters */
9589 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9590 ut_params->auth_xform.next = NULL;
9592 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9593 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9595 ut_params->sess = rte_cryptodev_sym_session_create(
9596 ts_params->session_mpool);
9598 /* Create Crypto session*/
9599 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9600 ut_params->sess, &ut_params->auth_xform,
9601 ts_params->session_priv_mpool);
9602 TEST_ASSERT(ret < 0,
9603 "Session creation succeeded unexpectedly");
9605 return TEST_SUCCESS;
9609 #define NULL_BURST_LENGTH (32)
9612 test_null_burst_operation(void)
9614 struct crypto_testsuite_params *ts_params = &testsuite_params;
9615 struct crypto_unittest_params *ut_params = &unittest_params;
9617 unsigned i, burst_len = NULL_BURST_LENGTH;
9619 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9620 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9622 /* This test is for NULL PMD only */
9623 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9624 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9627 /* Setup Cipher Parameters */
9628 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9629 ut_params->cipher_xform.next = &ut_params->auth_xform;
9631 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9632 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9634 /* Setup HMAC Parameters */
9635 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9636 ut_params->auth_xform.next = NULL;
9638 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9639 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9641 ut_params->sess = rte_cryptodev_sym_session_create(
9642 ts_params->session_mpool);
9644 /* Create Crypto session*/
9645 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9646 ut_params->sess, &ut_params->cipher_xform,
9647 ts_params->session_priv_mpool);
9648 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9650 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9651 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9652 burst_len, "failed to generate burst of crypto ops");
9654 /* Generate an operation for each mbuf in burst */
9655 for (i = 0; i < burst_len; i++) {
9656 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9658 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9660 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9664 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9666 burst[i]->sym->m_src = m;
9669 /* Process crypto operation */
9670 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9671 0, burst, burst_len),
9673 "Error enqueuing burst");
9675 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9676 0, burst_dequeued, burst_len),
9678 "Error dequeuing burst");
9681 for (i = 0; i < burst_len; i++) {
9683 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9684 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9686 "data not as expected");
9688 rte_pktmbuf_free(burst[i]->sym->m_src);
9689 rte_crypto_op_free(burst[i]);
9692 return TEST_SUCCESS;
9696 generate_gmac_large_plaintext(uint8_t *data)
9700 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9701 memcpy(&data[i], &data[0], 32);
9705 create_gmac_operation(enum rte_crypto_auth_operation op,
9706 const struct gmac_test_data *tdata)
9708 struct crypto_testsuite_params *ts_params = &testsuite_params;
9709 struct crypto_unittest_params *ut_params = &unittest_params;
9710 struct rte_crypto_sym_op *sym_op;
9712 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9714 /* Generate Crypto op data structure */
9715 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9716 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9717 TEST_ASSERT_NOT_NULL(ut_params->op,
9718 "Failed to allocate symmetric crypto operation struct");
9720 sym_op = ut_params->op->sym;
9722 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9723 ut_params->ibuf, tdata->gmac_tag.len);
9724 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9725 "no room to append digest");
9727 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9728 ut_params->ibuf, plaintext_pad_len);
9730 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9731 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9732 tdata->gmac_tag.len);
9733 debug_hexdump(stdout, "digest:",
9734 sym_op->auth.digest.data,
9735 tdata->gmac_tag.len);
9738 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9739 uint8_t *, IV_OFFSET);
9741 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9743 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9745 sym_op->cipher.data.length = 0;
9746 sym_op->cipher.data.offset = 0;
9748 sym_op->auth.data.offset = 0;
9749 sym_op->auth.data.length = tdata->plaintext.len;
9754 static int create_gmac_session(uint8_t dev_id,
9755 const struct gmac_test_data *tdata,
9756 enum rte_crypto_auth_operation auth_op)
9758 uint8_t auth_key[tdata->key.len];
9760 struct crypto_testsuite_params *ts_params = &testsuite_params;
9761 struct crypto_unittest_params *ut_params = &unittest_params;
9763 memcpy(auth_key, tdata->key.data, tdata->key.len);
9765 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9766 ut_params->auth_xform.next = NULL;
9768 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9769 ut_params->auth_xform.auth.op = auth_op;
9770 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9771 ut_params->auth_xform.auth.key.length = tdata->key.len;
9772 ut_params->auth_xform.auth.key.data = auth_key;
9773 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9774 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9777 ut_params->sess = rte_cryptodev_sym_session_create(
9778 ts_params->session_mpool);
9780 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9781 &ut_params->auth_xform,
9782 ts_params->session_priv_mpool);
9784 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9790 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9792 struct crypto_testsuite_params *ts_params = &testsuite_params;
9793 struct crypto_unittest_params *ut_params = &unittest_params;
9797 uint8_t *auth_tag, *plaintext;
9798 uint16_t plaintext_pad_len;
9800 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9801 "No GMAC length in the source data");
9803 /* Verify the capabilities */
9804 struct rte_cryptodev_sym_capability_idx cap_idx;
9805 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9806 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9811 retval = create_gmac_session(ts_params->valid_devs[0],
9812 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9817 if (tdata->plaintext.len > MBUF_SIZE)
9818 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9820 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9821 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9822 "Failed to allocate input buffer in mempool");
9824 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9825 rte_pktmbuf_tailroom(ut_params->ibuf));
9827 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9829 * Runtime generate the large plain text instead of use hard code
9830 * plain text vector. It is done to avoid create huge source file
9831 * with the test vector.
9833 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9834 generate_gmac_large_plaintext(tdata->plaintext.data);
9836 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9838 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9840 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9841 debug_hexdump(stdout, "plaintext:", plaintext,
9842 tdata->plaintext.len);
9844 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9850 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9852 ut_params->op->sym->m_src = ut_params->ibuf;
9854 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9855 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
9857 TEST_ASSERT_NOT_NULL(
9858 process_crypto_request(ts_params->valid_devs[0],
9859 ut_params->op), "failed to process sym crypto op");
9861 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9862 "crypto op processing failed");
9864 if (ut_params->op->sym->m_dst) {
9865 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9866 uint8_t *, plaintext_pad_len);
9868 auth_tag = plaintext + plaintext_pad_len;
9871 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9875 tdata->gmac_tag.data,
9876 tdata->gmac_tag.len,
9877 "GMAC Generated auth tag not as expected");
9883 test_AES_GMAC_authentication_test_case_1(void)
9885 return test_AES_GMAC_authentication(&gmac_test_case_1);
9889 test_AES_GMAC_authentication_test_case_2(void)
9891 return test_AES_GMAC_authentication(&gmac_test_case_2);
9895 test_AES_GMAC_authentication_test_case_3(void)
9897 return test_AES_GMAC_authentication(&gmac_test_case_3);
9901 test_AES_GMAC_authentication_test_case_4(void)
9903 return test_AES_GMAC_authentication(&gmac_test_case_4);
9907 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9909 struct crypto_testsuite_params *ts_params = &testsuite_params;
9910 struct crypto_unittest_params *ut_params = &unittest_params;
9912 uint32_t plaintext_pad_len;
9915 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9916 "No GMAC length in the source data");
9918 /* Verify the capabilities */
9919 struct rte_cryptodev_sym_capability_idx cap_idx;
9920 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9921 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
9922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9926 retval = create_gmac_session(ts_params->valid_devs[0],
9927 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9932 if (tdata->plaintext.len > MBUF_SIZE)
9933 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9935 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9936 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9937 "Failed to allocate input buffer in mempool");
9939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9940 rte_pktmbuf_tailroom(ut_params->ibuf));
9942 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9945 * Runtime generate the large plain text instead of use hard code
9946 * plain text vector. It is done to avoid create huge source file
9947 * with the test vector.
9949 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9950 generate_gmac_large_plaintext(tdata->plaintext.data);
9952 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9954 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9956 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9957 debug_hexdump(stdout, "plaintext:", plaintext,
9958 tdata->plaintext.len);
9960 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9966 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9968 ut_params->op->sym->m_src = ut_params->ibuf;
9970 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9971 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
9973 TEST_ASSERT_NOT_NULL(
9974 process_crypto_request(ts_params->valid_devs[0],
9975 ut_params->op), "failed to process sym crypto op");
9977 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9978 "crypto op processing failed");
9985 test_AES_GMAC_authentication_verify_test_case_1(void)
9987 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9991 test_AES_GMAC_authentication_verify_test_case_2(void)
9993 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9997 test_AES_GMAC_authentication_verify_test_case_3(void)
9999 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10003 test_AES_GMAC_authentication_verify_test_case_4(void)
10005 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10008 struct test_crypto_vector {
10009 enum rte_crypto_cipher_algorithm crypto_algo;
10010 unsigned int cipher_offset;
10011 unsigned int cipher_len;
10024 const uint8_t *data;
10029 const uint8_t *data;
10033 enum rte_crypto_auth_algorithm auth_algo;
10034 unsigned int auth_offset;
10042 const uint8_t *data;
10052 static const struct test_crypto_vector
10053 hmac_sha1_test_crypto_vector = {
10054 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10056 .data = plaintext_hash,
10061 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10062 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10063 0xDE, 0xF4, 0xDE, 0xAD
10069 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10070 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10071 0x3F, 0x91, 0x64, 0x59
10077 static const struct test_crypto_vector
10078 aes128_gmac_test_vector = {
10079 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10081 .data = plaintext_hash,
10086 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10087 0x08, 0x09, 0x0A, 0x0B
10093 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10094 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10100 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10101 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10107 static const struct test_crypto_vector
10108 aes128cbc_hmac_sha1_test_vector = {
10109 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10110 .cipher_offset = 0,
10114 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10115 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10121 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10122 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10127 .data = plaintext_hash,
10131 .data = ciphertext512_aes128cbc,
10134 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10138 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10139 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10140 0xDE, 0xF4, 0xDE, 0xAD
10146 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10147 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10148 0x18, 0x8C, 0x1D, 0x32
10154 static const struct test_crypto_vector
10155 aes128cbc_hmac_sha1_aad_test_vector = {
10156 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10157 .cipher_offset = 12,
10161 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10162 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10168 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10169 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10174 .data = plaintext_hash,
10178 .data = ciphertext512_aes128cbc_aad,
10181 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10185 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10186 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10187 0xDE, 0xF4, 0xDE, 0xAD
10193 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10194 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10195 0x62, 0x8D, 0x62, 0x65
10202 data_corruption(uint8_t *data)
10208 tag_corruption(uint8_t *data, unsigned int tag_offset)
10210 data[tag_offset] += 1;
10214 create_auth_session(struct crypto_unittest_params *ut_params,
10216 const struct test_crypto_vector *reference,
10217 enum rte_crypto_auth_operation auth_op)
10219 struct crypto_testsuite_params *ts_params = &testsuite_params;
10220 uint8_t auth_key[reference->auth_key.len + 1];
10222 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10224 /* Setup Authentication Parameters */
10225 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10226 ut_params->auth_xform.auth.op = auth_op;
10227 ut_params->auth_xform.next = NULL;
10228 ut_params->auth_xform.auth.algo = reference->auth_algo;
10229 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10230 ut_params->auth_xform.auth.key.data = auth_key;
10231 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10233 /* Create Crypto session*/
10234 ut_params->sess = rte_cryptodev_sym_session_create(
10235 ts_params->session_mpool);
10237 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10238 &ut_params->auth_xform,
10239 ts_params->session_priv_mpool);
10241 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10247 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10249 const struct test_crypto_vector *reference,
10250 enum rte_crypto_auth_operation auth_op,
10251 enum rte_crypto_cipher_operation cipher_op)
10253 struct crypto_testsuite_params *ts_params = &testsuite_params;
10254 uint8_t cipher_key[reference->cipher_key.len + 1];
10255 uint8_t auth_key[reference->auth_key.len + 1];
10257 memcpy(cipher_key, reference->cipher_key.data,
10258 reference->cipher_key.len);
10259 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10261 /* Setup Authentication Parameters */
10262 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10263 ut_params->auth_xform.auth.op = auth_op;
10264 ut_params->auth_xform.auth.algo = reference->auth_algo;
10265 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10266 ut_params->auth_xform.auth.key.data = auth_key;
10267 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10269 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10270 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10271 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10273 ut_params->auth_xform.next = &ut_params->cipher_xform;
10275 /* Setup Cipher Parameters */
10276 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10277 ut_params->cipher_xform.next = NULL;
10278 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10279 ut_params->cipher_xform.cipher.op = cipher_op;
10280 ut_params->cipher_xform.cipher.key.data = cipher_key;
10281 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10282 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10283 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10286 /* Create Crypto session*/
10287 ut_params->sess = rte_cryptodev_sym_session_create(
10288 ts_params->session_mpool);
10290 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10291 &ut_params->auth_xform,
10292 ts_params->session_priv_mpool);
10294 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10300 create_auth_operation(struct crypto_testsuite_params *ts_params,
10301 struct crypto_unittest_params *ut_params,
10302 const struct test_crypto_vector *reference,
10303 unsigned int auth_generate)
10305 /* Generate Crypto op data structure */
10306 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10307 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10308 TEST_ASSERT_NOT_NULL(ut_params->op,
10309 "Failed to allocate pktmbuf offload");
10311 /* Set crypto operation data parameters */
10312 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10314 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10316 /* set crypto operation source mbuf */
10317 sym_op->m_src = ut_params->ibuf;
10320 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10321 ut_params->ibuf, reference->digest.len);
10323 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10324 "no room to append auth tag");
10326 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10327 ut_params->ibuf, reference->plaintext.len);
10330 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10332 memcpy(sym_op->auth.digest.data,
10333 reference->digest.data,
10334 reference->digest.len);
10336 debug_hexdump(stdout, "digest:",
10337 sym_op->auth.digest.data,
10338 reference->digest.len);
10340 sym_op->auth.data.length = reference->plaintext.len;
10341 sym_op->auth.data.offset = 0;
10347 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10348 struct crypto_unittest_params *ut_params,
10349 const struct test_crypto_vector *reference,
10350 unsigned int auth_generate)
10352 /* Generate Crypto op data structure */
10353 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10354 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10355 TEST_ASSERT_NOT_NULL(ut_params->op,
10356 "Failed to allocate pktmbuf offload");
10358 /* Set crypto operation data parameters */
10359 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10361 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10363 /* set crypto operation source mbuf */
10364 sym_op->m_src = ut_params->ibuf;
10367 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10368 ut_params->ibuf, reference->digest.len);
10370 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10371 "no room to append auth tag");
10373 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10374 ut_params->ibuf, reference->ciphertext.len);
10377 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10379 memcpy(sym_op->auth.digest.data,
10380 reference->digest.data,
10381 reference->digest.len);
10383 debug_hexdump(stdout, "digest:",
10384 sym_op->auth.digest.data,
10385 reference->digest.len);
10387 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10388 reference->iv.data, reference->iv.len);
10390 sym_op->cipher.data.length = 0;
10391 sym_op->cipher.data.offset = 0;
10393 sym_op->auth.data.length = reference->plaintext.len;
10394 sym_op->auth.data.offset = 0;
10400 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10401 struct crypto_unittest_params *ut_params,
10402 const struct test_crypto_vector *reference,
10403 unsigned int auth_generate)
10405 /* Generate Crypto op data structure */
10406 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10407 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10408 TEST_ASSERT_NOT_NULL(ut_params->op,
10409 "Failed to allocate pktmbuf offload");
10411 /* Set crypto operation data parameters */
10412 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10414 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10416 /* set crypto operation source mbuf */
10417 sym_op->m_src = ut_params->ibuf;
10420 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10421 ut_params->ibuf, reference->digest.len);
10423 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10424 "no room to append auth tag");
10426 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10427 ut_params->ibuf, reference->ciphertext.len);
10430 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10432 memcpy(sym_op->auth.digest.data,
10433 reference->digest.data,
10434 reference->digest.len);
10436 debug_hexdump(stdout, "digest:",
10437 sym_op->auth.digest.data,
10438 reference->digest.len);
10440 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10441 reference->iv.data, reference->iv.len);
10443 sym_op->cipher.data.length = reference->cipher_len;
10444 sym_op->cipher.data.offset = reference->cipher_offset;
10446 sym_op->auth.data.length = reference->plaintext.len;
10447 sym_op->auth.data.offset = reference->auth_offset;
10453 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10454 struct crypto_unittest_params *ut_params,
10455 const struct test_crypto_vector *reference)
10457 return create_auth_operation(ts_params, ut_params, reference, 0);
10461 create_auth_verify_GMAC_operation(
10462 struct crypto_testsuite_params *ts_params,
10463 struct crypto_unittest_params *ut_params,
10464 const struct test_crypto_vector *reference)
10466 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10470 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10471 struct crypto_unittest_params *ut_params,
10472 const struct test_crypto_vector *reference)
10474 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10478 test_authentication_verify_fail_when_data_corruption(
10479 struct crypto_testsuite_params *ts_params,
10480 struct crypto_unittest_params *ut_params,
10481 const struct test_crypto_vector *reference,
10482 unsigned int data_corrupted)
10486 uint8_t *plaintext;
10488 /* Verify the capabilities */
10489 struct rte_cryptodev_sym_capability_idx cap_idx;
10490 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10491 cap_idx.algo.auth = reference->auth_algo;
10492 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10496 /* Create session */
10497 retval = create_auth_session(ut_params,
10498 ts_params->valid_devs[0],
10500 RTE_CRYPTO_AUTH_OP_VERIFY);
10504 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10505 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10506 "Failed to allocate input buffer in mempool");
10508 /* clear mbuf payload */
10509 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10510 rte_pktmbuf_tailroom(ut_params->ibuf));
10512 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10513 reference->plaintext.len);
10514 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10515 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10517 debug_hexdump(stdout, "plaintext:", plaintext,
10518 reference->plaintext.len);
10520 /* Create operation */
10521 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10526 if (data_corrupted)
10527 data_corruption(plaintext);
10529 tag_corruption(plaintext, reference->plaintext.len);
10531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10534 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10540 test_authentication_verify_GMAC_fail_when_corruption(
10541 struct crypto_testsuite_params *ts_params,
10542 struct crypto_unittest_params *ut_params,
10543 const struct test_crypto_vector *reference,
10544 unsigned int data_corrupted)
10547 uint8_t *plaintext;
10549 /* Verify the capabilities */
10550 struct rte_cryptodev_sym_capability_idx cap_idx;
10551 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10552 cap_idx.algo.auth = reference->auth_algo;
10553 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10557 /* Create session */
10558 retval = create_auth_cipher_session(ut_params,
10559 ts_params->valid_devs[0],
10561 RTE_CRYPTO_AUTH_OP_VERIFY,
10562 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10567 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10568 "Failed to allocate input buffer in mempool");
10570 /* clear mbuf payload */
10571 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10572 rte_pktmbuf_tailroom(ut_params->ibuf));
10574 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10575 reference->plaintext.len);
10576 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10577 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10579 debug_hexdump(stdout, "plaintext:", plaintext,
10580 reference->plaintext.len);
10582 /* Create operation */
10583 retval = create_auth_verify_GMAC_operation(ts_params,
10590 if (data_corrupted)
10591 data_corruption(plaintext);
10593 tag_corruption(plaintext, reference->aad.len);
10595 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10596 process_cpu_gmac_op(ts_params->valid_devs[0], ut_params->op);
10597 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10598 RTE_CRYPTO_OP_STATUS_SUCCESS,
10599 "authentication not failed");
10601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10603 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10610 test_authenticated_decryption_fail_when_corruption(
10611 struct crypto_testsuite_params *ts_params,
10612 struct crypto_unittest_params *ut_params,
10613 const struct test_crypto_vector *reference,
10614 unsigned int data_corrupted)
10618 uint8_t *ciphertext;
10620 /* Verify the capabilities */
10621 struct rte_cryptodev_sym_capability_idx cap_idx;
10622 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10623 cap_idx.algo.auth = reference->auth_algo;
10624 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10627 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10628 cap_idx.algo.cipher = reference->crypto_algo;
10629 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10633 /* Create session */
10634 retval = create_auth_cipher_session(ut_params,
10635 ts_params->valid_devs[0],
10637 RTE_CRYPTO_AUTH_OP_VERIFY,
10638 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10643 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10644 "Failed to allocate input buffer in mempool");
10646 /* clear mbuf payload */
10647 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10648 rte_pktmbuf_tailroom(ut_params->ibuf));
10650 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10651 reference->ciphertext.len);
10652 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10653 memcpy(ciphertext, reference->ciphertext.data,
10654 reference->ciphertext.len);
10656 /* Create operation */
10657 retval = create_cipher_auth_verify_operation(ts_params,
10664 if (data_corrupted)
10665 data_corruption(ciphertext);
10667 tag_corruption(ciphertext, reference->ciphertext.len);
10669 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10672 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10678 test_authenticated_encryt_with_esn(
10679 struct crypto_testsuite_params *ts_params,
10680 struct crypto_unittest_params *ut_params,
10681 const struct test_crypto_vector *reference)
10685 uint8_t *authciphertext, *plaintext, *auth_tag;
10686 uint16_t plaintext_pad_len;
10687 uint8_t cipher_key[reference->cipher_key.len + 1];
10688 uint8_t auth_key[reference->auth_key.len + 1];
10690 /* Verify the capabilities */
10691 struct rte_cryptodev_sym_capability_idx cap_idx;
10692 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10693 cap_idx.algo.auth = reference->auth_algo;
10694 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10697 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10698 cap_idx.algo.cipher = reference->crypto_algo;
10699 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10703 /* Create session */
10704 memcpy(cipher_key, reference->cipher_key.data,
10705 reference->cipher_key.len);
10706 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10708 /* Setup Cipher Parameters */
10709 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10710 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10711 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10712 ut_params->cipher_xform.cipher.key.data = cipher_key;
10713 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10714 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10715 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10717 ut_params->cipher_xform.next = &ut_params->auth_xform;
10719 /* Setup Authentication Parameters */
10720 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10721 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10722 ut_params->auth_xform.auth.algo = reference->auth_algo;
10723 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10724 ut_params->auth_xform.auth.key.data = auth_key;
10725 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10726 ut_params->auth_xform.next = NULL;
10728 /* Create Crypto session*/
10729 ut_params->sess = rte_cryptodev_sym_session_create(
10730 ts_params->session_mpool);
10732 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10734 &ut_params->cipher_xform,
10735 ts_params->session_priv_mpool);
10737 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10739 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10740 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10741 "Failed to allocate input buffer in mempool");
10743 /* clear mbuf payload */
10744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10745 rte_pktmbuf_tailroom(ut_params->ibuf));
10747 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10748 reference->plaintext.len);
10749 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10750 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10752 /* Create operation */
10753 retval = create_cipher_auth_operation(ts_params,
10760 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10763 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10765 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10766 "crypto op processing failed");
10768 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
10770 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10771 ut_params->op->sym->auth.data.offset);
10772 auth_tag = authciphertext + plaintext_pad_len;
10773 debug_hexdump(stdout, "ciphertext:", authciphertext,
10774 reference->ciphertext.len);
10775 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
10777 /* Validate obuf */
10778 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10780 reference->ciphertext.data,
10781 reference->ciphertext.len,
10782 "Ciphertext data not as expected");
10784 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10786 reference->digest.data,
10787 reference->digest.len,
10788 "Generated digest not as expected");
10790 return TEST_SUCCESS;
10795 test_authenticated_decrypt_with_esn(
10796 struct crypto_testsuite_params *ts_params,
10797 struct crypto_unittest_params *ut_params,
10798 const struct test_crypto_vector *reference)
10802 uint8_t *ciphertext;
10803 uint8_t cipher_key[reference->cipher_key.len + 1];
10804 uint8_t auth_key[reference->auth_key.len + 1];
10806 /* Verify the capabilities */
10807 struct rte_cryptodev_sym_capability_idx cap_idx;
10808 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10809 cap_idx.algo.auth = reference->auth_algo;
10810 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10813 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10814 cap_idx.algo.cipher = reference->crypto_algo;
10815 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10819 /* Create session */
10820 memcpy(cipher_key, reference->cipher_key.data,
10821 reference->cipher_key.len);
10822 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10824 /* Setup Authentication Parameters */
10825 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10826 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
10827 ut_params->auth_xform.auth.algo = reference->auth_algo;
10828 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10829 ut_params->auth_xform.auth.key.data = auth_key;
10830 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10831 ut_params->auth_xform.next = &ut_params->cipher_xform;
10833 /* Setup Cipher Parameters */
10834 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10835 ut_params->cipher_xform.next = NULL;
10836 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10837 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10838 ut_params->cipher_xform.cipher.key.data = cipher_key;
10839 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10840 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10841 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10843 /* Create Crypto session*/
10844 ut_params->sess = rte_cryptodev_sym_session_create(
10845 ts_params->session_mpool);
10847 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10849 &ut_params->auth_xform,
10850 ts_params->session_priv_mpool);
10852 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10855 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10856 "Failed to allocate input buffer in mempool");
10858 /* clear mbuf payload */
10859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10860 rte_pktmbuf_tailroom(ut_params->ibuf));
10862 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10863 reference->ciphertext.len);
10864 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10865 memcpy(ciphertext, reference->ciphertext.data,
10866 reference->ciphertext.len);
10868 /* Create operation */
10869 retval = create_cipher_auth_verify_operation(ts_params,
10876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10880 TEST_ASSERT_EQUAL(ut_params->op->status,
10881 RTE_CRYPTO_OP_STATUS_SUCCESS,
10882 "crypto op processing passed");
10884 ut_params->obuf = ut_params->op->sym->m_src;
10885 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10891 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10892 const struct aead_test_data *tdata,
10893 void *digest_mem, uint64_t digest_phys)
10895 struct crypto_testsuite_params *ts_params = &testsuite_params;
10896 struct crypto_unittest_params *ut_params = &unittest_params;
10898 const unsigned int auth_tag_len = tdata->auth_tag.len;
10899 const unsigned int iv_len = tdata->iv.len;
10900 unsigned int aad_len = tdata->aad.len;
10901 unsigned int aad_len_pad = 0;
10903 /* Generate Crypto op data structure */
10904 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10905 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10906 TEST_ASSERT_NOT_NULL(ut_params->op,
10907 "Failed to allocate symmetric crypto operation struct");
10909 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10911 sym_op->aead.digest.data = digest_mem;
10913 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10914 "no room to append digest");
10916 sym_op->aead.digest.phys_addr = digest_phys;
10918 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10919 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10921 debug_hexdump(stdout, "digest:",
10922 sym_op->aead.digest.data,
10926 /* Append aad data */
10927 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10928 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10929 uint8_t *, IV_OFFSET);
10931 /* Copy IV 1 byte after the IV pointer, according to the API */
10932 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10934 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10936 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10937 ut_params->ibuf, aad_len);
10938 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10939 "no room to prepend aad");
10940 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10943 memset(sym_op->aead.aad.data, 0, aad_len);
10944 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10945 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10947 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10948 debug_hexdump(stdout, "aad:",
10949 sym_op->aead.aad.data, aad_len);
10951 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10952 uint8_t *, IV_OFFSET);
10954 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10956 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
10958 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10959 ut_params->ibuf, aad_len_pad);
10960 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10961 "no room to prepend aad");
10962 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10965 memset(sym_op->aead.aad.data, 0, aad_len);
10966 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10968 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10969 debug_hexdump(stdout, "aad:",
10970 sym_op->aead.aad.data, aad_len);
10973 sym_op->aead.data.length = tdata->plaintext.len;
10974 sym_op->aead.data.offset = aad_len_pad;
10979 #define SGL_MAX_NO 16
10982 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10983 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10985 struct crypto_testsuite_params *ts_params = &testsuite_params;
10986 struct crypto_unittest_params *ut_params = &unittest_params;
10987 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10990 int to_trn_tbl[SGL_MAX_NO];
10992 unsigned int trn_data = 0;
10993 uint8_t *plaintext, *ciphertext, *auth_tag;
10994 struct rte_cryptodev_info dev_info;
10996 /* Verify the capabilities */
10997 struct rte_cryptodev_sym_capability_idx cap_idx;
10998 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10999 cap_idx.algo.aead = tdata->algo;
11000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11004 /* OOP not supported with CPU crypto */
11005 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11008 /* Detailed check for the particular SGL support flag */
11009 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11011 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11012 if (sgl_in && (!(dev_info.feature_flags &
11013 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11016 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11017 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11018 tdata->plaintext.len;
11019 if (sgl_in && !sgl_out) {
11020 if (!(dev_info.feature_flags &
11021 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11023 } else if (!sgl_in && sgl_out) {
11024 if (!(dev_info.feature_flags &
11025 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11027 } else if (sgl_in && sgl_out) {
11028 if (!(dev_info.feature_flags &
11029 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11034 if (fragsz > tdata->plaintext.len)
11035 fragsz = tdata->plaintext.len;
11037 uint16_t plaintext_len = fragsz;
11038 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11040 if (fragsz_oop > tdata->plaintext.len)
11041 frag_size_oop = tdata->plaintext.len;
11044 void *digest_mem = NULL;
11046 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11048 if (tdata->plaintext.len % fragsz != 0) {
11049 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11052 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11057 * For out-op-place we need to alloc another mbuf
11060 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11061 rte_pktmbuf_append(ut_params->obuf,
11062 frag_size_oop + prepend_len);
11063 buf_oop = ut_params->obuf;
11066 /* Create AEAD session */
11067 retval = create_aead_session(ts_params->valid_devs[0],
11069 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11070 tdata->key.data, tdata->key.len,
11071 tdata->aad.len, tdata->auth_tag.len,
11076 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11078 /* clear mbuf payload */
11079 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11080 rte_pktmbuf_tailroom(ut_params->ibuf));
11082 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11085 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11087 trn_data += plaintext_len;
11089 buf = ut_params->ibuf;
11092 * Loop until no more fragments
11095 while (trn_data < tdata->plaintext.len) {
11097 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11098 (tdata->plaintext.len - trn_data) : fragsz;
11100 to_trn_tbl[ecx++] = to_trn;
11102 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11105 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11106 rte_pktmbuf_tailroom(buf));
11109 if (oop && !fragsz_oop) {
11110 buf_last_oop = buf_oop->next =
11111 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11112 buf_oop = buf_oop->next;
11113 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11114 0, rte_pktmbuf_tailroom(buf_oop));
11115 rte_pktmbuf_append(buf_oop, to_trn);
11118 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11121 memcpy(plaintext, tdata->plaintext.data + trn_data,
11123 trn_data += to_trn;
11124 if (trn_data == tdata->plaintext.len) {
11127 digest_mem = rte_pktmbuf_append(buf_oop,
11128 tdata->auth_tag.len);
11130 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11131 tdata->auth_tag.len);
11135 uint64_t digest_phys = 0;
11137 ut_params->ibuf->nb_segs = segs;
11140 if (fragsz_oop && oop) {
11144 if (frag_size_oop == tdata->plaintext.len) {
11145 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11146 tdata->auth_tag.len);
11148 digest_phys = rte_pktmbuf_iova_offset(
11150 tdata->plaintext.len + prepend_len);
11153 trn_data = frag_size_oop;
11154 while (trn_data < tdata->plaintext.len) {
11157 (tdata->plaintext.len - trn_data <
11159 (tdata->plaintext.len - trn_data) :
11162 to_trn_tbl[ecx++] = to_trn;
11164 buf_last_oop = buf_oop->next =
11165 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11166 buf_oop = buf_oop->next;
11167 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11168 0, rte_pktmbuf_tailroom(buf_oop));
11169 rte_pktmbuf_append(buf_oop, to_trn);
11171 trn_data += to_trn;
11173 if (trn_data == tdata->plaintext.len) {
11174 digest_mem = rte_pktmbuf_append(buf_oop,
11175 tdata->auth_tag.len);
11179 ut_params->obuf->nb_segs = segs;
11183 * Place digest at the end of the last buffer
11186 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11187 if (oop && buf_last_oop)
11188 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11190 if (!digest_mem && !oop) {
11191 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11192 + tdata->auth_tag.len);
11193 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11194 tdata->plaintext.len);
11197 /* Create AEAD operation */
11198 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11199 tdata, digest_mem, digest_phys);
11204 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11206 ut_params->op->sym->m_src = ut_params->ibuf;
11208 ut_params->op->sym->m_dst = ut_params->obuf;
11210 /* Process crypto operation */
11211 if (oop == IN_PLACE &&
11212 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11213 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11215 TEST_ASSERT_NOT_NULL(
11216 process_crypto_request(ts_params->valid_devs[0],
11217 ut_params->op), "failed to process sym crypto op");
11219 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11220 "crypto op processing failed");
11223 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11224 uint8_t *, prepend_len);
11226 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11227 uint8_t *, prepend_len);
11231 fragsz = fragsz_oop;
11233 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11235 tdata->ciphertext.data,
11237 "Ciphertext data not as expected");
11239 buf = ut_params->op->sym->m_src->next;
11241 buf = ut_params->op->sym->m_dst->next;
11243 unsigned int off = fragsz;
11247 ciphertext = rte_pktmbuf_mtod(buf,
11250 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11252 tdata->ciphertext.data + off,
11254 "Ciphertext data not as expected");
11256 off += to_trn_tbl[ecx++];
11260 auth_tag = digest_mem;
11261 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11263 tdata->auth_tag.data,
11264 tdata->auth_tag.len,
11265 "Generated auth tag not as expected");
11271 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11273 return test_authenticated_encryption_SGL(
11274 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11278 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11280 return test_authenticated_encryption_SGL(
11281 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11285 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11287 return test_authenticated_encryption_SGL(
11288 &gcm_test_case_8, OUT_OF_PLACE, 400,
11289 gcm_test_case_8.plaintext.len);
11293 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11295 /* This test is not for OPENSSL PMD */
11296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11300 return test_authenticated_encryption_SGL(
11301 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11305 test_authentication_verify_fail_when_data_corrupted(
11306 struct crypto_testsuite_params *ts_params,
11307 struct crypto_unittest_params *ut_params,
11308 const struct test_crypto_vector *reference)
11310 return test_authentication_verify_fail_when_data_corruption(
11311 ts_params, ut_params, reference, 1);
11315 test_authentication_verify_fail_when_tag_corrupted(
11316 struct crypto_testsuite_params *ts_params,
11317 struct crypto_unittest_params *ut_params,
11318 const struct test_crypto_vector *reference)
11320 return test_authentication_verify_fail_when_data_corruption(
11321 ts_params, ut_params, reference, 0);
11325 test_authentication_verify_GMAC_fail_when_data_corrupted(
11326 struct crypto_testsuite_params *ts_params,
11327 struct crypto_unittest_params *ut_params,
11328 const struct test_crypto_vector *reference)
11330 return test_authentication_verify_GMAC_fail_when_corruption(
11331 ts_params, ut_params, reference, 1);
11335 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11336 struct crypto_testsuite_params *ts_params,
11337 struct crypto_unittest_params *ut_params,
11338 const struct test_crypto_vector *reference)
11340 return test_authentication_verify_GMAC_fail_when_corruption(
11341 ts_params, ut_params, reference, 0);
11345 test_authenticated_decryption_fail_when_data_corrupted(
11346 struct crypto_testsuite_params *ts_params,
11347 struct crypto_unittest_params *ut_params,
11348 const struct test_crypto_vector *reference)
11350 return test_authenticated_decryption_fail_when_corruption(
11351 ts_params, ut_params, reference, 1);
11355 test_authenticated_decryption_fail_when_tag_corrupted(
11356 struct crypto_testsuite_params *ts_params,
11357 struct crypto_unittest_params *ut_params,
11358 const struct test_crypto_vector *reference)
11360 return test_authenticated_decryption_fail_when_corruption(
11361 ts_params, ut_params, reference, 0);
11365 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11367 return test_authentication_verify_fail_when_data_corrupted(
11368 &testsuite_params, &unittest_params,
11369 &hmac_sha1_test_crypto_vector);
11373 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11375 return test_authentication_verify_fail_when_tag_corrupted(
11376 &testsuite_params, &unittest_params,
11377 &hmac_sha1_test_crypto_vector);
11381 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11383 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11384 &testsuite_params, &unittest_params,
11385 &aes128_gmac_test_vector);
11389 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11391 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11392 &testsuite_params, &unittest_params,
11393 &aes128_gmac_test_vector);
11397 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11399 return test_authenticated_decryption_fail_when_data_corrupted(
11402 &aes128cbc_hmac_sha1_test_vector);
11406 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11408 return test_authenticated_decryption_fail_when_tag_corrupted(
11411 &aes128cbc_hmac_sha1_test_vector);
11415 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11417 return test_authenticated_encryt_with_esn(
11420 &aes128cbc_hmac_sha1_aad_test_vector);
11424 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11426 return test_authenticated_decrypt_with_esn(
11429 &aes128cbc_hmac_sha1_aad_test_vector);
11432 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11434 /* global AESNI slave IDs for the scheduler test */
11435 uint8_t aesni_ids[2];
11438 test_scheduler_attach_slave_op(void)
11440 struct crypto_testsuite_params *ts_params = &testsuite_params;
11441 uint8_t sched_id = ts_params->valid_devs[0];
11442 uint32_t nb_devs, i, nb_devs_attached = 0;
11444 char vdev_name[32];
11446 /* create 2 AESNI_MB if necessary */
11447 nb_devs = rte_cryptodev_device_count_by_driver(
11448 rte_cryptodev_driver_id_get(
11449 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11451 for (i = nb_devs; i < 2; i++) {
11452 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11453 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11455 ret = rte_vdev_init(vdev_name, NULL);
11457 TEST_ASSERT(ret == 0,
11458 "Failed to create instance %u of"
11460 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11464 /* attach 2 AESNI_MB cdevs */
11465 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11467 struct rte_cryptodev_info info;
11468 unsigned int session_size;
11470 rte_cryptodev_info_get(i, &info);
11471 if (info.driver_id != rte_cryptodev_driver_id_get(
11472 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11475 session_size = rte_cryptodev_sym_get_private_session_size(i);
11477 * Create the session mempool again, since now there are new devices
11478 * to use the mempool.
11480 if (ts_params->session_mpool) {
11481 rte_mempool_free(ts_params->session_mpool);
11482 ts_params->session_mpool = NULL;
11484 if (ts_params->session_priv_mpool) {
11485 rte_mempool_free(ts_params->session_priv_mpool);
11486 ts_params->session_priv_mpool = NULL;
11489 if (info.sym.max_nb_sessions != 0 &&
11490 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11491 RTE_LOG(ERR, USER1,
11492 "Device does not support "
11493 "at least %u sessions\n",
11495 return TEST_FAILED;
11498 * Create mempool with maximum number of sessions,
11499 * to include the session headers
11501 if (ts_params->session_mpool == NULL) {
11502 ts_params->session_mpool =
11503 rte_cryptodev_sym_session_pool_create(
11505 MAX_NB_SESSIONS, 0, 0, 0,
11507 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11508 "session mempool allocation failed");
11512 * Create mempool with maximum number of sessions,
11513 * to include device specific session private data
11515 if (ts_params->session_priv_mpool == NULL) {
11516 ts_params->session_priv_mpool = rte_mempool_create(
11517 "test_sess_mp_priv",
11520 0, 0, NULL, NULL, NULL,
11521 NULL, SOCKET_ID_ANY,
11524 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11525 "session mempool allocation failed");
11528 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11529 ts_params->qp_conf.mp_session_private =
11530 ts_params->session_priv_mpool;
11532 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11535 TEST_ASSERT(ret == 0,
11536 "Failed to attach device %u of pmd : %s", i,
11537 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11539 aesni_ids[nb_devs_attached] = (uint8_t)i;
11541 nb_devs_attached++;
11548 test_scheduler_detach_slave_op(void)
11550 struct crypto_testsuite_params *ts_params = &testsuite_params;
11551 uint8_t sched_id = ts_params->valid_devs[0];
11555 for (i = 0; i < 2; i++) {
11556 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11558 TEST_ASSERT(ret == 0,
11559 "Failed to detach device %u", aesni_ids[i]);
11566 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11568 struct crypto_testsuite_params *ts_params = &testsuite_params;
11569 uint8_t sched_id = ts_params->valid_devs[0];
11571 return rte_cryptodev_scheduler_mode_set(sched_id,
11576 test_scheduler_mode_roundrobin_op(void)
11578 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11579 0, "Failed to set roundrobin mode");
11585 test_scheduler_mode_multicore_op(void)
11587 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11588 0, "Failed to set multicore mode");
11594 test_scheduler_mode_failover_op(void)
11596 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11597 0, "Failed to set failover mode");
11603 test_scheduler_mode_pkt_size_distr_op(void)
11605 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11606 0, "Failed to set pktsize mode");
11611 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11612 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11613 .setup = testsuite_setup,
11614 .teardown = testsuite_teardown,
11615 .unit_test_cases = {
11617 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11618 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11619 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11620 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11621 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11622 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11625 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11626 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11627 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11628 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11629 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11630 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11633 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11634 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11635 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11636 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11637 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11638 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11641 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11642 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11643 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11644 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11645 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11646 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11648 TEST_CASES_END() /**< NULL terminate unit test array */
11652 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11654 static struct unit_test_suite cryptodev_testsuite = {
11655 .suite_name = "Crypto Unit Test Suite",
11656 .setup = testsuite_setup,
11657 .teardown = testsuite_teardown,
11658 .unit_test_cases = {
11659 TEST_CASE_ST(ut_setup, ut_teardown,
11660 test_device_configure_invalid_dev_id),
11661 TEST_CASE_ST(ut_setup, ut_teardown,
11662 test_device_configure_invalid_queue_pair_ids),
11663 TEST_CASE_ST(ut_setup, ut_teardown,
11664 test_queue_pair_descriptor_setup),
11666 TEST_CASE_ST(ut_setup, ut_teardown,
11667 test_multi_session),
11668 TEST_CASE_ST(ut_setup, ut_teardown,
11669 test_multi_session_random_usage),
11671 TEST_CASE_ST(ut_setup, ut_teardown,
11672 test_null_invalid_operation),
11673 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11675 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11676 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11677 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11678 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11679 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11680 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11681 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11682 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11683 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11685 /** AES CCM Authenticated Encryption 128 bits key */
11686 TEST_CASE_ST(ut_setup, ut_teardown,
11687 test_AES_CCM_authenticated_encryption_test_case_128_1),
11688 TEST_CASE_ST(ut_setup, ut_teardown,
11689 test_AES_CCM_authenticated_encryption_test_case_128_2),
11690 TEST_CASE_ST(ut_setup, ut_teardown,
11691 test_AES_CCM_authenticated_encryption_test_case_128_3),
11693 /** AES CCM Authenticated Decryption 128 bits key*/
11694 TEST_CASE_ST(ut_setup, ut_teardown,
11695 test_AES_CCM_authenticated_decryption_test_case_128_1),
11696 TEST_CASE_ST(ut_setup, ut_teardown,
11697 test_AES_CCM_authenticated_decryption_test_case_128_2),
11698 TEST_CASE_ST(ut_setup, ut_teardown,
11699 test_AES_CCM_authenticated_decryption_test_case_128_3),
11701 /** AES CCM Authenticated Encryption 192 bits key */
11702 TEST_CASE_ST(ut_setup, ut_teardown,
11703 test_AES_CCM_authenticated_encryption_test_case_192_1),
11704 TEST_CASE_ST(ut_setup, ut_teardown,
11705 test_AES_CCM_authenticated_encryption_test_case_192_2),
11706 TEST_CASE_ST(ut_setup, ut_teardown,
11707 test_AES_CCM_authenticated_encryption_test_case_192_3),
11709 /** AES CCM Authenticated Decryption 192 bits key*/
11710 TEST_CASE_ST(ut_setup, ut_teardown,
11711 test_AES_CCM_authenticated_decryption_test_case_192_1),
11712 TEST_CASE_ST(ut_setup, ut_teardown,
11713 test_AES_CCM_authenticated_decryption_test_case_192_2),
11714 TEST_CASE_ST(ut_setup, ut_teardown,
11715 test_AES_CCM_authenticated_decryption_test_case_192_3),
11717 /** AES CCM Authenticated Encryption 256 bits key */
11718 TEST_CASE_ST(ut_setup, ut_teardown,
11719 test_AES_CCM_authenticated_encryption_test_case_256_1),
11720 TEST_CASE_ST(ut_setup, ut_teardown,
11721 test_AES_CCM_authenticated_encryption_test_case_256_2),
11722 TEST_CASE_ST(ut_setup, ut_teardown,
11723 test_AES_CCM_authenticated_encryption_test_case_256_3),
11725 /** AES CCM Authenticated Decryption 256 bits key*/
11726 TEST_CASE_ST(ut_setup, ut_teardown,
11727 test_AES_CCM_authenticated_decryption_test_case_256_1),
11728 TEST_CASE_ST(ut_setup, ut_teardown,
11729 test_AES_CCM_authenticated_decryption_test_case_256_2),
11730 TEST_CASE_ST(ut_setup, ut_teardown,
11731 test_AES_CCM_authenticated_decryption_test_case_256_3),
11733 /** AES GCM Authenticated Encryption */
11734 TEST_CASE_ST(ut_setup, ut_teardown,
11735 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11736 TEST_CASE_ST(ut_setup, ut_teardown,
11737 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11738 TEST_CASE_ST(ut_setup, ut_teardown,
11739 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11740 TEST_CASE_ST(ut_setup, ut_teardown,
11741 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11742 TEST_CASE_ST(ut_setup, ut_teardown,
11743 test_AES_GCM_authenticated_encryption_test_case_1),
11744 TEST_CASE_ST(ut_setup, ut_teardown,
11745 test_AES_GCM_authenticated_encryption_test_case_2),
11746 TEST_CASE_ST(ut_setup, ut_teardown,
11747 test_AES_GCM_authenticated_encryption_test_case_3),
11748 TEST_CASE_ST(ut_setup, ut_teardown,
11749 test_AES_GCM_authenticated_encryption_test_case_4),
11750 TEST_CASE_ST(ut_setup, ut_teardown,
11751 test_AES_GCM_authenticated_encryption_test_case_5),
11752 TEST_CASE_ST(ut_setup, ut_teardown,
11753 test_AES_GCM_authenticated_encryption_test_case_6),
11754 TEST_CASE_ST(ut_setup, ut_teardown,
11755 test_AES_GCM_authenticated_encryption_test_case_7),
11756 TEST_CASE_ST(ut_setup, ut_teardown,
11757 test_AES_GCM_authenticated_encryption_test_case_8),
11759 /** AES GCM Authenticated Decryption */
11760 TEST_CASE_ST(ut_setup, ut_teardown,
11761 test_AES_GCM_authenticated_decryption_test_case_1),
11762 TEST_CASE_ST(ut_setup, ut_teardown,
11763 test_AES_GCM_authenticated_decryption_test_case_2),
11764 TEST_CASE_ST(ut_setup, ut_teardown,
11765 test_AES_GCM_authenticated_decryption_test_case_3),
11766 TEST_CASE_ST(ut_setup, ut_teardown,
11767 test_AES_GCM_authenticated_decryption_test_case_4),
11768 TEST_CASE_ST(ut_setup, ut_teardown,
11769 test_AES_GCM_authenticated_decryption_test_case_5),
11770 TEST_CASE_ST(ut_setup, ut_teardown,
11771 test_AES_GCM_authenticated_decryption_test_case_6),
11772 TEST_CASE_ST(ut_setup, ut_teardown,
11773 test_AES_GCM_authenticated_decryption_test_case_7),
11774 TEST_CASE_ST(ut_setup, ut_teardown,
11775 test_AES_GCM_authenticated_decryption_test_case_8),
11777 /** AES GCM Authenticated Encryption 192 bits key */
11778 TEST_CASE_ST(ut_setup, ut_teardown,
11779 test_AES_GCM_auth_encryption_test_case_192_1),
11780 TEST_CASE_ST(ut_setup, ut_teardown,
11781 test_AES_GCM_auth_encryption_test_case_192_2),
11782 TEST_CASE_ST(ut_setup, ut_teardown,
11783 test_AES_GCM_auth_encryption_test_case_192_3),
11784 TEST_CASE_ST(ut_setup, ut_teardown,
11785 test_AES_GCM_auth_encryption_test_case_192_4),
11786 TEST_CASE_ST(ut_setup, ut_teardown,
11787 test_AES_GCM_auth_encryption_test_case_192_5),
11788 TEST_CASE_ST(ut_setup, ut_teardown,
11789 test_AES_GCM_auth_encryption_test_case_192_6),
11790 TEST_CASE_ST(ut_setup, ut_teardown,
11791 test_AES_GCM_auth_encryption_test_case_192_7),
11793 /** AES GCM Authenticated Decryption 192 bits key */
11794 TEST_CASE_ST(ut_setup, ut_teardown,
11795 test_AES_GCM_auth_decryption_test_case_192_1),
11796 TEST_CASE_ST(ut_setup, ut_teardown,
11797 test_AES_GCM_auth_decryption_test_case_192_2),
11798 TEST_CASE_ST(ut_setup, ut_teardown,
11799 test_AES_GCM_auth_decryption_test_case_192_3),
11800 TEST_CASE_ST(ut_setup, ut_teardown,
11801 test_AES_GCM_auth_decryption_test_case_192_4),
11802 TEST_CASE_ST(ut_setup, ut_teardown,
11803 test_AES_GCM_auth_decryption_test_case_192_5),
11804 TEST_CASE_ST(ut_setup, ut_teardown,
11805 test_AES_GCM_auth_decryption_test_case_192_6),
11806 TEST_CASE_ST(ut_setup, ut_teardown,
11807 test_AES_GCM_auth_decryption_test_case_192_7),
11809 /** AES GCM Authenticated Encryption 256 bits key */
11810 TEST_CASE_ST(ut_setup, ut_teardown,
11811 test_AES_GCM_auth_encryption_test_case_256_1),
11812 TEST_CASE_ST(ut_setup, ut_teardown,
11813 test_AES_GCM_auth_encryption_test_case_256_2),
11814 TEST_CASE_ST(ut_setup, ut_teardown,
11815 test_AES_GCM_auth_encryption_test_case_256_3),
11816 TEST_CASE_ST(ut_setup, ut_teardown,
11817 test_AES_GCM_auth_encryption_test_case_256_4),
11818 TEST_CASE_ST(ut_setup, ut_teardown,
11819 test_AES_GCM_auth_encryption_test_case_256_5),
11820 TEST_CASE_ST(ut_setup, ut_teardown,
11821 test_AES_GCM_auth_encryption_test_case_256_6),
11822 TEST_CASE_ST(ut_setup, ut_teardown,
11823 test_AES_GCM_auth_encryption_test_case_256_7),
11825 /** AES GCM Authenticated Decryption 256 bits key */
11826 TEST_CASE_ST(ut_setup, ut_teardown,
11827 test_AES_GCM_auth_decryption_test_case_256_1),
11828 TEST_CASE_ST(ut_setup, ut_teardown,
11829 test_AES_GCM_auth_decryption_test_case_256_2),
11830 TEST_CASE_ST(ut_setup, ut_teardown,
11831 test_AES_GCM_auth_decryption_test_case_256_3),
11832 TEST_CASE_ST(ut_setup, ut_teardown,
11833 test_AES_GCM_auth_decryption_test_case_256_4),
11834 TEST_CASE_ST(ut_setup, ut_teardown,
11835 test_AES_GCM_auth_decryption_test_case_256_5),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_GCM_auth_decryption_test_case_256_6),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_AES_GCM_auth_decryption_test_case_256_7),
11841 /** AES GCM Authenticated Encryption big aad size */
11842 TEST_CASE_ST(ut_setup, ut_teardown,
11843 test_AES_GCM_auth_encryption_test_case_aad_1),
11844 TEST_CASE_ST(ut_setup, ut_teardown,
11845 test_AES_GCM_auth_encryption_test_case_aad_2),
11847 /** AES GCM Authenticated Decryption big aad size */
11848 TEST_CASE_ST(ut_setup, ut_teardown,
11849 test_AES_GCM_auth_decryption_test_case_aad_1),
11850 TEST_CASE_ST(ut_setup, ut_teardown,
11851 test_AES_GCM_auth_decryption_test_case_aad_2),
11853 /** Out of place tests */
11854 TEST_CASE_ST(ut_setup, ut_teardown,
11855 test_AES_GCM_authenticated_encryption_oop_test_case_1),
11856 TEST_CASE_ST(ut_setup, ut_teardown,
11857 test_AES_GCM_authenticated_decryption_oop_test_case_1),
11859 /** Session-less tests */
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11865 /** AES GMAC Authentication */
11866 TEST_CASE_ST(ut_setup, ut_teardown,
11867 test_AES_GMAC_authentication_test_case_1),
11868 TEST_CASE_ST(ut_setup, ut_teardown,
11869 test_AES_GMAC_authentication_verify_test_case_1),
11870 TEST_CASE_ST(ut_setup, ut_teardown,
11871 test_AES_GMAC_authentication_test_case_2),
11872 TEST_CASE_ST(ut_setup, ut_teardown,
11873 test_AES_GMAC_authentication_verify_test_case_2),
11874 TEST_CASE_ST(ut_setup, ut_teardown,
11875 test_AES_GMAC_authentication_test_case_3),
11876 TEST_CASE_ST(ut_setup, ut_teardown,
11877 test_AES_GMAC_authentication_verify_test_case_3),
11878 TEST_CASE_ST(ut_setup, ut_teardown,
11879 test_AES_GMAC_authentication_test_case_4),
11880 TEST_CASE_ST(ut_setup, ut_teardown,
11881 test_AES_GMAC_authentication_verify_test_case_4),
11883 /** SNOW 3G encrypt only (UEA2) */
11884 TEST_CASE_ST(ut_setup, ut_teardown,
11885 test_snow3g_encryption_test_case_1),
11886 TEST_CASE_ST(ut_setup, ut_teardown,
11887 test_snow3g_encryption_test_case_2),
11888 TEST_CASE_ST(ut_setup, ut_teardown,
11889 test_snow3g_encryption_test_case_3),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_snow3g_encryption_test_case_4),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_snow3g_encryption_test_case_5),
11895 TEST_CASE_ST(ut_setup, ut_teardown,
11896 test_snow3g_encryption_test_case_1_oop),
11897 TEST_CASE_ST(ut_setup, ut_teardown,
11898 test_snow3g_encryption_test_case_1_oop_sgl),
11899 TEST_CASE_ST(ut_setup, ut_teardown,
11900 test_snow3g_encryption_test_case_1_offset_oop),
11901 TEST_CASE_ST(ut_setup, ut_teardown,
11902 test_snow3g_decryption_test_case_1_oop),
11904 /** SNOW 3G generate auth, then encrypt (UEA2) */
11905 TEST_CASE_ST(ut_setup, ut_teardown,
11906 test_snow3g_auth_cipher_test_case_1),
11907 TEST_CASE_ST(ut_setup, ut_teardown,
11908 test_snow3g_auth_cipher_test_case_2),
11909 TEST_CASE_ST(ut_setup, ut_teardown,
11910 test_snow3g_auth_cipher_test_case_2_oop),
11911 TEST_CASE_ST(ut_setup, ut_teardown,
11912 test_snow3g_auth_cipher_part_digest_enc),
11913 TEST_CASE_ST(ut_setup, ut_teardown,
11914 test_snow3g_auth_cipher_part_digest_enc_oop),
11915 TEST_CASE_ST(ut_setup, ut_teardown,
11916 test_snow3g_auth_cipher_test_case_3_sgl),
11917 TEST_CASE_ST(ut_setup, ut_teardown,
11918 test_snow3g_auth_cipher_test_case_3_oop_sgl),
11919 TEST_CASE_ST(ut_setup, ut_teardown,
11920 test_snow3g_auth_cipher_part_digest_enc_sgl),
11921 TEST_CASE_ST(ut_setup, ut_teardown,
11922 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11924 /** SNOW 3G decrypt (UEA2), then verify auth */
11925 TEST_CASE_ST(ut_setup, ut_teardown,
11926 test_snow3g_auth_cipher_verify_test_case_1),
11927 TEST_CASE_ST(ut_setup, ut_teardown,
11928 test_snow3g_auth_cipher_verify_test_case_2),
11929 TEST_CASE_ST(ut_setup, ut_teardown,
11930 test_snow3g_auth_cipher_verify_test_case_2_oop),
11931 TEST_CASE_ST(ut_setup, ut_teardown,
11932 test_snow3g_auth_cipher_verify_part_digest_enc),
11933 TEST_CASE_ST(ut_setup, ut_teardown,
11934 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11935 TEST_CASE_ST(ut_setup, ut_teardown,
11936 test_snow3g_auth_cipher_verify_test_case_3_sgl),
11937 TEST_CASE_ST(ut_setup, ut_teardown,
11938 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11939 TEST_CASE_ST(ut_setup, ut_teardown,
11940 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11941 TEST_CASE_ST(ut_setup, ut_teardown,
11942 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11944 /** SNOW 3G decrypt only (UEA2) */
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_snow3g_decryption_test_case_1),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_snow3g_decryption_test_case_2),
11949 TEST_CASE_ST(ut_setup, ut_teardown,
11950 test_snow3g_decryption_test_case_3),
11951 TEST_CASE_ST(ut_setup, ut_teardown,
11952 test_snow3g_decryption_test_case_4),
11953 TEST_CASE_ST(ut_setup, ut_teardown,
11954 test_snow3g_decryption_test_case_5),
11955 TEST_CASE_ST(ut_setup, ut_teardown,
11956 test_snow3g_decryption_with_digest_test_case_1),
11957 TEST_CASE_ST(ut_setup, ut_teardown,
11958 test_snow3g_hash_generate_test_case_1),
11959 TEST_CASE_ST(ut_setup, ut_teardown,
11960 test_snow3g_hash_generate_test_case_2),
11961 TEST_CASE_ST(ut_setup, ut_teardown,
11962 test_snow3g_hash_generate_test_case_3),
11963 /* Tests with buffers which length is not byte-aligned */
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_snow3g_hash_generate_test_case_4),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_snow3g_hash_generate_test_case_5),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_snow3g_hash_generate_test_case_6),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_snow3g_hash_verify_test_case_1),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_snow3g_hash_verify_test_case_2),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_snow3g_hash_verify_test_case_3),
11976 /* Tests with buffers which length is not byte-aligned */
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_snow3g_hash_verify_test_case_4),
11979 TEST_CASE_ST(ut_setup, ut_teardown,
11980 test_snow3g_hash_verify_test_case_5),
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_snow3g_hash_verify_test_case_6),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_snow3g_cipher_auth_test_case_1),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_snow3g_auth_cipher_with_digest_test_case_1),
11988 /** ZUC encrypt only (EEA3) */
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_zuc_encryption_test_case_1),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_zuc_encryption_test_case_2),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_zuc_encryption_test_case_3),
11995 TEST_CASE_ST(ut_setup, ut_teardown,
11996 test_zuc_encryption_test_case_4),
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_zuc_encryption_test_case_5),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_zuc_encryption_test_case_6_sgl),
12002 /** ZUC authenticate (EIA3) */
12003 TEST_CASE_ST(ut_setup, ut_teardown,
12004 test_zuc_hash_generate_test_case_1),
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_zuc_hash_generate_test_case_2),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_zuc_hash_generate_test_case_3),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_zuc_hash_generate_test_case_4),
12011 TEST_CASE_ST(ut_setup, ut_teardown,
12012 test_zuc_hash_generate_test_case_5),
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_zuc_hash_generate_test_case_6),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_zuc_hash_generate_test_case_7),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_zuc_hash_generate_test_case_8),
12020 /** ZUC alg-chain (EEA3/EIA3) */
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_zuc_cipher_auth_test_case_1),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_zuc_cipher_auth_test_case_2),
12026 /** ZUC generate auth, then encrypt (EEA3) */
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_zuc_auth_cipher_test_case_1),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_zuc_auth_cipher_test_case_1_oop),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_zuc_auth_cipher_test_case_1_sgl),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_zuc_auth_cipher_test_case_1_oop_sgl),
12036 /** ZUC decrypt (EEA3), then verify auth */
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_zuc_auth_cipher_verify_test_case_1),
12039 TEST_CASE_ST(ut_setup, ut_teardown,
12040 test_zuc_auth_cipher_verify_test_case_1_oop),
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_zuc_auth_cipher_verify_test_case_1_sgl),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12046 /** HMAC_MD5 Authentication */
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_MD5_HMAC_generate_case_1),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_MD5_HMAC_verify_case_1),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_MD5_HMAC_generate_case_2),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_MD5_HMAC_verify_case_2),
12056 /** KASUMI hash only (UIA1) */
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_kasumi_hash_generate_test_case_1),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_kasumi_hash_generate_test_case_2),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_kasumi_hash_generate_test_case_3),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_kasumi_hash_generate_test_case_4),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_kasumi_hash_generate_test_case_5),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_kasumi_hash_generate_test_case_6),
12070 TEST_CASE_ST(ut_setup, ut_teardown,
12071 test_kasumi_hash_verify_test_case_1),
12072 TEST_CASE_ST(ut_setup, ut_teardown,
12073 test_kasumi_hash_verify_test_case_2),
12074 TEST_CASE_ST(ut_setup, ut_teardown,
12075 test_kasumi_hash_verify_test_case_3),
12076 TEST_CASE_ST(ut_setup, ut_teardown,
12077 test_kasumi_hash_verify_test_case_4),
12078 TEST_CASE_ST(ut_setup, ut_teardown,
12079 test_kasumi_hash_verify_test_case_5),
12081 /** KASUMI encrypt only (UEA1) */
12082 TEST_CASE_ST(ut_setup, ut_teardown,
12083 test_kasumi_encryption_test_case_1),
12084 TEST_CASE_ST(ut_setup, ut_teardown,
12085 test_kasumi_encryption_test_case_1_sgl),
12086 TEST_CASE_ST(ut_setup, ut_teardown,
12087 test_kasumi_encryption_test_case_1_oop),
12088 TEST_CASE_ST(ut_setup, ut_teardown,
12089 test_kasumi_encryption_test_case_1_oop_sgl),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_kasumi_encryption_test_case_2),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_kasumi_encryption_test_case_3),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_kasumi_encryption_test_case_4),
12096 TEST_CASE_ST(ut_setup, ut_teardown,
12097 test_kasumi_encryption_test_case_5),
12099 /** KASUMI decrypt only (UEA1) */
12100 TEST_CASE_ST(ut_setup, ut_teardown,
12101 test_kasumi_decryption_test_case_1),
12102 TEST_CASE_ST(ut_setup, ut_teardown,
12103 test_kasumi_decryption_test_case_2),
12104 TEST_CASE_ST(ut_setup, ut_teardown,
12105 test_kasumi_decryption_test_case_3),
12106 TEST_CASE_ST(ut_setup, ut_teardown,
12107 test_kasumi_decryption_test_case_4),
12108 TEST_CASE_ST(ut_setup, ut_teardown,
12109 test_kasumi_decryption_test_case_5),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_kasumi_decryption_test_case_1_oop),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_kasumi_cipher_auth_test_case_1),
12116 /** KASUMI generate auth, then encrypt (F8) */
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_kasumi_auth_cipher_test_case_1),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_kasumi_auth_cipher_test_case_2),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_kasumi_auth_cipher_test_case_2_oop),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_kasumi_auth_cipher_test_case_2_sgl),
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12128 /** KASUMI decrypt (F8), then verify auth */
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_kasumi_auth_cipher_verify_test_case_1),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_kasumi_auth_cipher_verify_test_case_2),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_kasumi_auth_cipher_verify_test_case_2_oop),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12140 /** ESN Testcase */
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12146 /** Negative tests */
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12161 TEST_CASE_ST(ut_setup, ut_teardown,
12162 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 authentication_verify_AES128_GMAC_fail_data_corrupt),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12184 /** Mixed CIPHER + HASH algorithms */
12185 /** AUTH AES CMAC + CIPHER AES CTR */
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12203 /** AUTH ZUC + CIPHER SNOW3G */
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_auth_zuc_cipher_snow_test_case_1),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_verify_auth_zuc_cipher_snow_test_case_1),
12208 /** AUTH AES CMAC + CIPHER SNOW3G */
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_auth_aes_cmac_cipher_snow_test_case_1),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12213 /** AUTH ZUC + CIPHER AES CTR */
12214 TEST_CASE_ST(ut_setup, ut_teardown,
12215 test_auth_zuc_cipher_aes_ctr_test_case_1),
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12218 /** AUTH SNOW3G + CIPHER AES CTR */
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_auth_snow_cipher_aes_ctr_test_case_1),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12223 /** AUTH SNOW3G + CIPHER ZUC */
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_auth_snow_cipher_zuc_test_case_1),
12226 TEST_CASE_ST(ut_setup, ut_teardown,
12227 test_verify_auth_snow_cipher_zuc_test_case_1),
12228 /** AUTH AES CMAC + CIPHER ZUC */
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_auth_aes_cmac_cipher_zuc_test_case_1),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12234 /** AUTH NULL + CIPHER SNOW3G */
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_auth_null_cipher_snow_test_case_1),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_verify_auth_null_cipher_snow_test_case_1),
12239 /** AUTH NULL + CIPHER ZUC */
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_auth_null_cipher_zuc_test_case_1),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_verify_auth_null_cipher_zuc_test_case_1),
12244 /** AUTH SNOW3G + CIPHER NULL */
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_auth_snow_cipher_null_test_case_1),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_verify_auth_snow_cipher_null_test_case_1),
12249 /** AUTH ZUC + CIPHER NULL */
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_auth_zuc_cipher_null_test_case_1),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_verify_auth_zuc_cipher_null_test_case_1),
12254 /** AUTH NULL + CIPHER AES CTR */
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_auth_null_cipher_aes_ctr_test_case_1),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12259 /** AUTH AES CMAC + CIPHER NULL */
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 test_auth_aes_cmac_cipher_null_test_case_1),
12262 TEST_CASE_ST(ut_setup, ut_teardown,
12263 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12265 TEST_CASES_END() /**< NULL terminate unit test array */
12269 static struct unit_test_suite cryptodev_virtio_testsuite = {
12270 .suite_name = "Crypto VIRTIO Unit Test Suite",
12271 .setup = testsuite_setup,
12272 .teardown = testsuite_teardown,
12273 .unit_test_cases = {
12274 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12276 TEST_CASES_END() /**< NULL terminate unit test array */
12280 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12281 .suite_name = "Crypto CAAM JR Unit Test Suite",
12282 .setup = testsuite_setup,
12283 .teardown = testsuite_teardown,
12284 .unit_test_cases = {
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_device_configure_invalid_dev_id),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_multi_session),
12290 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12291 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12292 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12293 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12294 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12296 TEST_CASES_END() /**< NULL terminate unit test array */
12300 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
12301 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12302 .setup = testsuite_setup,
12303 .teardown = testsuite_teardown,
12304 .unit_test_cases = {
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_device_configure_invalid_dev_id),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_multi_session),
12310 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12311 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12312 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12313 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12314 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12316 #ifdef RTE_LIBRTE_SECURITY
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_PDCP_PROTO_cplane_encap_all),
12320 TEST_CASE_ST(ut_setup, ut_teardown,
12321 test_PDCP_PROTO_cplane_decap_all),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_PDCP_PROTO_uplane_encap_all),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_PDCP_PROTO_uplane_decap_all),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_PDCP_PROTO_SGL_in_place_32B),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_PDCP_PROTO_SGL_oop_32B_128B),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_PDCP_PROTO_SGL_oop_32B_40B),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_PDCP_PROTO_SGL_oop_128B_32B),
12338 /** AES GCM Authenticated Encryption */
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_AES_GCM_authenticated_encryption_test_case_1),
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_AES_GCM_authenticated_encryption_test_case_2),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_AES_GCM_authenticated_encryption_test_case_3),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_AES_GCM_authenticated_encryption_test_case_4),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_AES_GCM_authenticated_encryption_test_case_5),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_AES_GCM_authenticated_encryption_test_case_6),
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_AES_GCM_authenticated_encryption_test_case_7),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_AES_GCM_authenticated_encryption_test_case_8),
12364 /** AES GCM Authenticated Decryption */
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_AES_GCM_authenticated_decryption_test_case_1),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_AES_GCM_authenticated_decryption_test_case_2),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_AES_GCM_authenticated_decryption_test_case_3),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_AES_GCM_authenticated_decryption_test_case_4),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_AES_GCM_authenticated_decryption_test_case_5),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_AES_GCM_authenticated_decryption_test_case_6),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_AES_GCM_authenticated_decryption_test_case_7),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GCM_authenticated_decryption_test_case_8),
12382 /** AES GCM Authenticated Encryption 192 bits key */
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_AES_GCM_auth_encryption_test_case_192_1),
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_AES_GCM_auth_encryption_test_case_192_2),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_AES_GCM_auth_encryption_test_case_192_3),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_AES_GCM_auth_encryption_test_case_192_4),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_AES_GCM_auth_encryption_test_case_192_5),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_auth_encryption_test_case_192_6),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_auth_encryption_test_case_192_7),
12398 /** AES GCM Authenticated Decryption 192 bits key */
12399 TEST_CASE_ST(ut_setup, ut_teardown,
12400 test_AES_GCM_auth_decryption_test_case_192_1),
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_auth_decryption_test_case_192_2),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_AES_GCM_auth_decryption_test_case_192_3),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_AES_GCM_auth_decryption_test_case_192_4),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_AES_GCM_auth_decryption_test_case_192_5),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_AES_GCM_auth_decryption_test_case_192_6),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_AES_GCM_auth_decryption_test_case_192_7),
12414 /** AES GCM Authenticated Encryption 256 bits key */
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_AES_GCM_auth_encryption_test_case_256_1),
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_AES_GCM_auth_encryption_test_case_256_2),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_AES_GCM_auth_encryption_test_case_256_3),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_AES_GCM_auth_encryption_test_case_256_4),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_encryption_test_case_256_5),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_encryption_test_case_256_6),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_AES_GCM_auth_encryption_test_case_256_7),
12430 /** AES GCM Authenticated Decryption 256 bits key */
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_auth_decryption_test_case_256_1),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_AES_GCM_auth_decryption_test_case_256_2),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GCM_auth_decryption_test_case_256_3),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GCM_auth_decryption_test_case_256_4),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GCM_auth_decryption_test_case_256_5),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GCM_auth_decryption_test_case_256_6),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GCM_auth_decryption_test_case_256_7),
12446 /** Out of place tests */
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12452 /** SNOW 3G encrypt only (UEA2) */
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_snow3g_encryption_test_case_1),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_snow3g_encryption_test_case_2),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_snow3g_encryption_test_case_3),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_snow3g_encryption_test_case_4),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_snow3g_encryption_test_case_5),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_snow3g_encryption_test_case_1_oop),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_snow3g_encryption_test_case_1_oop_sgl),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_snow3g_decryption_test_case_1_oop),
12471 /** SNOW 3G decrypt only (UEA2) */
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_snow3g_decryption_test_case_1),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_snow3g_decryption_test_case_2),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_snow3g_decryption_test_case_3),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_snow3g_decryption_test_case_4),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_snow3g_decryption_test_case_5),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_snow3g_hash_generate_test_case_1),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_snow3g_hash_generate_test_case_2),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_snow3g_hash_generate_test_case_3),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_snow3g_hash_verify_test_case_1),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_snow3g_hash_verify_test_case_2),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_snow3g_hash_verify_test_case_3),
12496 /** ZUC encrypt only (EEA3) */
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_zuc_encryption_test_case_1),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_zuc_encryption_test_case_2),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_zuc_encryption_test_case_3),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_zuc_encryption_test_case_4),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_zuc_encryption_test_case_5),
12508 /** ZUC authenticate (EIA3) */
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_zuc_hash_generate_test_case_6),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_zuc_hash_generate_test_case_7),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_zuc_hash_generate_test_case_8),
12516 /** Negative tests */
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12556 TEST_CASES_END() /**< NULL terminate unit test array */
12560 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
12561 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12562 .setup = testsuite_setup,
12563 .teardown = testsuite_teardown,
12564 .unit_test_cases = {
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_device_configure_invalid_dev_id),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_multi_session),
12569 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12570 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12571 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12572 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12573 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12575 #ifdef RTE_LIBRTE_SECURITY
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_PDCP_PROTO_cplane_encap_all),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_PDCP_PROTO_cplane_decap_all),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_PDCP_PROTO_uplane_encap_all),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_PDCP_PROTO_uplane_decap_all),
12588 TEST_CASE_ST(ut_setup, ut_teardown,
12589 test_PDCP_PROTO_SGL_in_place_32B),
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_PDCP_PROTO_SGL_oop_32B_128B),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_PDCP_PROTO_SGL_oop_32B_40B),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_PDCP_PROTO_SGL_oop_128B_32B),
12597 /** AES GCM Authenticated Encryption */
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_AES_GCM_authenticated_encryption_test_case_1),
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_AES_GCM_authenticated_encryption_test_case_2),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_AES_GCM_authenticated_encryption_test_case_3),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_AES_GCM_authenticated_encryption_test_case_4),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_AES_GCM_authenticated_encryption_test_case_5),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_AES_GCM_authenticated_encryption_test_case_6),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_AES_GCM_authenticated_encryption_test_case_7),
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_AES_GCM_authenticated_encryption_test_case_8),
12623 /** AES GCM Authenticated Decryption */
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_AES_GCM_authenticated_decryption_test_case_1),
12626 TEST_CASE_ST(ut_setup, ut_teardown,
12627 test_AES_GCM_authenticated_decryption_test_case_2),
12628 TEST_CASE_ST(ut_setup, ut_teardown,
12629 test_AES_GCM_authenticated_decryption_test_case_3),
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_AES_GCM_authenticated_decryption_test_case_4),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_AES_GCM_authenticated_decryption_test_case_5),
12634 TEST_CASE_ST(ut_setup, ut_teardown,
12635 test_AES_GCM_authenticated_decryption_test_case_6),
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 test_AES_GCM_authenticated_decryption_test_case_7),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 test_AES_GCM_authenticated_decryption_test_case_8),
12641 /** AES GCM Authenticated Encryption 192 bits key */
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_AES_GCM_auth_encryption_test_case_192_1),
12644 TEST_CASE_ST(ut_setup, ut_teardown,
12645 test_AES_GCM_auth_encryption_test_case_192_2),
12646 TEST_CASE_ST(ut_setup, ut_teardown,
12647 test_AES_GCM_auth_encryption_test_case_192_3),
12648 TEST_CASE_ST(ut_setup, ut_teardown,
12649 test_AES_GCM_auth_encryption_test_case_192_4),
12650 TEST_CASE_ST(ut_setup, ut_teardown,
12651 test_AES_GCM_auth_encryption_test_case_192_5),
12652 TEST_CASE_ST(ut_setup, ut_teardown,
12653 test_AES_GCM_auth_encryption_test_case_192_6),
12654 TEST_CASE_ST(ut_setup, ut_teardown,
12655 test_AES_GCM_auth_encryption_test_case_192_7),
12657 /** AES GCM Authenticated Decryption 192 bits key */
12658 TEST_CASE_ST(ut_setup, ut_teardown,
12659 test_AES_GCM_auth_decryption_test_case_192_1),
12660 TEST_CASE_ST(ut_setup, ut_teardown,
12661 test_AES_GCM_auth_decryption_test_case_192_2),
12662 TEST_CASE_ST(ut_setup, ut_teardown,
12663 test_AES_GCM_auth_decryption_test_case_192_3),
12664 TEST_CASE_ST(ut_setup, ut_teardown,
12665 test_AES_GCM_auth_decryption_test_case_192_4),
12666 TEST_CASE_ST(ut_setup, ut_teardown,
12667 test_AES_GCM_auth_decryption_test_case_192_5),
12668 TEST_CASE_ST(ut_setup, ut_teardown,
12669 test_AES_GCM_auth_decryption_test_case_192_6),
12670 TEST_CASE_ST(ut_setup, ut_teardown,
12671 test_AES_GCM_auth_decryption_test_case_192_7),
12673 /** AES GCM Authenticated Encryption 256 bits key */
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 test_AES_GCM_auth_encryption_test_case_256_1),
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 test_AES_GCM_auth_encryption_test_case_256_2),
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 test_AES_GCM_auth_encryption_test_case_256_3),
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_AES_GCM_auth_encryption_test_case_256_4),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_AES_GCM_auth_encryption_test_case_256_5),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_AES_GCM_auth_encryption_test_case_256_6),
12686 TEST_CASE_ST(ut_setup, ut_teardown,
12687 test_AES_GCM_auth_encryption_test_case_256_7),
12689 /** AES GCM Authenticated Decryption 256 bits key */
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_AES_GCM_auth_decryption_test_case_256_1),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_AES_GCM_auth_decryption_test_case_256_2),
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_AES_GCM_auth_decryption_test_case_256_3),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_auth_decryption_test_case_256_4),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_auth_decryption_test_case_256_5),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_auth_decryption_test_case_256_6),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_AES_GCM_auth_decryption_test_case_256_7),
12705 /** Out of place tests */
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12711 /** SNOW 3G encrypt only (UEA2) */
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_snow3g_encryption_test_case_1),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_snow3g_encryption_test_case_2),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_snow3g_encryption_test_case_3),
12718 TEST_CASE_ST(ut_setup, ut_teardown,
12719 test_snow3g_encryption_test_case_4),
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_snow3g_encryption_test_case_5),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_snow3g_encryption_test_case_1_oop),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_snow3g_encryption_test_case_1_oop_sgl),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_snow3g_decryption_test_case_1_oop),
12730 /** SNOW 3G decrypt only (UEA2) */
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_snow3g_decryption_test_case_1),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_snow3g_decryption_test_case_2),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_snow3g_decryption_test_case_3),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_snow3g_decryption_test_case_4),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_snow3g_decryption_test_case_5),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_snow3g_hash_generate_test_case_1),
12744 TEST_CASE_ST(ut_setup, ut_teardown,
12745 test_snow3g_hash_generate_test_case_2),
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_snow3g_hash_generate_test_case_3),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_snow3g_hash_verify_test_case_1),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_snow3g_hash_verify_test_case_2),
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_snow3g_hash_verify_test_case_3),
12755 /** ZUC encrypt only (EEA3) */
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_zuc_encryption_test_case_1),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_zuc_encryption_test_case_2),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_zuc_encryption_test_case_3),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_zuc_encryption_test_case_4),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_zuc_encryption_test_case_5),
12767 /** ZUC authenticate (EIA3) */
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_zuc_hash_generate_test_case_6),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_zuc_hash_generate_test_case_7),
12772 TEST_CASE_ST(ut_setup, ut_teardown,
12773 test_zuc_hash_generate_test_case_8),
12775 /** HMAC_MD5 Authentication */
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_MD5_HMAC_generate_case_1),
12778 TEST_CASE_ST(ut_setup, ut_teardown,
12779 test_MD5_HMAC_verify_case_1),
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_MD5_HMAC_generate_case_2),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_MD5_HMAC_verify_case_2),
12785 /** Negative tests */
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12802 TEST_CASE_ST(ut_setup, ut_teardown,
12803 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12823 TEST_CASE_ST(ut_setup, ut_teardown,
12824 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12826 TEST_CASES_END() /**< NULL terminate unit test array */
12830 static struct unit_test_suite cryptodev_armv8_testsuite = {
12831 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12832 .setup = testsuite_setup,
12833 .teardown = testsuite_teardown,
12834 .unit_test_cases = {
12835 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12837 /** Negative tests */
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12843 TEST_CASES_END() /**< NULL terminate unit test array */
12847 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12848 .suite_name = "Crypto Device Marvell Component Test Suite",
12849 .setup = testsuite_setup,
12850 .teardown = testsuite_teardown,
12851 .unit_test_cases = {
12852 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_multi_session_random_usage),
12855 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12856 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12857 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12858 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12859 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12861 /** Negative tests */
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12871 TEST_CASES_END() /**< NULL terminate unit test array */
12875 static struct unit_test_suite cryptodev_ccp_testsuite = {
12876 .suite_name = "Crypto Device CCP Unit Test Suite",
12877 .setup = testsuite_setup,
12878 .teardown = testsuite_teardown,
12879 .unit_test_cases = {
12880 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_multi_session_random_usage),
12883 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12884 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12885 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12886 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12887 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12889 /** Negative tests */
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12899 TEST_CASES_END() /**< NULL terminate unit test array */
12903 static struct unit_test_suite cryptodev_octeontx_testsuite = {
12904 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12905 .setup = testsuite_setup,
12906 .teardown = testsuite_teardown,
12907 .unit_test_cases = {
12908 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12909 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12910 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12911 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12912 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12914 /** AES GCM Authenticated Encryption */
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GCM_authenticated_encryption_test_case_1),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GCM_authenticated_encryption_test_case_2),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GCM_authenticated_encryption_test_case_3),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GCM_authenticated_encryption_test_case_4),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GCM_authenticated_encryption_test_case_5),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 test_AES_GCM_authenticated_encryption_test_case_6),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 test_AES_GCM_authenticated_encryption_test_case_7),
12930 /** AES GCM Authenticated Decryption */
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 test_AES_GCM_authenticated_decryption_test_case_1),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_AES_GCM_authenticated_decryption_test_case_2),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 test_AES_GCM_authenticated_decryption_test_case_3),
12937 TEST_CASE_ST(ut_setup, ut_teardown,
12938 test_AES_GCM_authenticated_decryption_test_case_4),
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_AES_GCM_authenticated_decryption_test_case_5),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_AES_GCM_authenticated_decryption_test_case_6),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_AES_GCM_authenticated_decryption_test_case_7),
12945 /** AES GMAC Authentication */
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_AES_GMAC_authentication_test_case_1),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_AES_GMAC_authentication_verify_test_case_1),
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_AES_GMAC_authentication_test_case_2),
12952 TEST_CASE_ST(ut_setup, ut_teardown,
12953 test_AES_GMAC_authentication_verify_test_case_2),
12954 TEST_CASE_ST(ut_setup, ut_teardown,
12955 test_AES_GMAC_authentication_test_case_3),
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 test_AES_GMAC_authentication_verify_test_case_3),
12959 /** SNOW 3G encrypt only (UEA2) */
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 test_snow3g_encryption_test_case_1),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_snow3g_encryption_test_case_2),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_snow3g_encryption_test_case_3),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_snow3g_encryption_test_case_4),
12968 TEST_CASE_ST(ut_setup, ut_teardown,
12969 test_snow3g_encryption_test_case_5),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_snow3g_encryption_test_case_1_oop),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_snow3g_decryption_test_case_1_oop),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 test_snow3g_encryption_test_case_1_oop_sgl),
12978 /** SNOW 3G decrypt only (UEA2) */
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_snow3g_decryption_test_case_1),
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 test_snow3g_decryption_test_case_2),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 test_snow3g_decryption_test_case_3),
12985 TEST_CASE_ST(ut_setup, ut_teardown,
12986 test_snow3g_decryption_test_case_4),
12987 TEST_CASE_ST(ut_setup, ut_teardown,
12988 test_snow3g_decryption_test_case_5),
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 test_snow3g_hash_generate_test_case_1),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_snow3g_hash_generate_test_case_2),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_snow3g_hash_generate_test_case_3),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_snow3g_hash_verify_test_case_1),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_snow3g_hash_verify_test_case_2),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_snow3g_hash_verify_test_case_3),
13003 /** ZUC encrypt only (EEA3) */
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_zuc_encryption_test_case_1),
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_zuc_encryption_test_case_2),
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_zuc_encryption_test_case_3),
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_zuc_encryption_test_case_4),
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_zuc_encryption_test_case_5),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_zuc_hash_generate_test_case_1),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_zuc_hash_generate_test_case_2),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_zuc_hash_generate_test_case_3),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_zuc_hash_generate_test_case_4),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_zuc_hash_generate_test_case_5),
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_zuc_encryption_test_case_6_sgl),
13027 /** KASUMI encrypt only (UEA1) */
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_kasumi_encryption_test_case_1),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_kasumi_encryption_test_case_2),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_kasumi_encryption_test_case_3),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_kasumi_encryption_test_case_4),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_kasumi_encryption_test_case_5),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_kasumi_encryption_test_case_1_sgl),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_kasumi_encryption_test_case_1_oop_sgl),
13042 /** KASUMI decrypt only (UEA1) */
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 test_kasumi_decryption_test_case_1),
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 test_kasumi_decryption_test_case_2),
13047 TEST_CASE_ST(ut_setup, ut_teardown,
13048 test_kasumi_decryption_test_case_3),
13049 TEST_CASE_ST(ut_setup, ut_teardown,
13050 test_kasumi_decryption_test_case_4),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 test_kasumi_decryption_test_case_5),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_kasumi_encryption_test_case_1_oop),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_kasumi_decryption_test_case_1_oop),
13059 /** KASUMI hash only (UIA1) */
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_kasumi_hash_generate_test_case_1),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_kasumi_hash_generate_test_case_2),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_kasumi_hash_generate_test_case_3),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_kasumi_hash_generate_test_case_4),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_kasumi_hash_generate_test_case_5),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_kasumi_hash_generate_test_case_6),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_kasumi_hash_verify_test_case_1),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_kasumi_hash_verify_test_case_2),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_kasumi_hash_verify_test_case_3),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_kasumi_hash_verify_test_case_4),
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_kasumi_hash_verify_test_case_5),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_null_cipher_only_operation),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_null_auth_only_operation),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_null_cipher_auth_operation),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_null_auth_cipher_operation),
13093 /** Negative tests */
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 authentication_verify_AES128_GMAC_fail_data_corrupt),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13106 TEST_CASES_END() /**< NULL terminate unit test array */
13110 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13111 .suite_name = "Crypto NITROX Unit Test Suite",
13112 .setup = testsuite_setup,
13113 .teardown = testsuite_teardown,
13114 .unit_test_cases = {
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_device_configure_invalid_dev_id),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_device_configure_invalid_queue_pair_ids),
13119 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13121 TEST_CASES_END() /**< NULL terminate unit test array */
13125 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13126 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13127 .setup = testsuite_setup,
13128 .teardown = testsuite_teardown,
13129 .unit_test_cases = {
13130 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13131 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13132 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13133 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13134 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13136 /** AES GCM Authenticated Encryption */
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_AES_GCM_authenticated_encryption_test_case_1),
13139 TEST_CASE_ST(ut_setup, ut_teardown,
13140 test_AES_GCM_authenticated_encryption_test_case_2),
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_AES_GCM_authenticated_encryption_test_case_3),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_AES_GCM_authenticated_encryption_test_case_4),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_AES_GCM_authenticated_encryption_test_case_5),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_AES_GCM_authenticated_encryption_test_case_6),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_AES_GCM_authenticated_encryption_test_case_7),
13152 /** AES GCM Authenticated Decryption */
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_AES_GCM_authenticated_decryption_test_case_1),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_AES_GCM_authenticated_decryption_test_case_2),
13157 TEST_CASE_ST(ut_setup, ut_teardown,
13158 test_AES_GCM_authenticated_decryption_test_case_3),
13159 TEST_CASE_ST(ut_setup, ut_teardown,
13160 test_AES_GCM_authenticated_decryption_test_case_4),
13161 TEST_CASE_ST(ut_setup, ut_teardown,
13162 test_AES_GCM_authenticated_decryption_test_case_5),
13163 TEST_CASE_ST(ut_setup, ut_teardown,
13164 test_AES_GCM_authenticated_decryption_test_case_6),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_AES_GCM_authenticated_decryption_test_case_7),
13167 /** AES GMAC Authentication */
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GMAC_authentication_test_case_1),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_AES_GMAC_authentication_verify_test_case_1),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GMAC_authentication_test_case_2),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_AES_GMAC_authentication_verify_test_case_2),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GMAC_authentication_test_case_3),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GMAC_authentication_verify_test_case_3),
13181 /** SNOW 3G encrypt only (UEA2) */
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_snow3g_encryption_test_case_1),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_snow3g_encryption_test_case_2),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_snow3g_encryption_test_case_3),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_snow3g_encryption_test_case_4),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_snow3g_encryption_test_case_5),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_snow3g_encryption_test_case_1_oop),
13195 TEST_CASE_ST(ut_setup, ut_teardown,
13196 test_snow3g_decryption_test_case_1_oop),
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_snow3g_encryption_test_case_1_oop_sgl),
13200 /** SNOW 3G decrypt only (UEA2) */
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_snow3g_decryption_test_case_1),
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_snow3g_decryption_test_case_2),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_snow3g_decryption_test_case_3),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_snow3g_decryption_test_case_4),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_snow3g_decryption_test_case_5),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_snow3g_hash_generate_test_case_1),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 test_snow3g_hash_generate_test_case_2),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_snow3g_hash_generate_test_case_3),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_snow3g_hash_verify_test_case_1),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_snow3g_hash_verify_test_case_2),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_snow3g_hash_verify_test_case_3),
13225 /** ZUC encrypt only (EEA3) */
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_zuc_encryption_test_case_1),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_zuc_encryption_test_case_2),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_zuc_encryption_test_case_3),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_zuc_encryption_test_case_4),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_zuc_encryption_test_case_5),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_zuc_hash_generate_test_case_1),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_zuc_hash_generate_test_case_2),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_zuc_hash_generate_test_case_3),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_zuc_hash_generate_test_case_4),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_zuc_hash_generate_test_case_5),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_zuc_encryption_test_case_6_sgl),
13249 /** KASUMI encrypt only (UEA1) */
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_kasumi_encryption_test_case_1),
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_kasumi_encryption_test_case_2),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_kasumi_encryption_test_case_3),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_kasumi_encryption_test_case_4),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_kasumi_encryption_test_case_5),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_kasumi_encryption_test_case_1_sgl),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_kasumi_encryption_test_case_1_oop_sgl),
13264 /** KASUMI decrypt only (UEA1) */
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_kasumi_decryption_test_case_1),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_kasumi_decryption_test_case_2),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_kasumi_decryption_test_case_3),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_kasumi_decryption_test_case_4),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_kasumi_decryption_test_case_5),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_kasumi_encryption_test_case_1_oop),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_kasumi_decryption_test_case_1_oop),
13281 /** KASUMI hash only (UIA1) */
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_kasumi_hash_generate_test_case_1),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_kasumi_hash_generate_test_case_2),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_kasumi_hash_generate_test_case_3),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_kasumi_hash_generate_test_case_4),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_kasumi_hash_generate_test_case_5),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_kasumi_hash_generate_test_case_6),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_kasumi_hash_verify_test_case_1),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_kasumi_hash_verify_test_case_2),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_kasumi_hash_verify_test_case_3),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_kasumi_hash_verify_test_case_4),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_kasumi_hash_verify_test_case_5),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_null_cipher_only_operation),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_null_auth_only_operation),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_null_cipher_auth_operation),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_null_auth_cipher_operation),
13315 /** Negative tests */
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 authentication_verify_AES128_GMAC_fail_data_corrupt),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13328 TEST_CASES_END() /**< NULL terminate unit test array */
13333 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13335 gbl_driver_id = rte_cryptodev_driver_id_get(
13336 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13338 if (gbl_driver_id == -1) {
13339 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13340 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13341 "are enabled in config file to run this testsuite.\n");
13342 return TEST_SKIPPED;
13345 return unit_test_suite_runner(&cryptodev_testsuite);
13349 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13351 gbl_driver_id = rte_cryptodev_driver_id_get(
13352 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13354 if (gbl_driver_id == -1) {
13355 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
13356 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
13357 "in config file to run this testsuite.\n");
13358 return TEST_FAILED;
13361 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13365 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13367 gbl_driver_id = rte_cryptodev_driver_id_get(
13368 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13370 if (gbl_driver_id == -1) {
13371 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
13372 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
13373 "in config file to run this testsuite.\n");
13374 return TEST_SKIPPED;
13377 return unit_test_suite_runner(&cryptodev_testsuite);
13381 test_cryptodev_openssl(void)
13383 gbl_driver_id = rte_cryptodev_driver_id_get(
13384 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13386 if (gbl_driver_id == -1) {
13387 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
13388 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
13389 "in config file to run this testsuite.\n");
13390 return TEST_SKIPPED;
13393 return unit_test_suite_runner(&cryptodev_testsuite);
13397 test_cryptodev_aesni_gcm(void)
13399 gbl_driver_id = rte_cryptodev_driver_id_get(
13400 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13402 if (gbl_driver_id == -1) {
13403 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13404 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13405 "in config file to run this testsuite.\n");
13406 return TEST_SKIPPED;
13409 return unit_test_suite_runner(&cryptodev_testsuite);
13413 test_cryptodev_cpu_aesni_gcm(void)
13416 enum rte_security_session_action_type at;
13418 gbl_driver_id = rte_cryptodev_driver_id_get(
13419 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13421 if (gbl_driver_id == -1) {
13422 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
13423 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
13424 "in config file to run this testsuite.\n");
13425 return TEST_SKIPPED;
13428 at = gbl_action_type;
13429 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13430 rc = unit_test_suite_runner(&cryptodev_testsuite);
13431 gbl_action_type = at;
13436 test_cryptodev_null(void)
13438 gbl_driver_id = rte_cryptodev_driver_id_get(
13439 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13441 if (gbl_driver_id == -1) {
13442 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
13443 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
13444 "in config file to run this testsuite.\n");
13445 return TEST_SKIPPED;
13448 return unit_test_suite_runner(&cryptodev_testsuite);
13452 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13454 gbl_driver_id = rte_cryptodev_driver_id_get(
13455 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13457 if (gbl_driver_id == -1) {
13458 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
13459 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
13460 "in config file to run this testsuite.\n");
13461 return TEST_SKIPPED;
13464 return unit_test_suite_runner(&cryptodev_testsuite);
13468 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13470 gbl_driver_id = rte_cryptodev_driver_id_get(
13471 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13473 if (gbl_driver_id == -1) {
13474 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13475 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
13476 "in config file to run this testsuite.\n");
13477 return TEST_SKIPPED;
13480 return unit_test_suite_runner(&cryptodev_testsuite);
13484 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13486 gbl_driver_id = rte_cryptodev_driver_id_get(
13487 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13489 if (gbl_driver_id == -1) {
13490 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
13491 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
13492 "in config file to run this testsuite.\n");
13493 return TEST_SKIPPED;
13496 return unit_test_suite_runner(&cryptodev_testsuite);
13500 test_cryptodev_armv8(void)
13502 gbl_driver_id = rte_cryptodev_driver_id_get(
13503 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13505 if (gbl_driver_id == -1) {
13506 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
13507 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
13508 "in config file to run this testsuite.\n");
13509 return TEST_SKIPPED;
13512 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
13516 test_cryptodev_mrvl(void)
13518 gbl_driver_id = rte_cryptodev_driver_id_get(
13519 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13521 if (gbl_driver_id == -1) {
13522 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
13523 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
13524 "in config file to run this testsuite.\n");
13525 return TEST_SKIPPED;
13528 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13531 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13534 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13536 gbl_driver_id = rte_cryptodev_driver_id_get(
13537 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13539 if (gbl_driver_id == -1) {
13540 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
13541 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
13542 "in config file to run this testsuite.\n");
13543 return TEST_SKIPPED;
13546 if (rte_cryptodev_driver_id_get(
13547 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13548 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
13549 " enabled in config file to run this testsuite.\n");
13550 return TEST_SKIPPED;
13552 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13555 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13560 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13562 gbl_driver_id = rte_cryptodev_driver_id_get(
13563 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13565 if (gbl_driver_id == -1) {
13566 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
13567 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
13568 "in config file to run this testsuite.\n");
13569 return TEST_SKIPPED;
13572 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
13576 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13578 gbl_driver_id = rte_cryptodev_driver_id_get(
13579 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13581 if (gbl_driver_id == -1) {
13582 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
13583 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
13584 "in config file to run this testsuite.\n");
13585 return TEST_SKIPPED;
13588 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
13592 test_cryptodev_ccp(void)
13594 gbl_driver_id = rte_cryptodev_driver_id_get(
13595 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13597 if (gbl_driver_id == -1) {
13598 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
13599 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
13600 "in config file to run this testsuite.\n");
13601 return TEST_FAILED;
13604 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13608 test_cryptodev_octeontx(void)
13610 gbl_driver_id = rte_cryptodev_driver_id_get(
13611 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13612 if (gbl_driver_id == -1) {
13613 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
13614 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
13615 "enabled in config file to run this "
13617 return TEST_FAILED;
13619 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
13623 test_cryptodev_octeontx2(void)
13625 gbl_driver_id = rte_cryptodev_driver_id_get(
13626 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13627 if (gbl_driver_id == -1) {
13628 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
13629 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
13630 "enabled in config file to run this "
13632 return TEST_FAILED;
13634 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
13638 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13640 gbl_driver_id = rte_cryptodev_driver_id_get(
13641 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13643 if (gbl_driver_id == -1) {
13644 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13645 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13646 "in config file to run this testsuite.\n");
13647 return TEST_FAILED;
13650 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13654 test_cryptodev_nitrox(void)
13656 gbl_driver_id = rte_cryptodev_driver_id_get(
13657 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13659 if (gbl_driver_id == -1) {
13660 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13661 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13662 "in config file to run this testsuite.\n");
13663 return TEST_FAILED;
13666 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13669 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13670 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13671 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13672 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13673 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13674 test_cryptodev_cpu_aesni_gcm);
13675 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13676 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13677 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13678 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13679 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13680 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13681 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13682 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13683 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13684 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13685 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13686 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13687 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13688 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);