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>
14 #include <rte_ether.h>
16 #include <rte_crypto.h>
17 #include <rte_cryptodev.h>
18 #include <rte_cryptodev_pmd.h>
19 #include <rte_string_fns.h>
21 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
22 #include <rte_cryptodev_scheduler.h>
23 #include <rte_cryptodev_scheduler_operations.h>
26 #include <rte_lcore.h>
29 #include "test_cryptodev.h"
31 #include "test_cryptodev_blockcipher.h"
32 #include "test_cryptodev_aes_test_vectors.h"
33 #include "test_cryptodev_des_test_vectors.h"
34 #include "test_cryptodev_hash_test_vectors.h"
35 #include "test_cryptodev_kasumi_test_vectors.h"
36 #include "test_cryptodev_kasumi_hash_test_vectors.h"
37 #include "test_cryptodev_snow3g_test_vectors.h"
38 #include "test_cryptodev_snow3g_hash_test_vectors.h"
39 #include "test_cryptodev_zuc_test_vectors.h"
40 #include "test_cryptodev_aead_test_vectors.h"
41 #include "test_cryptodev_hmac_test_vectors.h"
42 #include "test_cryptodev_mixed_test_vectors.h"
43 #ifdef RTE_LIBRTE_SECURITY
44 #include "test_cryptodev_security_pdcp_test_vectors.h"
45 #include "test_cryptodev_security_pdcp_test_func.h"
46 #include "test_cryptodev_security_docsis_test_vectors.h"
49 #define VDEV_ARGS_SIZE 100
50 #define MAX_NB_SESSIONS 4
53 #define OUT_OF_PLACE 1
55 static int gbl_driver_id;
57 static enum rte_security_session_action_type gbl_action_type =
58 RTE_SECURITY_ACTION_TYPE_NONE;
60 struct crypto_testsuite_params {
61 struct rte_mempool *mbuf_pool;
62 struct rte_mempool *large_mbuf_pool;
63 struct rte_mempool *op_mpool;
64 struct rte_mempool *session_mpool;
65 struct rte_mempool *session_priv_mpool;
66 struct rte_cryptodev_config conf;
67 struct rte_cryptodev_qp_conf qp_conf;
69 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
70 uint8_t valid_dev_count;
73 struct crypto_unittest_params {
74 struct rte_crypto_sym_xform cipher_xform;
75 struct rte_crypto_sym_xform auth_xform;
76 struct rte_crypto_sym_xform aead_xform;
77 #ifdef RTE_LIBRTE_SECURITY
78 struct rte_security_docsis_xform docsis_xform;
82 struct rte_cryptodev_sym_session *sess;
83 #ifdef RTE_LIBRTE_SECURITY
84 struct rte_security_session *sec_session;
87 #ifdef RTE_LIBRTE_SECURITY
88 enum rte_security_session_action_type type;
90 struct rte_crypto_op *op;
92 struct rte_mbuf *obuf, *ibuf;
97 #define ALIGN_POW2_ROUNDUP(num, align) \
98 (((num) + (align) - 1) & ~((align) - 1))
101 * Forward declarations.
104 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
105 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
109 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
110 struct crypto_unittest_params *ut_params,
111 struct crypto_testsuite_params *ts_param,
112 const uint8_t *cipher,
113 const uint8_t *digest,
116 static struct rte_mbuf *
117 setup_test_string(struct rte_mempool *mpool,
118 const char *string, size_t len, uint8_t blocksize)
120 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
121 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
123 memset(m->buf_addr, 0, m->buf_len);
125 char *dst = rte_pktmbuf_append(m, t_len);
132 rte_memcpy(dst, string, t_len);
134 memset(dst, 0, t_len);
140 /* Get number of bytes in X bits (rounding up) */
142 ceil_byte_length(uint32_t num_bits)
145 return ((num_bits >> 3) + 1);
147 return (num_bits >> 3);
151 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
155 struct rte_crypto_sym_op *sop;
156 union rte_crypto_sym_ofs ofs;
157 struct rte_crypto_sgl sgl;
158 struct rte_crypto_sym_vec symvec;
159 struct rte_crypto_vec vec[UINT8_MAX];
163 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
164 sop->aead.data.length, vec, RTE_DIM(vec));
166 if (n < 0 || n != sop->m_src->nb_segs) {
167 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
174 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
176 symvec.aad = (void **)&sop->aead.aad.data;
177 symvec.digest = (void **)&sop->aead.digest.data;
183 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
187 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
189 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
193 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
197 struct rte_crypto_sym_op *sop;
198 union rte_crypto_sym_ofs ofs;
199 struct rte_crypto_sgl sgl;
200 struct rte_crypto_sym_vec symvec;
201 struct rte_crypto_vec vec[UINT8_MAX];
205 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
206 sop->auth.data.length, vec, RTE_DIM(vec));
208 if (n < 0 || n != sop->m_src->nb_segs) {
209 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
216 iv = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
218 symvec.aad = (void **)&sop->aead.aad.data;
219 symvec.digest = (void **)&sop->auth.digest.data;
224 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
225 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
226 (sop->cipher.data.offset + sop->cipher.data.length);
228 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
232 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
234 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
237 static struct rte_crypto_op *
238 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
241 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
243 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
244 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
250 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
253 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
254 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
261 static struct crypto_testsuite_params testsuite_params = { NULL };
262 static struct crypto_unittest_params unittest_params;
265 testsuite_setup(void)
267 struct crypto_testsuite_params *ts_params = &testsuite_params;
268 struct rte_cryptodev_info info;
269 uint32_t i = 0, nb_devs, dev_id;
273 memset(ts_params, 0, sizeof(*ts_params));
275 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
276 if (ts_params->mbuf_pool == NULL) {
277 /* Not already created so create */
278 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
280 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
282 if (ts_params->mbuf_pool == NULL) {
283 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
288 ts_params->large_mbuf_pool = rte_mempool_lookup(
289 "CRYPTO_LARGE_MBUFPOOL");
290 if (ts_params->large_mbuf_pool == NULL) {
291 /* Not already created so create */
292 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
293 "CRYPTO_LARGE_MBUFPOOL",
296 if (ts_params->large_mbuf_pool == NULL) {
298 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
303 ts_params->op_mpool = rte_crypto_op_pool_create(
304 "MBUF_CRYPTO_SYM_OP_POOL",
305 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
306 NUM_MBUFS, MBUF_CACHE_SIZE,
308 sizeof(struct rte_crypto_sym_xform) +
311 if (ts_params->op_mpool == NULL) {
312 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
316 /* Create an AESNI MB device if required */
317 if (gbl_driver_id == rte_cryptodev_driver_id_get(
318 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
319 nb_devs = rte_cryptodev_device_count_by_driver(
320 rte_cryptodev_driver_id_get(
321 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
324 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
326 TEST_ASSERT(ret == 0,
327 "Failed to create instance of"
329 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
333 /* Create an AESNI GCM device if required */
334 if (gbl_driver_id == rte_cryptodev_driver_id_get(
335 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
336 nb_devs = rte_cryptodev_device_count_by_driver(
337 rte_cryptodev_driver_id_get(
338 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
340 TEST_ASSERT_SUCCESS(rte_vdev_init(
341 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
342 "Failed to create instance of"
344 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
348 /* Create a SNOW 3G device if required */
349 if (gbl_driver_id == rte_cryptodev_driver_id_get(
350 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
351 nb_devs = rte_cryptodev_device_count_by_driver(
352 rte_cryptodev_driver_id_get(
353 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
355 TEST_ASSERT_SUCCESS(rte_vdev_init(
356 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
357 "Failed to create instance of"
359 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
363 /* Create a KASUMI device if required */
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
366 nb_devs = rte_cryptodev_device_count_by_driver(
367 rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
370 TEST_ASSERT_SUCCESS(rte_vdev_init(
371 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
372 "Failed to create instance of"
374 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
378 /* Create a ZUC device if required */
379 if (gbl_driver_id == rte_cryptodev_driver_id_get(
380 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
381 nb_devs = rte_cryptodev_device_count_by_driver(
382 rte_cryptodev_driver_id_get(
383 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
385 TEST_ASSERT_SUCCESS(rte_vdev_init(
386 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
387 "Failed to create instance of"
389 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
393 /* Create a NULL device if required */
394 if (gbl_driver_id == rte_cryptodev_driver_id_get(
395 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
396 nb_devs = rte_cryptodev_device_count_by_driver(
397 rte_cryptodev_driver_id_get(
398 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
401 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
403 TEST_ASSERT(ret == 0,
404 "Failed to create instance of"
406 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
410 /* Create an OPENSSL device if required */
411 if (gbl_driver_id == rte_cryptodev_driver_id_get(
412 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
413 nb_devs = rte_cryptodev_device_count_by_driver(
414 rte_cryptodev_driver_id_get(
415 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
418 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
421 TEST_ASSERT(ret == 0, "Failed to create "
422 "instance of pmd : %s",
423 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
427 /* Create a ARMv8 device if required */
428 if (gbl_driver_id == rte_cryptodev_driver_id_get(
429 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
430 nb_devs = rte_cryptodev_device_count_by_driver(
431 rte_cryptodev_driver_id_get(
432 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
435 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
438 TEST_ASSERT(ret == 0, "Failed to create "
439 "instance of pmd : %s",
440 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
444 /* Create a MVSAM device if required */
445 if (gbl_driver_id == rte_cryptodev_driver_id_get(
446 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
447 nb_devs = rte_cryptodev_device_count_by_driver(
448 rte_cryptodev_driver_id_get(
449 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
452 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
455 TEST_ASSERT(ret == 0, "Failed to create "
456 "instance of pmd : %s",
457 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
461 /* Create an CCP device if required */
462 if (gbl_driver_id == rte_cryptodev_driver_id_get(
463 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
464 nb_devs = rte_cryptodev_device_count_by_driver(
465 rte_cryptodev_driver_id_get(
466 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
469 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
472 TEST_ASSERT(ret == 0, "Failed to create "
473 "instance of pmd : %s",
474 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
478 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
479 char vdev_args[VDEV_ARGS_SIZE] = {""};
480 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
481 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
482 uint16_t worker_core_count = 0;
483 uint16_t socket_id = 0;
485 if (gbl_driver_id == rte_cryptodev_driver_id_get(
486 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
488 /* Identify the Worker Cores
489 * Use 2 worker cores for the device args
491 RTE_LCORE_FOREACH_SLAVE(i) {
492 if (worker_core_count > 1)
494 snprintf(vdev_args, sizeof(vdev_args),
495 "%s%d", temp_str, i);
496 strcpy(temp_str, vdev_args);
497 strlcat(temp_str, ";", sizeof(temp_str));
499 socket_id = rte_lcore_to_socket_id(i);
501 if (worker_core_count != 2) {
503 "Cryptodev scheduler test require at least "
504 "two worker cores to run. "
505 "Please use the correct coremask.\n");
508 strcpy(temp_str, vdev_args);
509 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
510 temp_str, socket_id);
511 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
512 nb_devs = rte_cryptodev_device_count_by_driver(
513 rte_cryptodev_driver_id_get(
514 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
517 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
519 TEST_ASSERT(ret == 0,
520 "Failed to create instance %u of"
522 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
525 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
527 nb_devs = rte_cryptodev_count();
529 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
533 /* Create list of valid crypto devs */
534 for (i = 0; i < nb_devs; i++) {
535 rte_cryptodev_info_get(i, &info);
536 if (info.driver_id == gbl_driver_id)
537 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
540 if (ts_params->valid_dev_count < 1)
543 /* Set up all the qps on the first of the valid devices found */
545 dev_id = ts_params->valid_devs[0];
547 rte_cryptodev_info_get(dev_id, &info);
549 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
550 ts_params->conf.socket_id = SOCKET_ID_ANY;
551 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
553 unsigned int session_size =
554 rte_cryptodev_sym_get_private_session_size(dev_id);
557 * Create mempool with maximum number of sessions * 2,
558 * to include the session headers
560 if (info.sym.max_nb_sessions != 0 &&
561 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
562 RTE_LOG(ERR, USER1, "Device does not support "
563 "at least %u sessions\n",
568 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
569 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
571 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
572 "session mempool allocation failed");
574 ts_params->session_priv_mpool = rte_mempool_create(
578 0, 0, NULL, NULL, NULL,
581 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
582 "session mempool allocation failed");
586 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
588 "Failed to configure cryptodev %u with %u qps",
589 dev_id, ts_params->conf.nb_queue_pairs);
591 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
592 ts_params->qp_conf.mp_session = ts_params->session_mpool;
593 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
595 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
596 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
597 dev_id, qp_id, &ts_params->qp_conf,
598 rte_cryptodev_socket_id(dev_id)),
599 "Failed to setup queue pair %u on cryptodev %u",
607 testsuite_teardown(void)
609 struct crypto_testsuite_params *ts_params = &testsuite_params;
611 if (ts_params->mbuf_pool != NULL) {
612 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
613 rte_mempool_avail_count(ts_params->mbuf_pool));
616 if (ts_params->op_mpool != NULL) {
617 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
618 rte_mempool_avail_count(ts_params->op_mpool));
621 /* Free session mempools */
622 if (ts_params->session_priv_mpool != NULL) {
623 rte_mempool_free(ts_params->session_priv_mpool);
624 ts_params->session_priv_mpool = NULL;
627 if (ts_params->session_mpool != NULL) {
628 rte_mempool_free(ts_params->session_mpool);
629 ts_params->session_mpool = NULL;
634 dev_configure_and_start(uint64_t ff_disable)
636 struct crypto_testsuite_params *ts_params = &testsuite_params;
637 struct crypto_unittest_params *ut_params = &unittest_params;
641 /* Clear unit test parameters before running test */
642 memset(ut_params, 0, sizeof(*ut_params));
644 /* Reconfigure device to default parameters */
645 ts_params->conf.socket_id = SOCKET_ID_ANY;
646 ts_params->conf.ff_disable = ff_disable;
647 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
648 ts_params->qp_conf.mp_session = ts_params->session_mpool;
649 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
653 "Failed to configure cryptodev %u",
654 ts_params->valid_devs[0]);
656 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
657 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
658 ts_params->valid_devs[0], qp_id,
660 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
661 "Failed to setup queue pair %u on cryptodev %u",
662 qp_id, ts_params->valid_devs[0]);
666 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
668 /* Start the device */
669 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
670 "Failed to start cryptodev %u",
671 ts_params->valid_devs[0]);
679 /* Configure and start the device with security feature disabled */
680 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
684 ut_setup_security(void)
686 /* Configure and start the device with no features disabled */
687 return dev_configure_and_start(0);
693 struct crypto_testsuite_params *ts_params = &testsuite_params;
694 struct crypto_unittest_params *ut_params = &unittest_params;
695 struct rte_cryptodev_stats stats;
697 /* free crypto session structure */
698 #ifdef RTE_LIBRTE_SECURITY
699 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
700 if (ut_params->sec_session) {
701 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
702 (ts_params->valid_devs[0]),
703 ut_params->sec_session);
704 ut_params->sec_session = NULL;
709 if (ut_params->sess) {
710 rte_cryptodev_sym_session_clear(
711 ts_params->valid_devs[0],
713 rte_cryptodev_sym_session_free(ut_params->sess);
714 ut_params->sess = NULL;
718 /* free crypto operation structure */
720 rte_crypto_op_free(ut_params->op);
723 * free mbuf - both obuf and ibuf are usually the same,
724 * so check if they point at the same address is necessary,
725 * to avoid freeing the mbuf twice.
727 if (ut_params->obuf) {
728 rte_pktmbuf_free(ut_params->obuf);
729 if (ut_params->ibuf == ut_params->obuf)
733 if (ut_params->ibuf) {
734 rte_pktmbuf_free(ut_params->ibuf);
738 if (ts_params->mbuf_pool != NULL)
739 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
740 rte_mempool_avail_count(ts_params->mbuf_pool));
742 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
744 /* Stop the device */
745 rte_cryptodev_stop(ts_params->valid_devs[0]);
749 test_device_configure_invalid_dev_id(void)
751 struct crypto_testsuite_params *ts_params = &testsuite_params;
752 uint16_t dev_id, num_devs = 0;
754 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
755 "Need at least %d devices for test", 1);
757 /* valid dev_id values */
758 dev_id = ts_params->valid_devs[0];
760 /* Stop the device in case it's started so it can be configured */
761 rte_cryptodev_stop(dev_id);
763 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
764 "Failed test for rte_cryptodev_configure: "
765 "invalid dev_num %u", dev_id);
767 /* invalid dev_id values */
770 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
771 "Failed test for rte_cryptodev_configure: "
772 "invalid dev_num %u", dev_id);
776 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
777 "Failed test for rte_cryptodev_configure:"
778 "invalid dev_num %u", dev_id);
784 test_device_configure_invalid_queue_pair_ids(void)
786 struct crypto_testsuite_params *ts_params = &testsuite_params;
787 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
789 /* Stop the device in case it's started so it can be configured */
790 rte_cryptodev_stop(ts_params->valid_devs[0]);
792 /* valid - max value queue pairs */
793 ts_params->conf.nb_queue_pairs = orig_nb_qps;
795 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
797 "Failed to configure cryptodev: dev_id %u, qp_id %u",
798 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
800 /* valid - one queue pairs */
801 ts_params->conf.nb_queue_pairs = 1;
803 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
805 "Failed to configure cryptodev: dev_id %u, qp_id %u",
806 ts_params->valid_devs[0],
807 ts_params->conf.nb_queue_pairs);
810 /* invalid - zero queue pairs */
811 ts_params->conf.nb_queue_pairs = 0;
813 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
815 "Failed test for rte_cryptodev_configure, dev_id %u,"
817 ts_params->valid_devs[0],
818 ts_params->conf.nb_queue_pairs);
821 /* invalid - max value supported by field queue pairs */
822 ts_params->conf.nb_queue_pairs = UINT16_MAX;
824 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
826 "Failed test for rte_cryptodev_configure, dev_id %u,"
828 ts_params->valid_devs[0],
829 ts_params->conf.nb_queue_pairs);
832 /* invalid - max value + 1 queue pairs */
833 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
835 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
837 "Failed test for rte_cryptodev_configure, dev_id %u,"
839 ts_params->valid_devs[0],
840 ts_params->conf.nb_queue_pairs);
842 /* revert to original testsuite value */
843 ts_params->conf.nb_queue_pairs = orig_nb_qps;
849 test_queue_pair_descriptor_setup(void)
851 struct crypto_testsuite_params *ts_params = &testsuite_params;
852 struct rte_cryptodev_qp_conf qp_conf = {
853 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
857 /* Stop the device in case it's started so it can be configured */
858 rte_cryptodev_stop(ts_params->valid_devs[0]);
860 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
862 "Failed to configure cryptodev %u",
863 ts_params->valid_devs[0]);
866 * Test various ring sizes on this device. memzones can't be
867 * freed so are re-used if ring is released and re-created.
869 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
870 qp_conf.mp_session = ts_params->session_mpool;
871 qp_conf.mp_session_private = ts_params->session_priv_mpool;
873 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
874 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
875 ts_params->valid_devs[0], qp_id, &qp_conf,
876 rte_cryptodev_socket_id(
877 ts_params->valid_devs[0])),
879 "rte_cryptodev_queue_pair_setup: num_inflights "
880 "%u on qp %u on cryptodev %u",
881 qp_conf.nb_descriptors, qp_id,
882 ts_params->valid_devs[0]);
885 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
887 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
888 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
889 ts_params->valid_devs[0], qp_id, &qp_conf,
890 rte_cryptodev_socket_id(
891 ts_params->valid_devs[0])),
893 " rte_cryptodev_queue_pair_setup: num_inflights"
894 " %u on qp %u on cryptodev %u",
895 qp_conf.nb_descriptors, qp_id,
896 ts_params->valid_devs[0]);
899 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
901 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
902 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
903 ts_params->valid_devs[0], qp_id, &qp_conf,
904 rte_cryptodev_socket_id(
905 ts_params->valid_devs[0])),
907 "rte_cryptodev_queue_pair_setup: num_inflights"
908 " %u on qp %u on cryptodev %u",
909 qp_conf.nb_descriptors, qp_id,
910 ts_params->valid_devs[0]);
913 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
915 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
916 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
917 ts_params->valid_devs[0], qp_id, &qp_conf,
918 rte_cryptodev_socket_id(
919 ts_params->valid_devs[0])),
921 " rte_cryptodev_queue_pair_setup:"
922 "num_inflights %u on qp %u on cryptodev %u",
923 qp_conf.nb_descriptors, qp_id,
924 ts_params->valid_devs[0]);
927 /* test invalid queue pair id */
928 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
930 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
932 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
933 ts_params->valid_devs[0],
935 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
936 "Failed test for rte_cryptodev_queue_pair_setup:"
937 "invalid qp %u on cryptodev %u",
938 qp_id, ts_params->valid_devs[0]);
940 qp_id = 0xffff; /*invalid*/
942 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
943 ts_params->valid_devs[0],
945 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
946 "Failed test for rte_cryptodev_queue_pair_setup:"
947 "invalid qp %u on cryptodev %u",
948 qp_id, ts_params->valid_devs[0]);
953 /* ***** Plaintext data for tests ***** */
955 const char catch_22_quote_1[] =
956 "There was only one catch and that was Catch-22, which "
957 "specified that a concern for one's safety in the face of "
958 "dangers that were real and immediate was the process of a "
959 "rational mind. Orr was crazy and could be grounded. All he "
960 "had to do was ask; and as soon as he did, he would no longer "
961 "be crazy and would have to fly more missions. Orr would be "
962 "crazy to fly more missions and sane if he didn't, but if he "
963 "was sane he had to fly them. If he flew them he was crazy "
964 "and didn't have to; but if he didn't want to he was sane and "
965 "had to. Yossarian was moved very deeply by the absolute "
966 "simplicity of this clause of Catch-22 and let out a "
967 "respectful whistle. \"That's some catch, that Catch-22\", he "
968 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
970 const char catch_22_quote[] =
971 "What a lousy earth! He wondered how many people were "
972 "destitute that same night even in his own prosperous country, "
973 "how many homes were shanties, how many husbands were drunk "
974 "and wives socked, and how many children were bullied, abused, "
975 "or abandoned. How many families hungered for food they could "
976 "not afford to buy? How many hearts were broken? How many "
977 "suicides would take place that same night, how many people "
978 "would go insane? How many cockroaches and landlords would "
979 "triumph? How many winners were losers, successes failures, "
980 "and rich men poor men? How many wise guys were stupid? How "
981 "many happy endings were unhappy endings? How many honest men "
982 "were liars, brave men cowards, loyal men traitors, how many "
983 "sainted men were corrupt, how many people in positions of "
984 "trust had sold their souls to bodyguards, how many had never "
985 "had souls? How many straight-and-narrow paths were crooked "
986 "paths? How many best families were worst families and how "
987 "many good people were bad people? When you added them all up "
988 "and then subtracted, you might be left with only the children, "
989 "and perhaps with Albert Einstein and an old violinist or "
990 "sculptor somewhere.";
992 #define QUOTE_480_BYTES (480)
993 #define QUOTE_512_BYTES (512)
994 #define QUOTE_768_BYTES (768)
995 #define QUOTE_1024_BYTES (1024)
999 /* ***** SHA1 Hash Tests ***** */
1001 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1003 static uint8_t hmac_sha1_key[] = {
1004 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1005 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1006 0xDE, 0xF4, 0xDE, 0xAD };
1008 /* ***** SHA224 Hash Tests ***** */
1010 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1013 /* ***** AES-CBC Cipher Tests ***** */
1015 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1016 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1018 static uint8_t aes_cbc_key[] = {
1019 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1020 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1022 static uint8_t aes_cbc_iv[] = {
1023 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1024 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1027 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1029 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1030 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1031 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1032 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1033 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1034 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1035 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1036 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1037 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1038 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1039 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1040 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1041 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1042 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1043 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1044 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1045 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1046 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1047 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1048 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1049 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1050 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1051 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1052 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1053 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1054 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1055 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1056 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1057 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1058 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1059 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1060 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1061 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1062 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1063 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1064 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1065 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1066 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1067 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1068 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1069 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1070 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1071 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1072 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1073 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1074 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1075 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1076 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1077 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1078 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1079 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1080 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1081 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1082 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1083 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1084 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1085 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1086 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1087 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1088 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1089 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1090 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1091 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1092 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1093 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1096 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1097 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1098 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1099 0x18, 0x8c, 0x1d, 0x32
1103 /* Multisession Vector context Test */
1104 /*Begin Session 0 */
1105 static uint8_t ms_aes_cbc_key0[] = {
1106 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1107 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1110 static uint8_t ms_aes_cbc_iv0[] = {
1111 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1112 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1115 static const uint8_t ms_aes_cbc_cipher0[] = {
1116 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1117 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1118 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1119 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1120 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1121 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1122 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1123 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1124 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1125 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1126 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1127 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1128 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1129 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1130 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1131 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1132 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1133 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1134 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1135 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1136 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1137 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1138 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1139 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1140 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1141 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1142 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1143 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1144 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1145 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1146 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1147 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1148 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1149 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1150 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1151 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1152 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1153 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1154 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1155 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1156 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1157 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1158 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1159 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1160 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1161 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1162 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1163 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1164 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1165 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1166 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1167 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1168 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1169 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1170 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1171 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1172 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1173 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1174 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1175 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1176 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1177 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1178 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1179 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1183 static uint8_t ms_hmac_key0[] = {
1184 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1185 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1186 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1187 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1188 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1189 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1190 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1191 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1194 static const uint8_t ms_hmac_digest0[] = {
1195 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1196 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1197 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1198 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1199 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1200 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1201 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1202 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1206 /* Begin session 1 */
1208 static uint8_t ms_aes_cbc_key1[] = {
1209 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1210 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1213 static uint8_t ms_aes_cbc_iv1[] = {
1214 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1215 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1218 static const uint8_t ms_aes_cbc_cipher1[] = {
1219 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1220 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1221 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1222 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1223 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1224 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1225 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1226 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1227 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1228 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1229 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1230 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1231 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1232 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1233 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1234 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1235 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1236 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1237 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1238 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1239 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1240 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1241 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1242 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1243 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1244 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1245 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1246 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1247 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1248 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1249 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1250 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1251 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1252 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1253 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1254 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1255 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1256 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1257 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1258 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1259 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1260 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1261 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1262 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1263 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1264 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1265 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1266 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1267 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1268 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1269 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1270 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1271 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1272 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1273 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1274 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1275 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1276 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1277 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1278 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1279 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1280 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1281 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1282 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1286 static uint8_t ms_hmac_key1[] = {
1287 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1288 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1289 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1290 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1291 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1292 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1293 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1294 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1297 static const uint8_t ms_hmac_digest1[] = {
1298 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1299 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1300 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1301 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1302 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1303 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1304 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1305 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1308 /* Begin Session 2 */
1309 static uint8_t ms_aes_cbc_key2[] = {
1310 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1311 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1314 static uint8_t ms_aes_cbc_iv2[] = {
1315 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1316 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1319 static const uint8_t ms_aes_cbc_cipher2[] = {
1320 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1321 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1322 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1323 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1324 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1325 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1326 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1327 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1328 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1329 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1330 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1331 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1332 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1333 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1334 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1335 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1336 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1337 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1338 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1339 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1340 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1341 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1342 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1343 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1344 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1345 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1346 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1347 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1348 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1349 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1350 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1351 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1352 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1353 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1354 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1355 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1356 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1357 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1358 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1359 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1360 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1361 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1362 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1363 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1364 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1365 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1366 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1367 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1368 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1369 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1370 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1371 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1372 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1373 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1374 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1375 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1376 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1377 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1378 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1379 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1380 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1381 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1382 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1383 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1386 static uint8_t ms_hmac_key2[] = {
1387 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1388 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1389 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1390 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1391 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1392 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1393 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1394 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1397 static const uint8_t ms_hmac_digest2[] = {
1398 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1399 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1400 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1401 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1402 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1403 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1404 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1405 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1412 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1414 struct crypto_testsuite_params *ts_params = &testsuite_params;
1415 struct crypto_unittest_params *ut_params = &unittest_params;
1417 /* Verify the capabilities */
1418 struct rte_cryptodev_sym_capability_idx cap_idx;
1419 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1420 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1421 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1424 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1425 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1426 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1430 /* Generate test mbuf data and space for digest */
1431 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1432 catch_22_quote, QUOTE_512_BYTES, 0);
1434 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1435 DIGEST_BYTE_LENGTH_SHA1);
1436 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1438 /* Setup Cipher Parameters */
1439 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1440 ut_params->cipher_xform.next = &ut_params->auth_xform;
1442 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1443 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1444 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1445 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1446 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1447 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1449 /* Setup HMAC Parameters */
1450 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1452 ut_params->auth_xform.next = NULL;
1454 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1455 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1456 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1457 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1458 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1460 ut_params->sess = rte_cryptodev_sym_session_create(
1461 ts_params->session_mpool);
1463 /* Create crypto session*/
1464 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1465 ut_params->sess, &ut_params->cipher_xform,
1466 ts_params->session_priv_mpool);
1467 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1469 /* Generate crypto op data structure */
1470 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1471 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1472 TEST_ASSERT_NOT_NULL(ut_params->op,
1473 "Failed to allocate symmetric crypto operation struct");
1475 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1477 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1479 /* set crypto operation source mbuf */
1480 sym_op->m_src = ut_params->ibuf;
1482 /* Set crypto operation authentication parameters */
1483 sym_op->auth.digest.data = ut_params->digest;
1484 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1485 ut_params->ibuf, QUOTE_512_BYTES);
1487 sym_op->auth.data.offset = 0;
1488 sym_op->auth.data.length = QUOTE_512_BYTES;
1490 /* Copy IV at the end of the crypto operation */
1491 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1492 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1494 /* Set crypto operation cipher parameters */
1495 sym_op->cipher.data.offset = 0;
1496 sym_op->cipher.data.length = QUOTE_512_BYTES;
1498 /* Process crypto operation */
1499 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1500 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1503 TEST_ASSERT_NOT_NULL(
1504 process_crypto_request(ts_params->valid_devs[0],
1506 "failed to process sym crypto op");
1508 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1509 "crypto op processing failed");
1512 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1515 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1516 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1518 "ciphertext data not as expected");
1520 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1522 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1523 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1524 gbl_driver_id == rte_cryptodev_driver_id_get(
1525 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1526 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1527 DIGEST_BYTE_LENGTH_SHA1,
1528 "Generated digest data not as expected");
1530 return TEST_SUCCESS;
1533 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1535 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1537 static uint8_t hmac_sha512_key[] = {
1538 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1539 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1540 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1541 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1542 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1543 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1544 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1545 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1547 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1548 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1549 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1550 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1551 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1552 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1553 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1554 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1555 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1560 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1561 struct crypto_unittest_params *ut_params,
1562 uint8_t *cipher_key,
1566 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1567 struct crypto_unittest_params *ut_params,
1568 struct crypto_testsuite_params *ts_params,
1569 const uint8_t *cipher,
1570 const uint8_t *digest,
1575 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1576 struct crypto_unittest_params *ut_params,
1577 uint8_t *cipher_key,
1581 /* Setup Cipher Parameters */
1582 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1583 ut_params->cipher_xform.next = NULL;
1585 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1586 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1587 ut_params->cipher_xform.cipher.key.data = cipher_key;
1588 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1589 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1590 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1592 /* Setup HMAC Parameters */
1593 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1594 ut_params->auth_xform.next = &ut_params->cipher_xform;
1596 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1597 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1598 ut_params->auth_xform.auth.key.data = hmac_key;
1599 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1600 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1602 return TEST_SUCCESS;
1607 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1608 struct crypto_unittest_params *ut_params,
1609 struct crypto_testsuite_params *ts_params,
1610 const uint8_t *cipher,
1611 const uint8_t *digest,
1614 /* Generate test mbuf data and digest */
1615 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1618 QUOTE_512_BYTES, 0);
1620 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1621 DIGEST_BYTE_LENGTH_SHA512);
1622 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1624 rte_memcpy(ut_params->digest,
1626 DIGEST_BYTE_LENGTH_SHA512);
1628 /* Generate Crypto op data structure */
1629 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1630 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1631 TEST_ASSERT_NOT_NULL(ut_params->op,
1632 "Failed to allocate symmetric crypto operation struct");
1634 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1636 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1638 /* set crypto operation source mbuf */
1639 sym_op->m_src = ut_params->ibuf;
1641 sym_op->auth.digest.data = ut_params->digest;
1642 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1643 ut_params->ibuf, QUOTE_512_BYTES);
1645 sym_op->auth.data.offset = 0;
1646 sym_op->auth.data.length = QUOTE_512_BYTES;
1648 /* Copy IV at the end of the crypto operation */
1649 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1650 iv, CIPHER_IV_LENGTH_AES_CBC);
1652 sym_op->cipher.data.offset = 0;
1653 sym_op->cipher.data.length = QUOTE_512_BYTES;
1655 /* Process crypto operation */
1656 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1657 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1660 TEST_ASSERT_NOT_NULL(
1661 process_crypto_request(ts_params->valid_devs[0],
1663 "failed to process sym crypto op");
1665 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1666 "crypto op processing failed");
1668 ut_params->obuf = ut_params->op->sym->m_src;
1671 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1672 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1675 "Plaintext data not as expected");
1678 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1679 "Digest verification failed");
1681 return TEST_SUCCESS;
1685 test_blockcipher(enum blockcipher_test_type test_type)
1687 struct crypto_testsuite_params *ts_params = &testsuite_params;
1690 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1691 ts_params->op_mpool,
1692 ts_params->session_mpool, ts_params->session_priv_mpool,
1693 ts_params->valid_devs[0],
1696 if (status == -ENOTSUP)
1699 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1701 return TEST_SUCCESS;
1705 test_AES_cipheronly_all(void)
1707 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1711 test_AES_docsis_all(void)
1713 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1717 test_DES_docsis_all(void)
1719 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1723 test_DES_cipheronly_all(void)
1725 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1729 test_authonly_all(void)
1731 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1735 test_AES_chain_all(void)
1737 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1741 test_3DES_chain_all(void)
1743 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1747 test_3DES_cipheronly_all(void)
1749 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1752 /* ***** SNOW 3G Tests ***** */
1754 create_wireless_algo_hash_session(uint8_t dev_id,
1755 const uint8_t *key, const uint8_t key_len,
1756 const uint8_t iv_len, const uint8_t auth_len,
1757 enum rte_crypto_auth_operation op,
1758 enum rte_crypto_auth_algorithm algo)
1760 uint8_t hash_key[key_len];
1763 struct crypto_testsuite_params *ts_params = &testsuite_params;
1764 struct crypto_unittest_params *ut_params = &unittest_params;
1766 memcpy(hash_key, key, key_len);
1768 debug_hexdump(stdout, "key:", key, key_len);
1770 /* Setup Authentication Parameters */
1771 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1772 ut_params->auth_xform.next = NULL;
1774 ut_params->auth_xform.auth.op = op;
1775 ut_params->auth_xform.auth.algo = algo;
1776 ut_params->auth_xform.auth.key.length = key_len;
1777 ut_params->auth_xform.auth.key.data = hash_key;
1778 ut_params->auth_xform.auth.digest_length = auth_len;
1779 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1780 ut_params->auth_xform.auth.iv.length = iv_len;
1781 ut_params->sess = rte_cryptodev_sym_session_create(
1782 ts_params->session_mpool);
1784 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1785 &ut_params->auth_xform,
1786 ts_params->session_priv_mpool);
1787 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1788 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1793 create_wireless_algo_cipher_session(uint8_t dev_id,
1794 enum rte_crypto_cipher_operation op,
1795 enum rte_crypto_cipher_algorithm algo,
1796 const uint8_t *key, const uint8_t key_len,
1799 uint8_t cipher_key[key_len];
1801 struct crypto_testsuite_params *ts_params = &testsuite_params;
1802 struct crypto_unittest_params *ut_params = &unittest_params;
1804 memcpy(cipher_key, key, key_len);
1806 /* Setup Cipher Parameters */
1807 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1808 ut_params->cipher_xform.next = NULL;
1810 ut_params->cipher_xform.cipher.algo = algo;
1811 ut_params->cipher_xform.cipher.op = op;
1812 ut_params->cipher_xform.cipher.key.data = cipher_key;
1813 ut_params->cipher_xform.cipher.key.length = key_len;
1814 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1815 ut_params->cipher_xform.cipher.iv.length = iv_len;
1817 debug_hexdump(stdout, "key:", key, key_len);
1819 /* Create Crypto session */
1820 ut_params->sess = rte_cryptodev_sym_session_create(
1821 ts_params->session_mpool);
1823 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1824 &ut_params->cipher_xform,
1825 ts_params->session_priv_mpool);
1826 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1827 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1832 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1833 unsigned int cipher_len,
1834 unsigned int cipher_offset)
1836 struct crypto_testsuite_params *ts_params = &testsuite_params;
1837 struct crypto_unittest_params *ut_params = &unittest_params;
1839 /* Generate Crypto op data structure */
1840 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1841 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1842 TEST_ASSERT_NOT_NULL(ut_params->op,
1843 "Failed to allocate pktmbuf offload");
1845 /* Set crypto operation data parameters */
1846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1848 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1850 /* set crypto operation source mbuf */
1851 sym_op->m_src = ut_params->ibuf;
1854 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1856 sym_op->cipher.data.length = cipher_len;
1857 sym_op->cipher.data.offset = cipher_offset;
1862 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1863 unsigned int cipher_len,
1864 unsigned int cipher_offset)
1866 struct crypto_testsuite_params *ts_params = &testsuite_params;
1867 struct crypto_unittest_params *ut_params = &unittest_params;
1869 /* Generate Crypto op data structure */
1870 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1871 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1872 TEST_ASSERT_NOT_NULL(ut_params->op,
1873 "Failed to allocate pktmbuf offload");
1875 /* Set crypto operation data parameters */
1876 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1878 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1880 /* set crypto operation source mbuf */
1881 sym_op->m_src = ut_params->ibuf;
1882 sym_op->m_dst = ut_params->obuf;
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_auth_session(uint8_t dev_id,
1894 enum rte_crypto_cipher_operation cipher_op,
1895 enum rte_crypto_auth_operation auth_op,
1896 enum rte_crypto_auth_algorithm auth_algo,
1897 enum rte_crypto_cipher_algorithm cipher_algo,
1898 const uint8_t *key, uint8_t key_len,
1899 uint8_t auth_iv_len, uint8_t auth_len,
1900 uint8_t cipher_iv_len)
1903 uint8_t cipher_auth_key[key_len];
1906 struct crypto_testsuite_params *ts_params = &testsuite_params;
1907 struct crypto_unittest_params *ut_params = &unittest_params;
1909 memcpy(cipher_auth_key, key, key_len);
1911 /* Setup Authentication Parameters */
1912 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1913 ut_params->auth_xform.next = NULL;
1915 ut_params->auth_xform.auth.op = auth_op;
1916 ut_params->auth_xform.auth.algo = auth_algo;
1917 ut_params->auth_xform.auth.key.length = key_len;
1918 /* Hash key = cipher key */
1919 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1920 ut_params->auth_xform.auth.digest_length = auth_len;
1921 /* Auth IV will be after cipher IV */
1922 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1923 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1925 /* Setup Cipher Parameters */
1926 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1927 ut_params->cipher_xform.next = &ut_params->auth_xform;
1929 ut_params->cipher_xform.cipher.algo = cipher_algo;
1930 ut_params->cipher_xform.cipher.op = cipher_op;
1931 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1932 ut_params->cipher_xform.cipher.key.length = key_len;
1933 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1934 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1936 debug_hexdump(stdout, "key:", key, key_len);
1938 /* Create Crypto session*/
1939 ut_params->sess = rte_cryptodev_sym_session_create(
1940 ts_params->session_mpool);
1941 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1943 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1944 &ut_params->cipher_xform,
1945 ts_params->session_priv_mpool);
1946 if (status == -ENOTSUP)
1949 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1954 create_wireless_cipher_auth_session(uint8_t dev_id,
1955 enum rte_crypto_cipher_operation cipher_op,
1956 enum rte_crypto_auth_operation auth_op,
1957 enum rte_crypto_auth_algorithm auth_algo,
1958 enum rte_crypto_cipher_algorithm cipher_algo,
1959 const struct wireless_test_data *tdata)
1961 const uint8_t key_len = tdata->key.len;
1962 uint8_t cipher_auth_key[key_len];
1965 struct crypto_testsuite_params *ts_params = &testsuite_params;
1966 struct crypto_unittest_params *ut_params = &unittest_params;
1967 const uint8_t *key = tdata->key.data;
1968 const uint8_t auth_len = tdata->digest.len;
1969 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1970 uint8_t auth_iv_len = tdata->auth_iv.len;
1972 memcpy(cipher_auth_key, key, key_len);
1974 /* Setup Authentication Parameters */
1975 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1976 ut_params->auth_xform.next = NULL;
1978 ut_params->auth_xform.auth.op = auth_op;
1979 ut_params->auth_xform.auth.algo = auth_algo;
1980 ut_params->auth_xform.auth.key.length = key_len;
1981 /* Hash key = cipher key */
1982 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1983 ut_params->auth_xform.auth.digest_length = auth_len;
1984 /* Auth IV will be after cipher IV */
1985 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1986 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1988 /* Setup Cipher Parameters */
1989 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1990 ut_params->cipher_xform.next = &ut_params->auth_xform;
1992 ut_params->cipher_xform.cipher.algo = cipher_algo;
1993 ut_params->cipher_xform.cipher.op = cipher_op;
1994 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1995 ut_params->cipher_xform.cipher.key.length = key_len;
1996 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1997 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2000 debug_hexdump(stdout, "key:", key, key_len);
2002 /* Create Crypto session*/
2003 ut_params->sess = rte_cryptodev_sym_session_create(
2004 ts_params->session_mpool);
2006 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2007 &ut_params->cipher_xform,
2008 ts_params->session_priv_mpool);
2009 if (status == -ENOTSUP)
2012 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2013 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2018 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2019 const struct wireless_test_data *tdata)
2021 return create_wireless_cipher_auth_session(dev_id,
2022 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2023 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2024 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2028 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2029 enum rte_crypto_cipher_operation cipher_op,
2030 enum rte_crypto_auth_operation auth_op,
2031 enum rte_crypto_auth_algorithm auth_algo,
2032 enum rte_crypto_cipher_algorithm cipher_algo,
2033 const uint8_t *key, const uint8_t key_len,
2034 uint8_t auth_iv_len, uint8_t auth_len,
2035 uint8_t cipher_iv_len)
2037 uint8_t auth_cipher_key[key_len];
2039 struct crypto_testsuite_params *ts_params = &testsuite_params;
2040 struct crypto_unittest_params *ut_params = &unittest_params;
2042 memcpy(auth_cipher_key, key, key_len);
2044 /* Setup Authentication Parameters */
2045 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2046 ut_params->auth_xform.auth.op = auth_op;
2047 ut_params->auth_xform.next = &ut_params->cipher_xform;
2048 ut_params->auth_xform.auth.algo = auth_algo;
2049 ut_params->auth_xform.auth.key.length = key_len;
2050 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2051 ut_params->auth_xform.auth.digest_length = auth_len;
2052 /* Auth IV will be after cipher IV */
2053 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2054 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2056 /* Setup Cipher Parameters */
2057 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2058 ut_params->cipher_xform.next = NULL;
2059 ut_params->cipher_xform.cipher.algo = cipher_algo;
2060 ut_params->cipher_xform.cipher.op = cipher_op;
2061 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2062 ut_params->cipher_xform.cipher.key.length = key_len;
2063 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2064 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2066 debug_hexdump(stdout, "key:", key, key_len);
2068 /* Create Crypto session*/
2069 ut_params->sess = rte_cryptodev_sym_session_create(
2070 ts_params->session_mpool);
2071 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2073 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2074 ut_params->auth_xform.next = NULL;
2075 ut_params->cipher_xform.next = &ut_params->auth_xform;
2076 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2077 &ut_params->cipher_xform,
2078 ts_params->session_priv_mpool);
2081 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2082 &ut_params->auth_xform,
2083 ts_params->session_priv_mpool);
2085 if (status == -ENOTSUP)
2088 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2094 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2095 unsigned int auth_tag_len,
2096 const uint8_t *iv, unsigned int iv_len,
2097 unsigned int data_pad_len,
2098 enum rte_crypto_auth_operation op,
2099 unsigned int auth_len, unsigned int auth_offset)
2101 struct crypto_testsuite_params *ts_params = &testsuite_params;
2103 struct crypto_unittest_params *ut_params = &unittest_params;
2105 /* Generate Crypto op data structure */
2106 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2107 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2108 TEST_ASSERT_NOT_NULL(ut_params->op,
2109 "Failed to allocate pktmbuf offload");
2111 /* Set crypto operation data parameters */
2112 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2114 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2116 /* set crypto operation source mbuf */
2117 sym_op->m_src = ut_params->ibuf;
2120 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2123 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2124 ut_params->ibuf, auth_tag_len);
2126 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2127 "no room to append auth tag");
2128 ut_params->digest = sym_op->auth.digest.data;
2129 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2130 ut_params->ibuf, data_pad_len);
2131 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2132 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2134 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2136 debug_hexdump(stdout, "digest:",
2137 sym_op->auth.digest.data,
2140 sym_op->auth.data.length = auth_len;
2141 sym_op->auth.data.offset = auth_offset;
2147 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2148 enum rte_crypto_auth_operation op)
2150 struct crypto_testsuite_params *ts_params = &testsuite_params;
2151 struct crypto_unittest_params *ut_params = &unittest_params;
2153 const uint8_t *auth_tag = tdata->digest.data;
2154 const unsigned int auth_tag_len = tdata->digest.len;
2155 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2156 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2158 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2159 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2160 const uint8_t *auth_iv = tdata->auth_iv.data;
2161 const uint8_t auth_iv_len = tdata->auth_iv.len;
2162 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2163 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2165 /* Generate Crypto op data structure */
2166 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2167 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2168 TEST_ASSERT_NOT_NULL(ut_params->op,
2169 "Failed to allocate pktmbuf offload");
2170 /* Set crypto operation data parameters */
2171 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2173 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2175 /* set crypto operation source mbuf */
2176 sym_op->m_src = ut_params->ibuf;
2179 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2180 ut_params->ibuf, auth_tag_len);
2182 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2183 "no room to append auth tag");
2184 ut_params->digest = sym_op->auth.digest.data;
2185 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2186 ut_params->ibuf, data_pad_len);
2187 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2188 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2190 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2192 debug_hexdump(stdout, "digest:",
2193 sym_op->auth.digest.data,
2196 /* Copy cipher and auth IVs at the end of the crypto operation */
2197 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2199 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2200 iv_ptr += cipher_iv_len;
2201 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2203 sym_op->cipher.data.length = cipher_len;
2204 sym_op->cipher.data.offset = 0;
2205 sym_op->auth.data.length = auth_len;
2206 sym_op->auth.data.offset = 0;
2212 create_zuc_cipher_hash_generate_operation(
2213 const struct wireless_test_data *tdata)
2215 return create_wireless_cipher_hash_operation(tdata,
2216 RTE_CRYPTO_AUTH_OP_GENERATE);
2220 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2221 const unsigned auth_tag_len,
2222 const uint8_t *auth_iv, uint8_t auth_iv_len,
2223 unsigned data_pad_len,
2224 enum rte_crypto_auth_operation op,
2225 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2226 const unsigned cipher_len, const unsigned cipher_offset,
2227 const unsigned auth_len, const unsigned auth_offset)
2229 struct crypto_testsuite_params *ts_params = &testsuite_params;
2230 struct crypto_unittest_params *ut_params = &unittest_params;
2232 enum rte_crypto_cipher_algorithm cipher_algo =
2233 ut_params->cipher_xform.cipher.algo;
2234 enum rte_crypto_auth_algorithm auth_algo =
2235 ut_params->auth_xform.auth.algo;
2237 /* Generate Crypto op data structure */
2238 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2239 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2240 TEST_ASSERT_NOT_NULL(ut_params->op,
2241 "Failed to allocate pktmbuf offload");
2242 /* Set crypto operation data parameters */
2243 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2245 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2247 /* set crypto operation source mbuf */
2248 sym_op->m_src = ut_params->ibuf;
2251 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2252 ut_params->ibuf, auth_tag_len);
2254 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2255 "no room to append auth tag");
2256 ut_params->digest = sym_op->auth.digest.data;
2258 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2259 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2260 ut_params->ibuf, data_pad_len);
2262 struct rte_mbuf *m = ut_params->ibuf;
2263 unsigned int offset = data_pad_len;
2265 while (offset > m->data_len && m->next != NULL) {
2266 offset -= m->data_len;
2269 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2273 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2274 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2276 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2278 debug_hexdump(stdout, "digest:",
2279 sym_op->auth.digest.data,
2282 /* Copy cipher and auth IVs at the end of the crypto operation */
2283 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2285 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2286 iv_ptr += cipher_iv_len;
2287 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2289 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2290 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2291 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2292 sym_op->cipher.data.length = cipher_len;
2293 sym_op->cipher.data.offset = cipher_offset;
2295 sym_op->cipher.data.length = cipher_len >> 3;
2296 sym_op->cipher.data.offset = cipher_offset >> 3;
2299 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2300 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2301 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2302 sym_op->auth.data.length = auth_len;
2303 sym_op->auth.data.offset = auth_offset;
2305 sym_op->auth.data.length = auth_len >> 3;
2306 sym_op->auth.data.offset = auth_offset >> 3;
2313 create_wireless_algo_auth_cipher_operation(
2314 const uint8_t *auth_tag, unsigned int auth_tag_len,
2315 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2316 const uint8_t *auth_iv, uint8_t auth_iv_len,
2317 unsigned int data_pad_len,
2318 unsigned int cipher_len, unsigned int cipher_offset,
2319 unsigned int auth_len, unsigned int auth_offset,
2320 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2322 struct crypto_testsuite_params *ts_params = &testsuite_params;
2323 struct crypto_unittest_params *ut_params = &unittest_params;
2325 enum rte_crypto_cipher_algorithm cipher_algo =
2326 ut_params->cipher_xform.cipher.algo;
2327 enum rte_crypto_auth_algorithm auth_algo =
2328 ut_params->auth_xform.auth.algo;
2330 /* Generate Crypto op data structure */
2331 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2332 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2333 TEST_ASSERT_NOT_NULL(ut_params->op,
2334 "Failed to allocate pktmbuf offload");
2336 /* Set crypto operation data parameters */
2337 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2339 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2341 /* set crypto operation mbufs */
2342 sym_op->m_src = ut_params->ibuf;
2343 if (op_mode == OUT_OF_PLACE)
2344 sym_op->m_dst = ut_params->obuf;
2348 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2349 (op_mode == IN_PLACE ?
2350 ut_params->ibuf : ut_params->obuf),
2351 uint8_t *, data_pad_len);
2352 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2353 (op_mode == IN_PLACE ?
2354 ut_params->ibuf : ut_params->obuf),
2356 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2358 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2359 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2360 sym_op->m_src : sym_op->m_dst);
2361 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2362 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2363 sgl_buf = sgl_buf->next;
2365 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2366 uint8_t *, remaining_off);
2367 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2369 memset(sym_op->auth.digest.data, 0, remaining_off);
2370 while (sgl_buf->next != NULL) {
2371 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2372 0, rte_pktmbuf_data_len(sgl_buf));
2373 sgl_buf = sgl_buf->next;
2377 /* Copy digest for the verification */
2379 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2381 /* Copy cipher and auth IVs at the end of the crypto operation */
2382 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2383 ut_params->op, uint8_t *, IV_OFFSET);
2385 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2386 iv_ptr += cipher_iv_len;
2387 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2389 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2390 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2391 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2392 sym_op->cipher.data.length = cipher_len;
2393 sym_op->cipher.data.offset = cipher_offset;
2395 sym_op->cipher.data.length = cipher_len >> 3;
2396 sym_op->cipher.data.offset = cipher_offset >> 3;
2399 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2400 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2401 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2402 sym_op->auth.data.length = auth_len;
2403 sym_op->auth.data.offset = auth_offset;
2405 sym_op->auth.data.length = auth_len >> 3;
2406 sym_op->auth.data.offset = auth_offset >> 3;
2413 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2415 struct crypto_testsuite_params *ts_params = &testsuite_params;
2416 struct crypto_unittest_params *ut_params = &unittest_params;
2419 unsigned plaintext_pad_len;
2420 unsigned plaintext_len;
2422 struct rte_cryptodev_info dev_info;
2424 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2425 uint64_t feat_flags = dev_info.feature_flags;
2427 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2428 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2429 printf("Device doesn't support NON-Byte Aligned Data.\n");
2433 /* Verify the capabilities */
2434 struct rte_cryptodev_sym_capability_idx cap_idx;
2435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2436 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2441 /* Create SNOW 3G session */
2442 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2443 tdata->key.data, tdata->key.len,
2444 tdata->auth_iv.len, tdata->digest.len,
2445 RTE_CRYPTO_AUTH_OP_GENERATE,
2446 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2450 /* alloc mbuf and set payload */
2451 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2453 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2454 rte_pktmbuf_tailroom(ut_params->ibuf));
2456 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2457 /* Append data which is padded to a multiple of */
2458 /* the algorithms block size */
2459 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2460 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2462 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2464 /* Create SNOW 3G operation */
2465 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2466 tdata->auth_iv.data, tdata->auth_iv.len,
2467 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2468 tdata->validAuthLenInBits.len,
2473 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2475 ut_params->obuf = ut_params->op->sym->m_src;
2476 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2477 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2478 + plaintext_pad_len;
2481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2484 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2485 "SNOW 3G Generated auth tag not as expected");
2491 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2493 struct crypto_testsuite_params *ts_params = &testsuite_params;
2494 struct crypto_unittest_params *ut_params = &unittest_params;
2497 unsigned plaintext_pad_len;
2498 unsigned plaintext_len;
2500 struct rte_cryptodev_info dev_info;
2502 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2503 uint64_t feat_flags = dev_info.feature_flags;
2505 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2506 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2507 printf("Device doesn't support NON-Byte Aligned Data.\n");
2511 /* Verify the capabilities */
2512 struct rte_cryptodev_sym_capability_idx cap_idx;
2513 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2514 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2515 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2519 /* Create SNOW 3G session */
2520 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2521 tdata->key.data, tdata->key.len,
2522 tdata->auth_iv.len, tdata->digest.len,
2523 RTE_CRYPTO_AUTH_OP_VERIFY,
2524 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2527 /* alloc mbuf and set payload */
2528 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2531 rte_pktmbuf_tailroom(ut_params->ibuf));
2533 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2534 /* Append data which is padded to a multiple of */
2535 /* the algorithms block size */
2536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2537 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2539 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2541 /* Create SNOW 3G operation */
2542 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2544 tdata->auth_iv.data, tdata->auth_iv.len,
2546 RTE_CRYPTO_AUTH_OP_VERIFY,
2547 tdata->validAuthLenInBits.len,
2552 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2554 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2555 ut_params->obuf = ut_params->op->sym->m_src;
2556 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2557 + plaintext_pad_len;
2560 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2569 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2571 struct crypto_testsuite_params *ts_params = &testsuite_params;
2572 struct crypto_unittest_params *ut_params = &unittest_params;
2575 unsigned plaintext_pad_len;
2576 unsigned plaintext_len;
2579 /* Verify the capabilities */
2580 struct rte_cryptodev_sym_capability_idx cap_idx;
2581 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2582 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2583 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2587 /* Create KASUMI session */
2588 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2589 tdata->key.data, tdata->key.len,
2590 0, tdata->digest.len,
2591 RTE_CRYPTO_AUTH_OP_GENERATE,
2592 RTE_CRYPTO_AUTH_KASUMI_F9);
2596 /* alloc mbuf and set payload */
2597 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2599 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2600 rte_pktmbuf_tailroom(ut_params->ibuf));
2602 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2603 /* Append data which is padded to a multiple of */
2604 /* the algorithms block size */
2605 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2606 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2608 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2610 /* Create KASUMI operation */
2611 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2613 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2614 tdata->plaintext.len,
2619 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2620 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2623 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2626 ut_params->obuf = ut_params->op->sym->m_src;
2627 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2628 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2629 + plaintext_pad_len;
2632 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2635 DIGEST_BYTE_LENGTH_KASUMI_F9,
2636 "KASUMI Generated auth tag not as expected");
2642 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2644 struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 struct crypto_unittest_params *ut_params = &unittest_params;
2648 unsigned plaintext_pad_len;
2649 unsigned plaintext_len;
2652 /* Verify the capabilities */
2653 struct rte_cryptodev_sym_capability_idx cap_idx;
2654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2655 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2656 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2660 /* Create KASUMI session */
2661 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2662 tdata->key.data, tdata->key.len,
2663 0, tdata->digest.len,
2664 RTE_CRYPTO_AUTH_OP_VERIFY,
2665 RTE_CRYPTO_AUTH_KASUMI_F9);
2668 /* alloc mbuf and set payload */
2669 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2671 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2672 rte_pktmbuf_tailroom(ut_params->ibuf));
2674 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2675 /* Append data which is padded to a multiple */
2676 /* of the algorithms block size */
2677 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2678 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2680 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2682 /* Create KASUMI operation */
2683 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2687 RTE_CRYPTO_AUTH_OP_VERIFY,
2688 tdata->plaintext.len,
2693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2695 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2696 ut_params->obuf = ut_params->op->sym->m_src;
2697 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2698 + plaintext_pad_len;
2701 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2710 test_snow3g_hash_generate_test_case_1(void)
2712 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2716 test_snow3g_hash_generate_test_case_2(void)
2718 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2722 test_snow3g_hash_generate_test_case_3(void)
2724 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2728 test_snow3g_hash_generate_test_case_4(void)
2730 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2734 test_snow3g_hash_generate_test_case_5(void)
2736 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2740 test_snow3g_hash_generate_test_case_6(void)
2742 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2746 test_snow3g_hash_verify_test_case_1(void)
2748 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2753 test_snow3g_hash_verify_test_case_2(void)
2755 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2759 test_snow3g_hash_verify_test_case_3(void)
2761 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2765 test_snow3g_hash_verify_test_case_4(void)
2767 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2771 test_snow3g_hash_verify_test_case_5(void)
2773 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2777 test_snow3g_hash_verify_test_case_6(void)
2779 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2783 test_kasumi_hash_generate_test_case_1(void)
2785 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2789 test_kasumi_hash_generate_test_case_2(void)
2791 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2795 test_kasumi_hash_generate_test_case_3(void)
2797 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2801 test_kasumi_hash_generate_test_case_4(void)
2803 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2807 test_kasumi_hash_generate_test_case_5(void)
2809 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2813 test_kasumi_hash_generate_test_case_6(void)
2815 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2819 test_kasumi_hash_verify_test_case_1(void)
2821 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2825 test_kasumi_hash_verify_test_case_2(void)
2827 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2831 test_kasumi_hash_verify_test_case_3(void)
2833 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2837 test_kasumi_hash_verify_test_case_4(void)
2839 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2843 test_kasumi_hash_verify_test_case_5(void)
2845 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2849 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2851 struct crypto_testsuite_params *ts_params = &testsuite_params;
2852 struct crypto_unittest_params *ut_params = &unittest_params;
2855 uint8_t *plaintext, *ciphertext;
2856 unsigned plaintext_pad_len;
2857 unsigned plaintext_len;
2859 /* Verify the capabilities */
2860 struct rte_cryptodev_sym_capability_idx cap_idx;
2861 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2862 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2863 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2867 /* Create KASUMI session */
2868 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2869 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2870 RTE_CRYPTO_CIPHER_KASUMI_F8,
2871 tdata->key.data, tdata->key.len,
2872 tdata->cipher_iv.len);
2876 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2878 /* Clear mbuf payload */
2879 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2880 rte_pktmbuf_tailroom(ut_params->ibuf));
2882 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2883 /* Append data which is padded to a multiple */
2884 /* of the algorithms block size */
2885 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2886 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2888 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2890 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2892 /* Create KASUMI operation */
2893 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2894 tdata->cipher_iv.len,
2895 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2896 tdata->validCipherOffsetInBits.len);
2900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2902 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2904 ut_params->obuf = ut_params->op->sym->m_dst;
2905 if (ut_params->obuf)
2906 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2908 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2910 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2912 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2913 (tdata->validCipherOffsetInBits.len >> 3);
2915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2917 reference_ciphertext,
2918 tdata->validCipherLenInBits.len,
2919 "KASUMI Ciphertext data not as expected");
2924 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2926 struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 struct crypto_unittest_params *ut_params = &unittest_params;
2931 unsigned int plaintext_pad_len;
2932 unsigned int plaintext_len;
2934 uint8_t buffer[10000];
2935 const uint8_t *ciphertext;
2937 struct rte_cryptodev_info dev_info;
2939 /* Verify the capabilities */
2940 struct rte_cryptodev_sym_capability_idx cap_idx;
2941 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2942 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2943 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2947 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2949 uint64_t feat_flags = dev_info.feature_flags;
2951 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2952 printf("Device doesn't support in-place scatter-gather. "
2957 /* Create KASUMI session */
2958 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2959 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2960 RTE_CRYPTO_CIPHER_KASUMI_F8,
2961 tdata->key.data, tdata->key.len,
2962 tdata->cipher_iv.len);
2966 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2969 /* Append data which is padded to a multiple */
2970 /* of the algorithms block size */
2971 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2973 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2974 plaintext_pad_len, 10, 0);
2976 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2978 /* Create KASUMI operation */
2979 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2980 tdata->cipher_iv.len,
2981 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2982 tdata->validCipherOffsetInBits.len);
2986 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2988 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2990 ut_params->obuf = ut_params->op->sym->m_dst;
2992 if (ut_params->obuf)
2993 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2994 plaintext_len, buffer);
2996 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
2997 tdata->validCipherOffsetInBits.len >> 3,
2998 plaintext_len, buffer);
3001 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3003 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3004 (tdata->validCipherOffsetInBits.len >> 3);
3006 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3008 reference_ciphertext,
3009 tdata->validCipherLenInBits.len,
3010 "KASUMI Ciphertext data not as expected");
3015 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3017 struct crypto_testsuite_params *ts_params = &testsuite_params;
3018 struct crypto_unittest_params *ut_params = &unittest_params;
3021 uint8_t *plaintext, *ciphertext;
3022 unsigned plaintext_pad_len;
3023 unsigned plaintext_len;
3025 /* Verify the capabilities */
3026 struct rte_cryptodev_sym_capability_idx cap_idx;
3027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3028 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3029 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3033 /* Create KASUMI session */
3034 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3035 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3036 RTE_CRYPTO_CIPHER_KASUMI_F8,
3037 tdata->key.data, tdata->key.len,
3038 tdata->cipher_iv.len);
3042 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3043 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3045 /* Clear mbuf payload */
3046 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3047 rte_pktmbuf_tailroom(ut_params->ibuf));
3049 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3050 /* Append data which is padded to a multiple */
3051 /* of the algorithms block size */
3052 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3055 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3056 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3058 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3060 /* Create KASUMI operation */
3061 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3062 tdata->cipher_iv.len,
3063 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3064 tdata->validCipherOffsetInBits.len);
3068 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3070 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3072 ut_params->obuf = ut_params->op->sym->m_dst;
3073 if (ut_params->obuf)
3074 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3076 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3078 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3080 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3081 (tdata->validCipherOffsetInBits.len >> 3);
3083 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3085 reference_ciphertext,
3086 tdata->validCipherLenInBits.len,
3087 "KASUMI Ciphertext data not as expected");
3092 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3094 struct crypto_testsuite_params *ts_params = &testsuite_params;
3095 struct crypto_unittest_params *ut_params = &unittest_params;
3098 unsigned int plaintext_pad_len;
3099 unsigned int plaintext_len;
3101 const uint8_t *ciphertext;
3102 uint8_t buffer[2048];
3104 struct rte_cryptodev_info dev_info;
3106 /* Verify the capabilities */
3107 struct rte_cryptodev_sym_capability_idx cap_idx;
3108 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3109 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3110 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3114 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3116 uint64_t feat_flags = dev_info.feature_flags;
3117 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3118 printf("Device doesn't support out-of-place scatter-gather "
3119 "in both input and output mbufs. "
3124 /* Create KASUMI session */
3125 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3126 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3127 RTE_CRYPTO_CIPHER_KASUMI_F8,
3128 tdata->key.data, tdata->key.len,
3129 tdata->cipher_iv.len);
3133 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3134 /* Append data which is padded to a multiple */
3135 /* of the algorithms block size */
3136 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3138 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3139 plaintext_pad_len, 10, 0);
3140 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3141 plaintext_pad_len, 3, 0);
3143 /* Append data which is padded to a multiple */
3144 /* of the algorithms block size */
3145 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3147 /* Create KASUMI operation */
3148 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3149 tdata->cipher_iv.len,
3150 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3151 tdata->validCipherOffsetInBits.len);
3155 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3157 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3159 ut_params->obuf = ut_params->op->sym->m_dst;
3160 if (ut_params->obuf)
3161 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3162 plaintext_pad_len, buffer);
3164 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3165 tdata->validCipherOffsetInBits.len >> 3,
3166 plaintext_pad_len, buffer);
3168 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3169 (tdata->validCipherOffsetInBits.len >> 3);
3171 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3173 reference_ciphertext,
3174 tdata->validCipherLenInBits.len,
3175 "KASUMI Ciphertext data not as expected");
3181 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3183 struct crypto_testsuite_params *ts_params = &testsuite_params;
3184 struct crypto_unittest_params *ut_params = &unittest_params;
3187 uint8_t *ciphertext, *plaintext;
3188 unsigned ciphertext_pad_len;
3189 unsigned ciphertext_len;
3191 /* Verify the capabilities */
3192 struct rte_cryptodev_sym_capability_idx cap_idx;
3193 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3194 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3195 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3199 /* Create KASUMI session */
3200 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3201 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3202 RTE_CRYPTO_CIPHER_KASUMI_F8,
3203 tdata->key.data, tdata->key.len,
3204 tdata->cipher_iv.len);
3208 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3209 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3211 /* Clear mbuf payload */
3212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3213 rte_pktmbuf_tailroom(ut_params->ibuf));
3215 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3216 /* Append data which is padded to a multiple */
3217 /* of the algorithms block size */
3218 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3219 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3220 ciphertext_pad_len);
3221 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3222 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3224 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3226 /* Create KASUMI operation */
3227 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3228 tdata->cipher_iv.len,
3229 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3230 tdata->validCipherOffsetInBits.len);
3234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3238 ut_params->obuf = ut_params->op->sym->m_dst;
3239 if (ut_params->obuf)
3240 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3242 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3244 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3246 const uint8_t *reference_plaintext = tdata->plaintext.data +
3247 (tdata->validCipherOffsetInBits.len >> 3);
3249 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3251 reference_plaintext,
3252 tdata->validCipherLenInBits.len,
3253 "KASUMI Plaintext data not as expected");
3258 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3264 uint8_t *ciphertext, *plaintext;
3265 unsigned ciphertext_pad_len;
3266 unsigned ciphertext_len;
3268 /* Verify the capabilities */
3269 struct rte_cryptodev_sym_capability_idx cap_idx;
3270 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3271 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3272 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3276 /* Create KASUMI session */
3277 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3278 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3279 RTE_CRYPTO_CIPHER_KASUMI_F8,
3280 tdata->key.data, tdata->key.len,
3281 tdata->cipher_iv.len);
3285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3287 /* Clear mbuf payload */
3288 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3289 rte_pktmbuf_tailroom(ut_params->ibuf));
3291 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3292 /* Append data which is padded to a multiple */
3293 /* of the algorithms block size */
3294 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3295 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3296 ciphertext_pad_len);
3297 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3299 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3301 /* Create KASUMI operation */
3302 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3303 tdata->cipher_iv.len,
3304 tdata->ciphertext.len,
3305 tdata->validCipherOffsetInBits.len);
3309 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3313 ut_params->obuf = ut_params->op->sym->m_dst;
3314 if (ut_params->obuf)
3315 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3317 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3319 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3321 const uint8_t *reference_plaintext = tdata->plaintext.data +
3322 (tdata->validCipherOffsetInBits.len >> 3);
3324 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3326 reference_plaintext,
3327 tdata->validCipherLenInBits.len,
3328 "KASUMI Plaintext data not as expected");
3333 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3335 struct crypto_testsuite_params *ts_params = &testsuite_params;
3336 struct crypto_unittest_params *ut_params = &unittest_params;
3339 uint8_t *plaintext, *ciphertext;
3340 unsigned plaintext_pad_len;
3341 unsigned plaintext_len;
3343 /* Verify the capabilities */
3344 struct rte_cryptodev_sym_capability_idx cap_idx;
3345 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3346 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3347 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3351 /* Create SNOW 3G session */
3352 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3353 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3354 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3355 tdata->key.data, tdata->key.len,
3356 tdata->cipher_iv.len);
3360 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3362 /* Clear mbuf payload */
3363 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3364 rte_pktmbuf_tailroom(ut_params->ibuf));
3366 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3367 /* Append data which is padded to a multiple of */
3368 /* the algorithms block size */
3369 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3372 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3374 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3376 /* Create SNOW 3G operation */
3377 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3378 tdata->cipher_iv.len,
3379 tdata->validCipherLenInBits.len,
3384 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3386 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3388 ut_params->obuf = ut_params->op->sym->m_dst;
3389 if (ut_params->obuf)
3390 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3392 ciphertext = plaintext;
3394 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3397 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3399 tdata->ciphertext.data,
3400 tdata->validDataLenInBits.len,
3401 "SNOW 3G Ciphertext data not as expected");
3407 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3409 struct crypto_testsuite_params *ts_params = &testsuite_params;
3410 struct crypto_unittest_params *ut_params = &unittest_params;
3411 uint8_t *plaintext, *ciphertext;
3414 unsigned plaintext_pad_len;
3415 unsigned plaintext_len;
3417 /* Verify the capabilities */
3418 struct rte_cryptodev_sym_capability_idx cap_idx;
3419 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3420 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3421 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3425 /* Create SNOW 3G session */
3426 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3427 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3428 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3429 tdata->key.data, tdata->key.len,
3430 tdata->cipher_iv.len);
3434 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3435 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3437 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3438 "Failed to allocate input buffer in mempool");
3439 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3440 "Failed to allocate output buffer in mempool");
3442 /* Clear mbuf payload */
3443 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3444 rte_pktmbuf_tailroom(ut_params->ibuf));
3446 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3447 /* Append data which is padded to a multiple of */
3448 /* the algorithms block size */
3449 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3450 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3452 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3453 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3455 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3457 /* Create SNOW 3G operation */
3458 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3459 tdata->cipher_iv.len,
3460 tdata->validCipherLenInBits.len,
3465 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3467 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3469 ut_params->obuf = ut_params->op->sym->m_dst;
3470 if (ut_params->obuf)
3471 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3473 ciphertext = plaintext;
3475 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3478 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3480 tdata->ciphertext.data,
3481 tdata->validDataLenInBits.len,
3482 "SNOW 3G Ciphertext data not as expected");
3487 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3489 struct crypto_testsuite_params *ts_params = &testsuite_params;
3490 struct crypto_unittest_params *ut_params = &unittest_params;
3493 unsigned int plaintext_pad_len;
3494 unsigned int plaintext_len;
3495 uint8_t buffer[10000];
3496 const uint8_t *ciphertext;
3498 struct rte_cryptodev_info dev_info;
3500 /* Verify the capabilities */
3501 struct rte_cryptodev_sym_capability_idx cap_idx;
3502 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3503 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3504 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3508 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3510 uint64_t feat_flags = dev_info.feature_flags;
3512 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3513 printf("Device doesn't support out-of-place scatter-gather "
3514 "in both input and output mbufs. "
3519 /* Create SNOW 3G session */
3520 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3521 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3522 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3523 tdata->key.data, tdata->key.len,
3524 tdata->cipher_iv.len);
3528 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3529 /* Append data which is padded to a multiple of */
3530 /* the algorithms block size */
3531 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3533 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3534 plaintext_pad_len, 10, 0);
3535 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3536 plaintext_pad_len, 3, 0);
3538 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3539 "Failed to allocate input buffer in mempool");
3540 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3541 "Failed to allocate output buffer in mempool");
3543 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3545 /* Create SNOW 3G operation */
3546 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3547 tdata->cipher_iv.len,
3548 tdata->validCipherLenInBits.len,
3553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3557 ut_params->obuf = ut_params->op->sym->m_dst;
3558 if (ut_params->obuf)
3559 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3560 plaintext_len, buffer);
3562 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3563 plaintext_len, buffer);
3565 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3568 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3570 tdata->ciphertext.data,
3571 tdata->validDataLenInBits.len,
3572 "SNOW 3G Ciphertext data not as expected");
3577 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3579 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3581 uint8_t curr_byte, prev_byte;
3582 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3583 uint8_t lower_byte_mask = (1 << offset) - 1;
3586 prev_byte = buffer[0];
3587 buffer[0] >>= offset;
3589 for (i = 1; i < length_in_bytes; i++) {
3590 curr_byte = buffer[i];
3591 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3592 (curr_byte >> offset);
3593 prev_byte = curr_byte;
3598 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3600 struct crypto_testsuite_params *ts_params = &testsuite_params;
3601 struct crypto_unittest_params *ut_params = &unittest_params;
3602 uint8_t *plaintext, *ciphertext;
3604 uint32_t plaintext_len;
3605 uint32_t plaintext_pad_len;
3606 uint8_t extra_offset = 4;
3607 uint8_t *expected_ciphertext_shifted;
3608 struct rte_cryptodev_info dev_info;
3610 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3611 uint64_t feat_flags = dev_info.feature_flags;
3613 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3614 ((tdata->validDataLenInBits.len % 8) != 0)) {
3615 printf("Device doesn't support NON-Byte Aligned Data.\n");
3619 /* Verify the capabilities */
3620 struct rte_cryptodev_sym_capability_idx cap_idx;
3621 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3622 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3623 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3627 /* Create SNOW 3G session */
3628 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3629 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3630 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3631 tdata->key.data, tdata->key.len,
3632 tdata->cipher_iv.len);
3636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3639 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3640 "Failed to allocate input buffer in mempool");
3641 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3642 "Failed to allocate output buffer in mempool");
3644 /* Clear mbuf payload */
3645 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3646 rte_pktmbuf_tailroom(ut_params->ibuf));
3648 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3650 * Append data which is padded to a
3651 * multiple of the algorithms block size
3653 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3655 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3658 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3660 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3661 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3663 #ifdef RTE_APP_TEST_DEBUG
3664 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3666 /* Create SNOW 3G operation */
3667 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3668 tdata->cipher_iv.len,
3669 tdata->validCipherLenInBits.len,
3674 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3678 ut_params->obuf = ut_params->op->sym->m_dst;
3679 if (ut_params->obuf)
3680 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3682 ciphertext = plaintext;
3684 #ifdef RTE_APP_TEST_DEBUG
3685 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3688 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3690 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3691 "failed to reserve memory for ciphertext shifted\n");
3693 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3694 ceil_byte_length(tdata->ciphertext.len));
3695 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3698 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3700 expected_ciphertext_shifted,
3701 tdata->validDataLenInBits.len,
3703 "SNOW 3G Ciphertext data not as expected");
3707 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3709 struct crypto_testsuite_params *ts_params = &testsuite_params;
3710 struct crypto_unittest_params *ut_params = &unittest_params;
3714 uint8_t *plaintext, *ciphertext;
3715 unsigned ciphertext_pad_len;
3716 unsigned ciphertext_len;
3718 /* Verify the capabilities */
3719 struct rte_cryptodev_sym_capability_idx cap_idx;
3720 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3721 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3722 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3726 /* Create SNOW 3G session */
3727 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3728 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3729 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3730 tdata->key.data, tdata->key.len,
3731 tdata->cipher_iv.len);
3735 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3737 /* Clear mbuf payload */
3738 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3739 rte_pktmbuf_tailroom(ut_params->ibuf));
3741 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3742 /* Append data which is padded to a multiple of */
3743 /* the algorithms block size */
3744 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3745 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3746 ciphertext_pad_len);
3747 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3749 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3751 /* Create SNOW 3G operation */
3752 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3753 tdata->cipher_iv.len,
3754 tdata->validCipherLenInBits.len,
3755 tdata->cipher.offset_bits);
3759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3761 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3762 ut_params->obuf = ut_params->op->sym->m_dst;
3763 if (ut_params->obuf)
3764 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3766 plaintext = ciphertext;
3768 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3771 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3772 tdata->plaintext.data,
3773 tdata->validDataLenInBits.len,
3774 "SNOW 3G Plaintext data not as expected");
3778 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3780 struct crypto_testsuite_params *ts_params = &testsuite_params;
3781 struct crypto_unittest_params *ut_params = &unittest_params;
3785 uint8_t *plaintext, *ciphertext;
3786 unsigned ciphertext_pad_len;
3787 unsigned ciphertext_len;
3789 /* Verify the capabilities */
3790 struct rte_cryptodev_sym_capability_idx cap_idx;
3791 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3792 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3793 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3797 /* Create SNOW 3G session */
3798 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3799 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3800 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3801 tdata->key.data, tdata->key.len,
3802 tdata->cipher_iv.len);
3806 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3807 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3809 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3810 "Failed to allocate input buffer");
3811 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3812 "Failed to allocate output buffer");
3814 /* Clear mbuf payload */
3815 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3816 rte_pktmbuf_tailroom(ut_params->ibuf));
3818 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3819 rte_pktmbuf_tailroom(ut_params->obuf));
3821 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3822 /* Append data which is padded to a multiple of */
3823 /* the algorithms block size */
3824 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3825 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3826 ciphertext_pad_len);
3827 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3828 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3830 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3832 /* Create SNOW 3G operation */
3833 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3834 tdata->cipher_iv.len,
3835 tdata->validCipherLenInBits.len,
3840 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3842 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3843 ut_params->obuf = ut_params->op->sym->m_dst;
3844 if (ut_params->obuf)
3845 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3847 plaintext = ciphertext;
3849 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3852 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3853 tdata->plaintext.data,
3854 tdata->validDataLenInBits.len,
3855 "SNOW 3G Plaintext data not as expected");
3860 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3862 struct crypto_testsuite_params *ts_params = &testsuite_params;
3863 struct crypto_unittest_params *ut_params = &unittest_params;
3867 uint8_t *plaintext, *ciphertext;
3868 unsigned int plaintext_pad_len;
3869 unsigned int plaintext_len;
3871 struct rte_cryptodev_info dev_info;
3872 struct rte_cryptodev_sym_capability_idx cap_idx;
3874 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3875 uint64_t feat_flags = dev_info.feature_flags;
3877 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3878 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3879 (tdata->validDataLenInBits.len % 8 != 0))) {
3880 printf("Device doesn't support NON-Byte Aligned Data.\n");
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;
5071 struct rte_cryptodev_info dev_info;
5073 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5074 uint64_t feat_flags = dev_info.feature_flags;
5076 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5077 (tdata->validAuthLenInBits.len % 8 != 0)) {
5078 printf("Device doesn't support NON-Byte Aligned Data.\n");
5082 /* Check if device supports ZUC EIA3 */
5083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5084 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5086 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5090 /* Create ZUC session */
5091 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5092 tdata->key.data, tdata->key.len,
5093 tdata->auth_iv.len, tdata->digest.len,
5094 RTE_CRYPTO_AUTH_OP_GENERATE,
5095 RTE_CRYPTO_AUTH_ZUC_EIA3);
5099 /* alloc mbuf and set payload */
5100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5102 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5103 rte_pktmbuf_tailroom(ut_params->ibuf));
5105 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5106 /* Append data which is padded to a multiple of */
5107 /* the algorithms block size */
5108 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5109 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5111 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5113 /* Create ZUC operation */
5114 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5115 tdata->auth_iv.data, tdata->auth_iv.len,
5116 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5117 tdata->validAuthLenInBits.len,
5122 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5124 ut_params->obuf = ut_params->op->sym->m_src;
5125 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5126 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5127 + plaintext_pad_len;
5130 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5134 "ZUC Generated auth tag not as expected");
5140 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5141 uint8_t op_mode, uint8_t verify)
5143 struct crypto_testsuite_params *ts_params = &testsuite_params;
5144 struct crypto_unittest_params *ut_params = &unittest_params;
5148 uint8_t *plaintext = NULL, *ciphertext = NULL;
5149 unsigned int plaintext_pad_len;
5150 unsigned int plaintext_len;
5151 unsigned int ciphertext_pad_len;
5152 unsigned int ciphertext_len;
5154 struct rte_cryptodev_info dev_info;
5155 struct rte_cryptodev_sym_capability_idx cap_idx;
5157 /* Check if device supports ZUC EIA3 */
5158 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5159 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5161 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5165 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5167 uint64_t feat_flags = dev_info.feature_flags;
5169 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5170 printf("Device doesn't support digest encrypted.\n");
5173 if (op_mode == IN_PLACE) {
5174 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5175 printf("Device doesn't support in-place scatter-gather "
5176 "in both input and output mbufs.\n");
5180 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5181 printf("Device doesn't support out-of-place scatter-gather "
5182 "in both input and output mbufs.\n");
5187 /* Create ZUC session */
5188 retval = create_wireless_algo_auth_cipher_session(
5189 ts_params->valid_devs[0],
5190 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5191 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5192 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5193 : RTE_CRYPTO_AUTH_OP_GENERATE),
5194 RTE_CRYPTO_AUTH_ZUC_EIA3,
5195 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5196 tdata->key.data, tdata->key.len,
5197 tdata->auth_iv.len, tdata->digest.len,
5198 tdata->cipher_iv.len);
5203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5204 if (op_mode == OUT_OF_PLACE)
5205 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5207 /* clear mbuf payload */
5208 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5209 rte_pktmbuf_tailroom(ut_params->ibuf));
5210 if (op_mode == OUT_OF_PLACE)
5211 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5212 rte_pktmbuf_tailroom(ut_params->obuf));
5214 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5215 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5216 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5217 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5220 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5221 ciphertext_pad_len);
5222 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5223 if (op_mode == OUT_OF_PLACE)
5224 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5225 debug_hexdump(stdout, "ciphertext:", ciphertext,
5228 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5230 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5231 if (op_mode == OUT_OF_PLACE)
5232 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5233 debug_hexdump(stdout, "plaintext:", plaintext,
5237 /* Create ZUC operation */
5238 retval = create_wireless_algo_auth_cipher_operation(
5239 tdata->digest.data, tdata->digest.len,
5240 tdata->cipher_iv.data, tdata->cipher_iv.len,
5241 tdata->auth_iv.data, tdata->auth_iv.len,
5242 (tdata->digest.offset_bytes == 0 ?
5243 (verify ? ciphertext_pad_len : plaintext_pad_len)
5244 : tdata->digest.offset_bytes),
5245 tdata->validCipherLenInBits.len,
5246 tdata->validCipherOffsetInBits.len,
5247 tdata->validAuthLenInBits.len,
5249 op_mode, 0, verify);
5254 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5257 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5259 ut_params->obuf = (op_mode == IN_PLACE ?
5260 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5264 if (ut_params->obuf)
5265 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5268 plaintext = ciphertext;
5270 debug_hexdump(stdout, "plaintext:", plaintext,
5271 (tdata->plaintext.len >> 3) - tdata->digest.len);
5272 debug_hexdump(stdout, "plaintext expected:",
5273 tdata->plaintext.data,
5274 (tdata->plaintext.len >> 3) - tdata->digest.len);
5276 if (ut_params->obuf)
5277 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5280 ciphertext = plaintext;
5282 debug_hexdump(stdout, "ciphertext:", ciphertext,
5284 debug_hexdump(stdout, "ciphertext expected:",
5285 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5287 ut_params->digest = rte_pktmbuf_mtod(
5288 ut_params->obuf, uint8_t *) +
5289 (tdata->digest.offset_bytes == 0 ?
5290 plaintext_pad_len : tdata->digest.offset_bytes);
5292 debug_hexdump(stdout, "digest:", ut_params->digest,
5294 debug_hexdump(stdout, "digest expected:",
5295 tdata->digest.data, tdata->digest.len);
5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5302 tdata->plaintext.data,
5303 tdata->plaintext.len >> 3,
5304 "ZUC Plaintext data not as expected");
5306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5308 tdata->ciphertext.data,
5309 tdata->ciphertext.len >> 3,
5310 "ZUC Ciphertext data not as expected");
5312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5315 DIGEST_BYTE_LENGTH_KASUMI_F9,
5316 "ZUC Generated auth tag not as expected");
5322 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5323 uint8_t op_mode, uint8_t verify)
5325 struct crypto_testsuite_params *ts_params = &testsuite_params;
5326 struct crypto_unittest_params *ut_params = &unittest_params;
5330 const uint8_t *plaintext = NULL;
5331 const uint8_t *ciphertext = NULL;
5332 const uint8_t *digest = NULL;
5333 unsigned int plaintext_pad_len;
5334 unsigned int plaintext_len;
5335 unsigned int ciphertext_pad_len;
5336 unsigned int ciphertext_len;
5337 uint8_t buffer[10000];
5338 uint8_t digest_buffer[10000];
5340 struct rte_cryptodev_info dev_info;
5341 struct rte_cryptodev_sym_capability_idx cap_idx;
5343 /* Check if device supports ZUC EIA3 */
5344 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5345 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5347 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5351 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5353 uint64_t feat_flags = dev_info.feature_flags;
5355 if (op_mode == IN_PLACE) {
5356 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5357 printf("Device doesn't support in-place scatter-gather "
5358 "in both input and output mbufs.\n");
5362 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5363 printf("Device doesn't support out-of-place scatter-gather "
5364 "in both input and output mbufs.\n");
5367 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5368 printf("Device doesn't support digest encrypted.\n");
5373 /* Create ZUC session */
5374 retval = create_wireless_algo_auth_cipher_session(
5375 ts_params->valid_devs[0],
5376 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5377 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5378 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5379 : RTE_CRYPTO_AUTH_OP_GENERATE),
5380 RTE_CRYPTO_AUTH_ZUC_EIA3,
5381 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5382 tdata->key.data, tdata->key.len,
5383 tdata->auth_iv.len, tdata->digest.len,
5384 tdata->cipher_iv.len);
5389 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5390 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5391 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5392 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5394 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5395 plaintext_pad_len, 15, 0);
5396 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5397 "Failed to allocate input buffer in mempool");
5399 if (op_mode == OUT_OF_PLACE) {
5400 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5401 plaintext_pad_len, 15, 0);
5402 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5403 "Failed to allocate output buffer in mempool");
5407 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5408 tdata->ciphertext.data);
5409 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5410 ciphertext_len, buffer);
5411 debug_hexdump(stdout, "ciphertext:", ciphertext,
5414 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5415 tdata->plaintext.data);
5416 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5417 plaintext_len, buffer);
5418 debug_hexdump(stdout, "plaintext:", plaintext,
5421 memset(buffer, 0, sizeof(buffer));
5423 /* Create ZUC operation */
5424 retval = create_wireless_algo_auth_cipher_operation(
5425 tdata->digest.data, tdata->digest.len,
5426 tdata->cipher_iv.data, tdata->cipher_iv.len,
5428 (tdata->digest.offset_bytes == 0 ?
5429 (verify ? ciphertext_pad_len : plaintext_pad_len)
5430 : tdata->digest.offset_bytes),
5431 tdata->validCipherLenInBits.len,
5432 tdata->validCipherOffsetInBits.len,
5433 tdata->validAuthLenInBits.len,
5435 op_mode, 1, verify);
5440 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5443 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5445 ut_params->obuf = (op_mode == IN_PLACE ?
5446 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5449 if (ut_params->obuf)
5450 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5451 plaintext_len, buffer);
5453 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5454 plaintext_len, buffer);
5456 debug_hexdump(stdout, "plaintext:", plaintext,
5457 (tdata->plaintext.len >> 3) - tdata->digest.len);
5458 debug_hexdump(stdout, "plaintext expected:",
5459 tdata->plaintext.data,
5460 (tdata->plaintext.len >> 3) - tdata->digest.len);
5462 if (ut_params->obuf)
5463 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5464 ciphertext_len, buffer);
5466 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5467 ciphertext_len, buffer);
5469 debug_hexdump(stdout, "ciphertext:", ciphertext,
5471 debug_hexdump(stdout, "ciphertext expected:",
5472 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5474 if (ut_params->obuf)
5475 digest = rte_pktmbuf_read(ut_params->obuf,
5476 (tdata->digest.offset_bytes == 0 ?
5477 plaintext_pad_len : tdata->digest.offset_bytes),
5478 tdata->digest.len, digest_buffer);
5480 digest = rte_pktmbuf_read(ut_params->ibuf,
5481 (tdata->digest.offset_bytes == 0 ?
5482 plaintext_pad_len : tdata->digest.offset_bytes),
5483 tdata->digest.len, digest_buffer);
5485 debug_hexdump(stdout, "digest:", digest,
5487 debug_hexdump(stdout, "digest expected:",
5488 tdata->digest.data, tdata->digest.len);
5493 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5495 tdata->plaintext.data,
5496 tdata->plaintext.len >> 3,
5497 "ZUC Plaintext data not as expected");
5499 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5501 tdata->ciphertext.data,
5502 tdata->validDataLenInBits.len,
5503 "ZUC Ciphertext data not as expected");
5505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5508 DIGEST_BYTE_LENGTH_KASUMI_F9,
5509 "ZUC Generated auth tag not as expected");
5515 test_kasumi_encryption_test_case_1(void)
5517 return test_kasumi_encryption(&kasumi_test_case_1);
5521 test_kasumi_encryption_test_case_1_sgl(void)
5523 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5527 test_kasumi_encryption_test_case_1_oop(void)
5529 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5533 test_kasumi_encryption_test_case_1_oop_sgl(void)
5535 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5539 test_kasumi_encryption_test_case_2(void)
5541 return test_kasumi_encryption(&kasumi_test_case_2);
5545 test_kasumi_encryption_test_case_3(void)
5547 return test_kasumi_encryption(&kasumi_test_case_3);
5551 test_kasumi_encryption_test_case_4(void)
5553 return test_kasumi_encryption(&kasumi_test_case_4);
5557 test_kasumi_encryption_test_case_5(void)
5559 return test_kasumi_encryption(&kasumi_test_case_5);
5563 test_kasumi_decryption_test_case_1(void)
5565 return test_kasumi_decryption(&kasumi_test_case_1);
5569 test_kasumi_decryption_test_case_1_oop(void)
5571 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5575 test_kasumi_decryption_test_case_2(void)
5577 return test_kasumi_decryption(&kasumi_test_case_2);
5581 test_kasumi_decryption_test_case_3(void)
5583 return test_kasumi_decryption(&kasumi_test_case_3);
5587 test_kasumi_decryption_test_case_4(void)
5589 return test_kasumi_decryption(&kasumi_test_case_4);
5593 test_kasumi_decryption_test_case_5(void)
5595 return test_kasumi_decryption(&kasumi_test_case_5);
5598 test_snow3g_encryption_test_case_1(void)
5600 return test_snow3g_encryption(&snow3g_test_case_1);
5604 test_snow3g_encryption_test_case_1_oop(void)
5606 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5610 test_snow3g_encryption_test_case_1_oop_sgl(void)
5612 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5617 test_snow3g_encryption_test_case_1_offset_oop(void)
5619 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5623 test_snow3g_encryption_test_case_2(void)
5625 return test_snow3g_encryption(&snow3g_test_case_2);
5629 test_snow3g_encryption_test_case_3(void)
5631 return test_snow3g_encryption(&snow3g_test_case_3);
5635 test_snow3g_encryption_test_case_4(void)
5637 return test_snow3g_encryption(&snow3g_test_case_4);
5641 test_snow3g_encryption_test_case_5(void)
5643 return test_snow3g_encryption(&snow3g_test_case_5);
5647 test_snow3g_decryption_test_case_1(void)
5649 return test_snow3g_decryption(&snow3g_test_case_1);
5653 test_snow3g_decryption_test_case_1_oop(void)
5655 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5659 test_snow3g_decryption_test_case_2(void)
5661 return test_snow3g_decryption(&snow3g_test_case_2);
5665 test_snow3g_decryption_test_case_3(void)
5667 return test_snow3g_decryption(&snow3g_test_case_3);
5671 test_snow3g_decryption_test_case_4(void)
5673 return test_snow3g_decryption(&snow3g_test_case_4);
5677 test_snow3g_decryption_test_case_5(void)
5679 return test_snow3g_decryption(&snow3g_test_case_5);
5683 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5684 * Pattern digest from snow3g_test_data must be allocated as
5685 * 4 last bytes in plaintext.
5688 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5689 struct snow3g_hash_test_data *output)
5691 if ((pattern != NULL) && (output != NULL)) {
5692 output->key.len = pattern->key.len;
5694 memcpy(output->key.data,
5695 pattern->key.data, pattern->key.len);
5697 output->auth_iv.len = pattern->auth_iv.len;
5699 memcpy(output->auth_iv.data,
5700 pattern->auth_iv.data, pattern->auth_iv.len);
5702 output->plaintext.len = pattern->plaintext.len;
5704 memcpy(output->plaintext.data,
5705 pattern->plaintext.data, pattern->plaintext.len >> 3);
5707 output->digest.len = pattern->digest.len;
5709 memcpy(output->digest.data,
5710 &pattern->plaintext.data[pattern->digest.offset_bytes],
5711 pattern->digest.len);
5713 output->validAuthLenInBits.len =
5714 pattern->validAuthLenInBits.len;
5719 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5722 test_snow3g_decryption_with_digest_test_case_1(void)
5724 struct snow3g_hash_test_data snow3g_hash_data;
5727 * Function prepare data for hash veryfication test case.
5728 * Digest is allocated in 4 last bytes in plaintext, pattern.
5730 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5732 return test_snow3g_decryption(&snow3g_test_case_7) &
5733 test_snow3g_authentication_verify(&snow3g_hash_data);
5737 test_snow3g_cipher_auth_test_case_1(void)
5739 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5743 test_snow3g_auth_cipher_test_case_1(void)
5745 return test_snow3g_auth_cipher(
5746 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5750 test_snow3g_auth_cipher_test_case_2(void)
5752 return test_snow3g_auth_cipher(
5753 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5757 test_snow3g_auth_cipher_test_case_2_oop(void)
5759 return test_snow3g_auth_cipher(
5760 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5764 test_snow3g_auth_cipher_part_digest_enc(void)
5766 return test_snow3g_auth_cipher(
5767 &snow3g_auth_cipher_partial_digest_encryption,
5772 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5774 return test_snow3g_auth_cipher(
5775 &snow3g_auth_cipher_partial_digest_encryption,
5780 test_snow3g_auth_cipher_test_case_3_sgl(void)
5782 return test_snow3g_auth_cipher_sgl(
5783 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5787 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5789 return test_snow3g_auth_cipher_sgl(
5790 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5794 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5796 return test_snow3g_auth_cipher_sgl(
5797 &snow3g_auth_cipher_partial_digest_encryption,
5802 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5804 return test_snow3g_auth_cipher_sgl(
5805 &snow3g_auth_cipher_partial_digest_encryption,
5810 test_snow3g_auth_cipher_verify_test_case_1(void)
5812 return test_snow3g_auth_cipher(
5813 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5817 test_snow3g_auth_cipher_verify_test_case_2(void)
5819 return test_snow3g_auth_cipher(
5820 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5824 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5826 return test_snow3g_auth_cipher(
5827 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5831 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5833 return test_snow3g_auth_cipher(
5834 &snow3g_auth_cipher_partial_digest_encryption,
5839 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5841 return test_snow3g_auth_cipher(
5842 &snow3g_auth_cipher_partial_digest_encryption,
5847 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5849 return test_snow3g_auth_cipher_sgl(
5850 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5854 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5856 return test_snow3g_auth_cipher_sgl(
5857 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5861 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5863 return test_snow3g_auth_cipher_sgl(
5864 &snow3g_auth_cipher_partial_digest_encryption,
5869 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5871 return test_snow3g_auth_cipher_sgl(
5872 &snow3g_auth_cipher_partial_digest_encryption,
5877 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5879 return test_snow3g_auth_cipher(
5880 &snow3g_test_case_7, IN_PLACE, 0);
5884 test_kasumi_auth_cipher_test_case_1(void)
5886 return test_kasumi_auth_cipher(
5887 &kasumi_test_case_3, IN_PLACE, 0);
5891 test_kasumi_auth_cipher_test_case_2(void)
5893 return test_kasumi_auth_cipher(
5894 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5898 test_kasumi_auth_cipher_test_case_2_oop(void)
5900 return test_kasumi_auth_cipher(
5901 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5905 test_kasumi_auth_cipher_test_case_2_sgl(void)
5907 return test_kasumi_auth_cipher_sgl(
5908 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5912 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5914 return test_kasumi_auth_cipher_sgl(
5915 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5919 test_kasumi_auth_cipher_verify_test_case_1(void)
5921 return test_kasumi_auth_cipher(
5922 &kasumi_test_case_3, IN_PLACE, 1);
5926 test_kasumi_auth_cipher_verify_test_case_2(void)
5928 return test_kasumi_auth_cipher(
5929 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5933 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5935 return test_kasumi_auth_cipher(
5936 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5940 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5942 return test_kasumi_auth_cipher_sgl(
5943 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5947 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5949 return test_kasumi_auth_cipher_sgl(
5950 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5954 test_kasumi_cipher_auth_test_case_1(void)
5956 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5960 test_zuc_encryption_test_case_1(void)
5962 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5966 test_zuc_encryption_test_case_2(void)
5968 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5972 test_zuc_encryption_test_case_3(void)
5974 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5978 test_zuc_encryption_test_case_4(void)
5980 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5984 test_zuc_encryption_test_case_5(void)
5986 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5990 test_zuc_encryption_test_case_6_sgl(void)
5992 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5996 test_zuc_hash_generate_test_case_1(void)
5998 return test_zuc_authentication(&zuc_test_case_auth_1b);
6002 test_zuc_hash_generate_test_case_2(void)
6004 return test_zuc_authentication(&zuc_test_case_auth_90b);
6008 test_zuc_hash_generate_test_case_3(void)
6010 return test_zuc_authentication(&zuc_test_case_auth_577b);
6014 test_zuc_hash_generate_test_case_4(void)
6016 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6020 test_zuc_hash_generate_test_case_5(void)
6022 return test_zuc_authentication(&zuc_test_auth_5670b);
6026 test_zuc_hash_generate_test_case_6(void)
6028 return test_zuc_authentication(&zuc_test_case_auth_128b);
6032 test_zuc_hash_generate_test_case_7(void)
6034 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6038 test_zuc_hash_generate_test_case_8(void)
6040 return test_zuc_authentication(&zuc_test_case_auth_584b);
6044 test_zuc_cipher_auth_test_case_1(void)
6046 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6050 test_zuc_cipher_auth_test_case_2(void)
6052 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6056 test_zuc_auth_cipher_test_case_1(void)
6058 return test_zuc_auth_cipher(
6059 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6063 test_zuc_auth_cipher_test_case_1_oop(void)
6065 return test_zuc_auth_cipher(
6066 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6070 test_zuc_auth_cipher_test_case_1_sgl(void)
6072 return test_zuc_auth_cipher_sgl(
6073 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6077 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6079 return test_zuc_auth_cipher_sgl(
6080 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6084 test_zuc_auth_cipher_verify_test_case_1(void)
6086 return test_zuc_auth_cipher(
6087 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6091 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6093 return test_zuc_auth_cipher(
6094 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6098 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6100 return test_zuc_auth_cipher_sgl(
6101 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6105 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6107 return test_zuc_auth_cipher_sgl(
6108 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6112 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6114 uint8_t dev_id = testsuite_params.valid_devs[0];
6116 struct rte_cryptodev_sym_capability_idx cap_idx;
6118 /* Check if device supports particular cipher algorithm */
6119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6120 cap_idx.algo.cipher = tdata->cipher_algo;
6121 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6124 /* Check if device supports particular hash algorithm */
6125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6126 cap_idx.algo.auth = tdata->auth_algo;
6127 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6134 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6135 uint8_t op_mode, uint8_t verify)
6137 struct crypto_testsuite_params *ts_params = &testsuite_params;
6138 struct crypto_unittest_params *ut_params = &unittest_params;
6142 uint8_t *plaintext = NULL, *ciphertext = NULL;
6143 unsigned int plaintext_pad_len;
6144 unsigned int plaintext_len;
6145 unsigned int ciphertext_pad_len;
6146 unsigned int ciphertext_len;
6148 struct rte_cryptodev_info dev_info;
6149 struct rte_crypto_op *op;
6151 /* Check if device supports particular algorithms separately */
6152 if (test_mixed_check_if_unsupported(tdata))
6155 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6157 uint64_t feat_flags = dev_info.feature_flags;
6159 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6160 printf("Device doesn't support digest encrypted.\n");
6164 /* Create the session */
6166 retval = create_wireless_algo_cipher_auth_session(
6167 ts_params->valid_devs[0],
6168 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6169 RTE_CRYPTO_AUTH_OP_VERIFY,
6172 tdata->auth_key.data, tdata->auth_key.len,
6173 tdata->auth_iv.len, tdata->digest_enc.len,
6174 tdata->cipher_iv.len);
6176 retval = create_wireless_algo_auth_cipher_session(
6177 ts_params->valid_devs[0],
6178 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6179 RTE_CRYPTO_AUTH_OP_GENERATE,
6182 tdata->auth_key.data, tdata->auth_key.len,
6183 tdata->auth_iv.len, tdata->digest_enc.len,
6184 tdata->cipher_iv.len);
6188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6189 if (op_mode == OUT_OF_PLACE)
6190 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6192 /* clear mbuf payload */
6193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6194 rte_pktmbuf_tailroom(ut_params->ibuf));
6195 if (op_mode == OUT_OF_PLACE)
6196 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6197 rte_pktmbuf_tailroom(ut_params->obuf));
6199 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6200 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6201 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6205 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6206 ciphertext_pad_len);
6207 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6208 if (op_mode == OUT_OF_PLACE)
6209 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6210 debug_hexdump(stdout, "ciphertext:", ciphertext,
6213 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6215 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6216 if (op_mode == OUT_OF_PLACE)
6217 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6218 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6221 /* Create the operation */
6222 retval = create_wireless_algo_auth_cipher_operation(
6223 tdata->digest_enc.data, tdata->digest_enc.len,
6224 tdata->cipher_iv.data, tdata->cipher_iv.len,
6225 tdata->auth_iv.data, tdata->auth_iv.len,
6226 (tdata->digest_enc.offset == 0 ?
6228 : tdata->digest_enc.offset),
6229 tdata->validCipherLen.len_bits,
6230 tdata->cipher.offset_bits,
6231 tdata->validAuthLen.len_bits,
6232 tdata->auth.offset_bits,
6233 op_mode, 0, verify);
6238 op = process_crypto_request(ts_params->valid_devs[0],
6241 /* Check if the op failed because the device doesn't */
6242 /* support this particular combination of algorithms */
6243 if (op == NULL && ut_params->op->status ==
6244 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6245 printf("Device doesn't support this mixed combination. "
6251 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6253 ut_params->obuf = (op_mode == IN_PLACE ?
6254 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6257 if (ut_params->obuf)
6258 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6261 plaintext = ciphertext +
6262 (tdata->cipher.offset_bits >> 3);
6264 debug_hexdump(stdout, "plaintext:", plaintext,
6265 tdata->plaintext.len_bits >> 3);
6266 debug_hexdump(stdout, "plaintext expected:",
6267 tdata->plaintext.data,
6268 tdata->plaintext.len_bits >> 3);
6270 if (ut_params->obuf)
6271 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6274 ciphertext = plaintext;
6276 debug_hexdump(stdout, "ciphertext:", ciphertext,
6278 debug_hexdump(stdout, "ciphertext expected:",
6279 tdata->ciphertext.data,
6280 tdata->ciphertext.len_bits >> 3);
6282 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6283 + (tdata->digest_enc.offset == 0 ?
6284 plaintext_pad_len : tdata->digest_enc.offset);
6286 debug_hexdump(stdout, "digest:", ut_params->digest,
6287 tdata->digest_enc.len);
6288 debug_hexdump(stdout, "digest expected:",
6289 tdata->digest_enc.data,
6290 tdata->digest_enc.len);
6295 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6297 tdata->plaintext.data,
6298 tdata->plaintext.len_bits >> 3,
6299 "Plaintext data not as expected");
6301 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6303 tdata->ciphertext.data,
6304 tdata->validDataLen.len_bits,
6305 "Ciphertext data not as expected");
6307 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6309 tdata->digest_enc.data,
6310 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6311 "Generated auth tag not as expected");
6314 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6315 "crypto op processing failed");
6321 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6322 uint8_t op_mode, uint8_t verify)
6324 struct crypto_testsuite_params *ts_params = &testsuite_params;
6325 struct crypto_unittest_params *ut_params = &unittest_params;
6329 const uint8_t *plaintext = NULL;
6330 const uint8_t *ciphertext = NULL;
6331 const uint8_t *digest = NULL;
6332 unsigned int plaintext_pad_len;
6333 unsigned int plaintext_len;
6334 unsigned int ciphertext_pad_len;
6335 unsigned int ciphertext_len;
6336 uint8_t buffer[10000];
6337 uint8_t digest_buffer[10000];
6339 struct rte_cryptodev_info dev_info;
6340 struct rte_crypto_op *op;
6342 /* Check if device supports particular algorithms */
6343 if (test_mixed_check_if_unsupported(tdata))
6346 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6348 uint64_t feat_flags = dev_info.feature_flags;
6350 if (op_mode == IN_PLACE) {
6351 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6352 printf("Device doesn't support in-place scatter-gather "
6353 "in both input and output mbufs.\n");
6357 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6358 printf("Device doesn't support out-of-place scatter-gather "
6359 "in both input and output mbufs.\n");
6362 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6363 printf("Device doesn't support digest encrypted.\n");
6368 /* Create the session */
6370 retval = create_wireless_algo_cipher_auth_session(
6371 ts_params->valid_devs[0],
6372 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6373 RTE_CRYPTO_AUTH_OP_VERIFY,
6376 tdata->auth_key.data, tdata->auth_key.len,
6377 tdata->auth_iv.len, tdata->digest_enc.len,
6378 tdata->cipher_iv.len);
6380 retval = create_wireless_algo_auth_cipher_session(
6381 ts_params->valid_devs[0],
6382 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6383 RTE_CRYPTO_AUTH_OP_GENERATE,
6386 tdata->auth_key.data, tdata->auth_key.len,
6387 tdata->auth_iv.len, tdata->digest_enc.len,
6388 tdata->cipher_iv.len);
6392 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6393 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6394 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6395 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6397 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6398 ciphertext_pad_len, 15, 0);
6399 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6400 "Failed to allocate input buffer in mempool");
6402 if (op_mode == OUT_OF_PLACE) {
6403 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6404 plaintext_pad_len, 15, 0);
6405 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6406 "Failed to allocate output buffer in mempool");
6410 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6411 tdata->ciphertext.data);
6412 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6413 ciphertext_len, buffer);
6414 debug_hexdump(stdout, "ciphertext:", ciphertext,
6417 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6418 tdata->plaintext.data);
6419 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6420 plaintext_len, buffer);
6421 debug_hexdump(stdout, "plaintext:", plaintext,
6424 memset(buffer, 0, sizeof(buffer));
6426 /* Create the operation */
6427 retval = create_wireless_algo_auth_cipher_operation(
6428 tdata->digest_enc.data, tdata->digest_enc.len,
6429 tdata->cipher_iv.data, tdata->cipher_iv.len,
6430 tdata->auth_iv.data, tdata->auth_iv.len,
6431 (tdata->digest_enc.offset == 0 ?
6433 : tdata->digest_enc.offset),
6434 tdata->validCipherLen.len_bits,
6435 tdata->cipher.offset_bits,
6436 tdata->validAuthLen.len_bits,
6437 tdata->auth.offset_bits,
6438 op_mode, 1, verify);
6443 op = process_crypto_request(ts_params->valid_devs[0],
6446 /* Check if the op failed because the device doesn't */
6447 /* support this particular combination of algorithms */
6448 if (op == NULL && ut_params->op->status ==
6449 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6450 printf("Device doesn't support this mixed combination. "
6457 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6459 ut_params->obuf = (op_mode == IN_PLACE ?
6460 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6463 if (ut_params->obuf)
6464 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6465 plaintext_len, buffer);
6467 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6468 plaintext_len, buffer);
6470 debug_hexdump(stdout, "plaintext:", plaintext,
6471 (tdata->plaintext.len_bits >> 3) -
6472 tdata->digest_enc.len);
6473 debug_hexdump(stdout, "plaintext expected:",
6474 tdata->plaintext.data,
6475 (tdata->plaintext.len_bits >> 3) -
6476 tdata->digest_enc.len);
6478 if (ut_params->obuf)
6479 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6480 ciphertext_len, buffer);
6482 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6483 ciphertext_len, buffer);
6485 debug_hexdump(stdout, "ciphertext:", ciphertext,
6487 debug_hexdump(stdout, "ciphertext expected:",
6488 tdata->ciphertext.data,
6489 tdata->ciphertext.len_bits >> 3);
6491 if (ut_params->obuf)
6492 digest = rte_pktmbuf_read(ut_params->obuf,
6493 (tdata->digest_enc.offset == 0 ?
6495 tdata->digest_enc.offset),
6496 tdata->digest_enc.len, digest_buffer);
6498 digest = rte_pktmbuf_read(ut_params->ibuf,
6499 (tdata->digest_enc.offset == 0 ?
6501 tdata->digest_enc.offset),
6502 tdata->digest_enc.len, digest_buffer);
6504 debug_hexdump(stdout, "digest:", digest,
6505 tdata->digest_enc.len);
6506 debug_hexdump(stdout, "digest expected:",
6507 tdata->digest_enc.data, tdata->digest_enc.len);
6512 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6514 tdata->plaintext.data,
6515 tdata->plaintext.len_bits >> 3,
6516 "Plaintext data not as expected");
6518 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6520 tdata->ciphertext.data,
6521 tdata->validDataLen.len_bits,
6522 "Ciphertext data not as expected");
6523 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6525 tdata->digest_enc.data,
6526 tdata->digest_enc.len,
6527 "Generated auth tag not as expected");
6530 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6531 "crypto op processing failed");
6536 /** AUTH AES CMAC + CIPHER AES CTR */
6539 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6541 return test_mixed_auth_cipher(
6542 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6546 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6548 return test_mixed_auth_cipher(
6549 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6553 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6555 return test_mixed_auth_cipher_sgl(
6556 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6560 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6562 return test_mixed_auth_cipher_sgl(
6563 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6567 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6569 return test_mixed_auth_cipher(
6570 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6574 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6576 return test_mixed_auth_cipher(
6577 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6581 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6583 return test_mixed_auth_cipher_sgl(
6584 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6588 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6590 return test_mixed_auth_cipher_sgl(
6591 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6594 /** MIXED AUTH + CIPHER */
6597 test_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, 0);
6604 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6606 return test_mixed_auth_cipher(
6607 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6611 test_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, 0);
6618 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6620 return test_mixed_auth_cipher(
6621 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6625 test_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, 0);
6632 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6634 return test_mixed_auth_cipher(
6635 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6639 test_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, 0);
6646 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6648 return test_mixed_auth_cipher(
6649 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6653 test_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, 0);
6660 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6662 return test_mixed_auth_cipher(
6663 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6667 test_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, 0);
6674 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6676 return test_mixed_auth_cipher(
6677 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6681 test_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, 0);
6688 test_verify_auth_null_cipher_snow_test_case_1(void)
6690 return test_mixed_auth_cipher(
6691 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6695 test_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, 0);
6702 test_verify_auth_null_cipher_zuc_test_case_1(void)
6704 return test_mixed_auth_cipher(
6705 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6709 test_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, 0);
6716 test_verify_auth_snow_cipher_null_test_case_1(void)
6718 return test_mixed_auth_cipher(
6719 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6723 test_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, 0);
6730 test_verify_auth_zuc_cipher_null_test_case_1(void)
6732 return test_mixed_auth_cipher(
6733 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6737 test_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, 0);
6744 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6746 return test_mixed_auth_cipher(
6747 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6751 test_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, 0);
6758 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6760 return test_mixed_auth_cipher(
6761 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6764 /* ***** AEAD algorithm Tests ***** */
6767 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6768 enum rte_crypto_aead_operation op,
6769 const uint8_t *key, const uint8_t key_len,
6770 const uint16_t aad_len, const uint8_t auth_len,
6773 uint8_t aead_key[key_len];
6775 struct crypto_testsuite_params *ts_params = &testsuite_params;
6776 struct crypto_unittest_params *ut_params = &unittest_params;
6778 memcpy(aead_key, key, key_len);
6780 /* Setup AEAD Parameters */
6781 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6782 ut_params->aead_xform.next = NULL;
6783 ut_params->aead_xform.aead.algo = algo;
6784 ut_params->aead_xform.aead.op = op;
6785 ut_params->aead_xform.aead.key.data = aead_key;
6786 ut_params->aead_xform.aead.key.length = key_len;
6787 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6788 ut_params->aead_xform.aead.iv.length = iv_len;
6789 ut_params->aead_xform.aead.digest_length = auth_len;
6790 ut_params->aead_xform.aead.aad_length = aad_len;
6792 debug_hexdump(stdout, "key:", key, key_len);
6794 /* Create Crypto session*/
6795 ut_params->sess = rte_cryptodev_sym_session_create(
6796 ts_params->session_mpool);
6798 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6799 &ut_params->aead_xform,
6800 ts_params->session_priv_mpool);
6802 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6808 create_aead_xform(struct rte_crypto_op *op,
6809 enum rte_crypto_aead_algorithm algo,
6810 enum rte_crypto_aead_operation aead_op,
6811 uint8_t *key, const uint8_t key_len,
6812 const uint8_t aad_len, const uint8_t auth_len,
6815 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6816 "failed to allocate space for crypto transform");
6818 struct rte_crypto_sym_op *sym_op = op->sym;
6820 /* Setup AEAD Parameters */
6821 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6822 sym_op->xform->next = NULL;
6823 sym_op->xform->aead.algo = algo;
6824 sym_op->xform->aead.op = aead_op;
6825 sym_op->xform->aead.key.data = key;
6826 sym_op->xform->aead.key.length = key_len;
6827 sym_op->xform->aead.iv.offset = IV_OFFSET;
6828 sym_op->xform->aead.iv.length = iv_len;
6829 sym_op->xform->aead.digest_length = auth_len;
6830 sym_op->xform->aead.aad_length = aad_len;
6832 debug_hexdump(stdout, "key:", key, key_len);
6838 create_aead_operation(enum rte_crypto_aead_operation op,
6839 const struct aead_test_data *tdata)
6841 struct crypto_testsuite_params *ts_params = &testsuite_params;
6842 struct crypto_unittest_params *ut_params = &unittest_params;
6844 uint8_t *plaintext, *ciphertext;
6845 unsigned int aad_pad_len, plaintext_pad_len;
6847 /* Generate Crypto op data structure */
6848 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6849 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6850 TEST_ASSERT_NOT_NULL(ut_params->op,
6851 "Failed to allocate symmetric crypto operation struct");
6853 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6855 /* Append aad data */
6856 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6857 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6858 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6860 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6861 "no room to append aad");
6863 sym_op->aead.aad.phys_addr =
6864 rte_pktmbuf_iova(ut_params->ibuf);
6865 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6866 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6867 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6870 /* Append IV at the end of the crypto operation*/
6871 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6872 uint8_t *, IV_OFFSET);
6874 /* Copy IV 1 byte after the IV pointer, according to the API */
6875 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6876 debug_hexdump(stdout, "iv:", iv_ptr,
6879 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6880 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6882 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6883 "no room to append aad");
6885 sym_op->aead.aad.phys_addr =
6886 rte_pktmbuf_iova(ut_params->ibuf);
6887 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6888 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6891 /* Append IV at the end of the crypto operation*/
6892 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6893 uint8_t *, IV_OFFSET);
6895 if (tdata->iv.len == 0) {
6896 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6897 debug_hexdump(stdout, "iv:", iv_ptr,
6900 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6901 debug_hexdump(stdout, "iv:", iv_ptr,
6906 /* Append plaintext/ciphertext */
6907 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6908 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6909 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6911 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6913 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6914 debug_hexdump(stdout, "plaintext:", plaintext,
6915 tdata->plaintext.len);
6917 if (ut_params->obuf) {
6918 ciphertext = (uint8_t *)rte_pktmbuf_append(
6920 plaintext_pad_len + aad_pad_len);
6921 TEST_ASSERT_NOT_NULL(ciphertext,
6922 "no room to append ciphertext");
6924 memset(ciphertext + aad_pad_len, 0,
6925 tdata->ciphertext.len);
6928 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6929 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6931 TEST_ASSERT_NOT_NULL(ciphertext,
6932 "no room to append ciphertext");
6934 memcpy(ciphertext, tdata->ciphertext.data,
6935 tdata->ciphertext.len);
6936 debug_hexdump(stdout, "ciphertext:", ciphertext,
6937 tdata->ciphertext.len);
6939 if (ut_params->obuf) {
6940 plaintext = (uint8_t *)rte_pktmbuf_append(
6942 plaintext_pad_len + aad_pad_len);
6943 TEST_ASSERT_NOT_NULL(plaintext,
6944 "no room to append plaintext");
6946 memset(plaintext + aad_pad_len, 0,
6947 tdata->plaintext.len);
6951 /* Append digest data */
6952 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6953 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6954 ut_params->obuf ? ut_params->obuf :
6956 tdata->auth_tag.len);
6957 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6958 "no room to append digest");
6959 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6960 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6961 ut_params->obuf ? ut_params->obuf :
6966 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6967 ut_params->ibuf, tdata->auth_tag.len);
6968 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6969 "no room to append digest");
6970 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6972 plaintext_pad_len + aad_pad_len);
6974 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6975 tdata->auth_tag.len);
6976 debug_hexdump(stdout, "digest:",
6977 sym_op->aead.digest.data,
6978 tdata->auth_tag.len);
6981 sym_op->aead.data.length = tdata->plaintext.len;
6982 sym_op->aead.data.offset = aad_pad_len;
6988 test_authenticated_encryption(const struct aead_test_data *tdata)
6990 struct crypto_testsuite_params *ts_params = &testsuite_params;
6991 struct crypto_unittest_params *ut_params = &unittest_params;
6994 uint8_t *ciphertext, *auth_tag;
6995 uint16_t plaintext_pad_len;
6998 /* Verify the capabilities */
6999 struct rte_cryptodev_sym_capability_idx cap_idx;
7000 const struct rte_cryptodev_symmetric_capability *capability;
7001 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7002 cap_idx.algo.aead = tdata->algo;
7003 capability = rte_cryptodev_sym_capability_get(
7004 ts_params->valid_devs[0], &cap_idx);
7005 if (capability == NULL)
7007 if (rte_cryptodev_sym_capability_check_aead(
7008 capability, tdata->key.len, tdata->auth_tag.len,
7009 tdata->aad.len, tdata->iv.len))
7012 /* Create AEAD session */
7013 retval = create_aead_session(ts_params->valid_devs[0],
7015 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7016 tdata->key.data, tdata->key.len,
7017 tdata->aad.len, tdata->auth_tag.len,
7022 if (tdata->aad.len > MBUF_SIZE) {
7023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7024 /* Populate full size of add data */
7025 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7026 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7030 /* clear mbuf payload */
7031 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7032 rte_pktmbuf_tailroom(ut_params->ibuf));
7034 /* Create AEAD operation */
7035 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7039 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7041 ut_params->op->sym->m_src = ut_params->ibuf;
7043 /* Process crypto operation */
7044 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7045 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7047 TEST_ASSERT_NOT_NULL(
7048 process_crypto_request(ts_params->valid_devs[0],
7049 ut_params->op), "failed to process sym crypto op");
7051 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7052 "crypto op processing failed");
7054 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7056 if (ut_params->op->sym->m_dst) {
7057 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7059 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7060 uint8_t *, plaintext_pad_len);
7062 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7064 ut_params->op->sym->cipher.data.offset);
7065 auth_tag = ciphertext + plaintext_pad_len;
7068 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7069 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7072 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7074 tdata->ciphertext.data,
7075 tdata->ciphertext.len,
7076 "Ciphertext data not as expected");
7078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7080 tdata->auth_tag.data,
7081 tdata->auth_tag.len,
7082 "Generated auth tag not as expected");
7088 #ifdef RTE_LIBRTE_SECURITY
7090 security_proto_supported(enum rte_security_session_action_type action,
7091 enum rte_security_session_protocol proto)
7093 struct crypto_testsuite_params *ts_params = &testsuite_params;
7095 const struct rte_security_capability *capabilities;
7096 const struct rte_security_capability *capability;
7099 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7100 rte_cryptodev_get_sec_ctx(
7101 ts_params->valid_devs[0]);
7104 capabilities = rte_security_capabilities_get(ctx);
7106 if (capabilities == NULL)
7109 while ((capability = &capabilities[i++])->action !=
7110 RTE_SECURITY_ACTION_TYPE_NONE) {
7111 if (capability->action == action &&
7112 capability->protocol == proto)
7119 /* Basic algorithm run function for async inplace mode.
7120 * Creates a session from input parameters and runs one operation
7121 * on input_vec. Checks the output of the crypto operation against
7125 test_pdcp_proto(int i, int oop,
7126 enum rte_crypto_cipher_operation opc,
7127 enum rte_crypto_auth_operation opa,
7129 unsigned int input_vec_len,
7130 uint8_t *output_vec,
7131 unsigned int output_vec_len)
7133 struct crypto_testsuite_params *ts_params = &testsuite_params;
7134 struct crypto_unittest_params *ut_params = &unittest_params;
7136 int ret = TEST_SUCCESS;
7137 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7138 rte_cryptodev_get_sec_ctx(
7139 ts_params->valid_devs[0]);
7141 /* Verify the capabilities */
7142 struct rte_security_capability_idx sec_cap_idx;
7144 sec_cap_idx.action = ut_params->type;
7145 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7146 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7147 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7150 /* Generate test mbuf data */
7151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7153 /* clear mbuf payload */
7154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7155 rte_pktmbuf_tailroom(ut_params->ibuf));
7157 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7159 memcpy(plaintext, input_vec, input_vec_len);
7161 /* Out of place support */
7164 * For out-op-place we need to alloc another mbuf
7166 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7167 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7170 /* Setup Cipher Parameters */
7171 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7172 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7173 ut_params->cipher_xform.cipher.op = opc;
7174 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7175 ut_params->cipher_xform.cipher.key.length =
7176 pdcp_test_params[i].cipher_key_len;
7177 ut_params->cipher_xform.cipher.iv.length =
7178 pdcp_test_packet_direction[i] ? 4 : 0;
7179 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7181 /* Setup HMAC Parameters if ICV header is required */
7182 if (pdcp_test_params[i].auth_alg != 0) {
7183 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7184 ut_params->auth_xform.next = NULL;
7185 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7186 ut_params->auth_xform.auth.op = opa;
7187 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7188 ut_params->auth_xform.auth.key.length =
7189 pdcp_test_params[i].auth_key_len;
7191 ut_params->cipher_xform.next = &ut_params->auth_xform;
7193 ut_params->cipher_xform.next = NULL;
7196 struct rte_security_session_conf sess_conf = {
7197 .action_type = ut_params->type,
7198 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7200 .bearer = pdcp_test_bearer[i],
7201 .domain = pdcp_test_params[i].domain,
7202 .pkt_dir = pdcp_test_packet_direction[i],
7203 .sn_size = pdcp_test_data_sn_size[i],
7204 .hfn = pdcp_test_packet_direction[i] ?
7205 0 : pdcp_test_hfn[i],
7207 * hfn can be set as pdcp_test_hfn[i]
7208 * if hfn_ovrd is not set. Here, PDCP
7209 * packet direction is just used to
7210 * run half of the cases with session
7211 * HFN and other half with per packet
7214 .hfn_threshold = pdcp_test_hfn_threshold[i],
7215 .hfn_ovrd = pdcp_test_packet_direction[i] ? 1 : 0,
7217 .crypto_xform = &ut_params->cipher_xform
7220 /* Create security session */
7221 ut_params->sec_session = rte_security_session_create(ctx,
7222 &sess_conf, ts_params->session_priv_mpool);
7224 if (!ut_params->sec_session) {
7225 printf("TestCase %s()-%d line %d failed %s: ",
7226 __func__, i, __LINE__, "Failed to allocate session");
7231 /* Generate crypto op data structure */
7232 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7233 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7234 if (!ut_params->op) {
7235 printf("TestCase %s()-%d line %d failed %s: ",
7236 __func__, i, __LINE__,
7237 "Failed to allocate symmetric crypto operation struct");
7242 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7243 uint32_t *, IV_OFFSET);
7244 *per_pkt_hfn = pdcp_test_packet_direction[i] ? pdcp_test_hfn[i] : 0;
7246 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7248 /* set crypto operation source mbuf */
7249 ut_params->op->sym->m_src = ut_params->ibuf;
7251 ut_params->op->sym->m_dst = ut_params->obuf;
7253 /* Process crypto operation */
7254 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7256 printf("TestCase %s()-%d line %d failed %s: ",
7257 __func__, i, __LINE__,
7258 "failed to process sym crypto op");
7263 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7264 printf("TestCase %s()-%d line %d failed %s: ",
7265 __func__, i, __LINE__, "crypto op processing failed");
7271 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7274 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7278 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7279 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7280 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7281 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7287 rte_crypto_op_free(ut_params->op);
7288 ut_params->op = NULL;
7290 if (ut_params->sec_session)
7291 rte_security_session_destroy(ctx, ut_params->sec_session);
7292 ut_params->sec_session = NULL;
7294 rte_pktmbuf_free(ut_params->ibuf);
7295 ut_params->ibuf = NULL;
7297 rte_pktmbuf_free(ut_params->obuf);
7298 ut_params->obuf = NULL;
7305 test_pdcp_proto_SGL(int i, int oop,
7306 enum rte_crypto_cipher_operation opc,
7307 enum rte_crypto_auth_operation opa,
7309 unsigned int input_vec_len,
7310 uint8_t *output_vec,
7311 unsigned int output_vec_len,
7313 uint32_t fragsz_oop)
7315 struct crypto_testsuite_params *ts_params = &testsuite_params;
7316 struct crypto_unittest_params *ut_params = &unittest_params;
7318 struct rte_mbuf *buf, *buf_oop = NULL;
7319 int ret = TEST_SUCCESS;
7323 unsigned int trn_data = 0;
7324 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7325 rte_cryptodev_get_sec_ctx(
7326 ts_params->valid_devs[0]);
7328 /* Verify the capabilities */
7329 struct rte_security_capability_idx sec_cap_idx;
7331 sec_cap_idx.action = ut_params->type;
7332 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7333 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7334 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7337 if (fragsz > input_vec_len)
7338 fragsz = input_vec_len;
7340 uint16_t plaintext_len = fragsz;
7341 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7343 if (fragsz_oop > output_vec_len)
7344 frag_size_oop = output_vec_len;
7347 if (input_vec_len % fragsz != 0) {
7348 if (input_vec_len / fragsz + 1 > 16)
7350 } else if (input_vec_len / fragsz > 16)
7353 /* Out of place support */
7356 * For out-op-place we need to alloc another mbuf
7358 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7359 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7360 buf_oop = ut_params->obuf;
7363 /* Generate test mbuf data */
7364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7366 /* clear mbuf payload */
7367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7368 rte_pktmbuf_tailroom(ut_params->ibuf));
7370 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7372 memcpy(plaintext, input_vec, plaintext_len);
7373 trn_data += plaintext_len;
7375 buf = ut_params->ibuf;
7378 * Loop until no more fragments
7381 while (trn_data < input_vec_len) {
7383 to_trn = (input_vec_len - trn_data < fragsz) ?
7384 (input_vec_len - trn_data) : fragsz;
7386 to_trn_tbl[ecx++] = to_trn;
7388 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7391 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7392 rte_pktmbuf_tailroom(buf));
7395 if (oop && !fragsz_oop) {
7397 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7398 buf_oop = buf_oop->next;
7399 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7400 0, rte_pktmbuf_tailroom(buf_oop));
7401 rte_pktmbuf_append(buf_oop, to_trn);
7404 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7407 memcpy(plaintext, input_vec + trn_data, to_trn);
7411 ut_params->ibuf->nb_segs = segs;
7414 if (fragsz_oop && oop) {
7418 trn_data = frag_size_oop;
7419 while (trn_data < output_vec_len) {
7422 (output_vec_len - trn_data <
7424 (output_vec_len - trn_data) :
7427 to_trn_tbl[ecx++] = to_trn;
7430 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7431 buf_oop = buf_oop->next;
7432 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7433 0, rte_pktmbuf_tailroom(buf_oop));
7434 rte_pktmbuf_append(buf_oop, to_trn);
7438 ut_params->obuf->nb_segs = segs;
7441 /* Setup Cipher Parameters */
7442 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7443 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7444 ut_params->cipher_xform.cipher.op = opc;
7445 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7446 ut_params->cipher_xform.cipher.key.length =
7447 pdcp_test_params[i].cipher_key_len;
7448 ut_params->cipher_xform.cipher.iv.length = 0;
7450 /* Setup HMAC Parameters if ICV header is required */
7451 if (pdcp_test_params[i].auth_alg != 0) {
7452 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7453 ut_params->auth_xform.next = NULL;
7454 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7455 ut_params->auth_xform.auth.op = opa;
7456 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7457 ut_params->auth_xform.auth.key.length =
7458 pdcp_test_params[i].auth_key_len;
7460 ut_params->cipher_xform.next = &ut_params->auth_xform;
7462 ut_params->cipher_xform.next = NULL;
7465 struct rte_security_session_conf sess_conf = {
7466 .action_type = ut_params->type,
7467 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7469 .bearer = pdcp_test_bearer[i],
7470 .domain = pdcp_test_params[i].domain,
7471 .pkt_dir = pdcp_test_packet_direction[i],
7472 .sn_size = pdcp_test_data_sn_size[i],
7473 .hfn = pdcp_test_hfn[i],
7474 .hfn_threshold = pdcp_test_hfn_threshold[i],
7477 .crypto_xform = &ut_params->cipher_xform
7480 /* Create security session */
7481 ut_params->sec_session = rte_security_session_create(ctx,
7482 &sess_conf, ts_params->session_priv_mpool);
7484 if (!ut_params->sec_session) {
7485 printf("TestCase %s()-%d line %d failed %s: ",
7486 __func__, i, __LINE__, "Failed to allocate session");
7491 /* Generate crypto op data structure */
7492 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7493 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7494 if (!ut_params->op) {
7495 printf("TestCase %s()-%d line %d failed %s: ",
7496 __func__, i, __LINE__,
7497 "Failed to allocate symmetric crypto operation struct");
7502 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7504 /* set crypto operation source mbuf */
7505 ut_params->op->sym->m_src = ut_params->ibuf;
7507 ut_params->op->sym->m_dst = ut_params->obuf;
7509 /* Process crypto operation */
7510 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7512 printf("TestCase %s()-%d line %d failed %s: ",
7513 __func__, i, __LINE__,
7514 "failed to process sym crypto op");
7519 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7520 printf("TestCase %s()-%d line %d failed %s: ",
7521 __func__, i, __LINE__, "crypto op processing failed");
7527 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7530 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7534 fragsz = frag_size_oop;
7535 if (memcmp(ciphertext, output_vec, fragsz)) {
7536 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7537 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7538 rte_hexdump(stdout, "reference", output_vec, fragsz);
7543 buf = ut_params->op->sym->m_src->next;
7545 buf = ut_params->op->sym->m_dst->next;
7547 unsigned int off = fragsz;
7551 ciphertext = rte_pktmbuf_mtod(buf,
7553 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7554 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7555 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7556 rte_hexdump(stdout, "reference", output_vec + off,
7561 off += to_trn_tbl[ecx++];
7565 rte_crypto_op_free(ut_params->op);
7566 ut_params->op = NULL;
7568 if (ut_params->sec_session)
7569 rte_security_session_destroy(ctx, ut_params->sec_session);
7570 ut_params->sec_session = NULL;
7572 rte_pktmbuf_free(ut_params->ibuf);
7573 ut_params->ibuf = NULL;
7575 rte_pktmbuf_free(ut_params->obuf);
7576 ut_params->obuf = NULL;
7583 test_pdcp_proto_cplane_encap(int i)
7585 return test_pdcp_proto(i, 0,
7586 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7587 RTE_CRYPTO_AUTH_OP_GENERATE,
7588 pdcp_test_data_in[i],
7589 pdcp_test_data_in_len[i],
7590 pdcp_test_data_out[i],
7591 pdcp_test_data_in_len[i]+4);
7595 test_pdcp_proto_uplane_encap(int i)
7597 return test_pdcp_proto(i, 0,
7598 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7599 RTE_CRYPTO_AUTH_OP_GENERATE,
7600 pdcp_test_data_in[i],
7601 pdcp_test_data_in_len[i],
7602 pdcp_test_data_out[i],
7603 pdcp_test_data_in_len[i]);
7608 test_pdcp_proto_uplane_encap_with_int(int i)
7610 return test_pdcp_proto(i, 0,
7611 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7612 RTE_CRYPTO_AUTH_OP_GENERATE,
7613 pdcp_test_data_in[i],
7614 pdcp_test_data_in_len[i],
7615 pdcp_test_data_out[i],
7616 pdcp_test_data_in_len[i] + 4);
7620 test_pdcp_proto_cplane_decap(int i)
7622 return test_pdcp_proto(i, 0,
7623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7624 RTE_CRYPTO_AUTH_OP_VERIFY,
7625 pdcp_test_data_out[i],
7626 pdcp_test_data_in_len[i] + 4,
7627 pdcp_test_data_in[i],
7628 pdcp_test_data_in_len[i]);
7632 test_pdcp_proto_uplane_decap(int i)
7634 return test_pdcp_proto(i, 0,
7635 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7636 RTE_CRYPTO_AUTH_OP_VERIFY,
7637 pdcp_test_data_out[i],
7638 pdcp_test_data_in_len[i],
7639 pdcp_test_data_in[i],
7640 pdcp_test_data_in_len[i]);
7644 test_pdcp_proto_uplane_decap_with_int(int i)
7646 return test_pdcp_proto(i, 0,
7647 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7648 RTE_CRYPTO_AUTH_OP_VERIFY,
7649 pdcp_test_data_out[i],
7650 pdcp_test_data_in_len[i] + 4,
7651 pdcp_test_data_in[i],
7652 pdcp_test_data_in_len[i]);
7656 test_PDCP_PROTO_SGL_in_place_32B(void)
7658 /* i can be used for running any PDCP case
7659 * In this case it is uplane 12-bit AES-SNOW DL encap
7661 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7662 return test_pdcp_proto_SGL(i, IN_PLACE,
7663 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 RTE_CRYPTO_AUTH_OP_GENERATE,
7665 pdcp_test_data_in[i],
7666 pdcp_test_data_in_len[i],
7667 pdcp_test_data_out[i],
7668 pdcp_test_data_in_len[i]+4,
7672 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7674 /* i can be used for running any PDCP case
7675 * In this case it is uplane 18-bit NULL-NULL DL encap
7677 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7678 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7679 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7680 RTE_CRYPTO_AUTH_OP_GENERATE,
7681 pdcp_test_data_in[i],
7682 pdcp_test_data_in_len[i],
7683 pdcp_test_data_out[i],
7684 pdcp_test_data_in_len[i]+4,
7688 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7690 /* i can be used for running any PDCP case
7691 * In this case it is uplane 18-bit AES DL encap
7693 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7695 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7697 RTE_CRYPTO_AUTH_OP_GENERATE,
7698 pdcp_test_data_in[i],
7699 pdcp_test_data_in_len[i],
7700 pdcp_test_data_out[i],
7701 pdcp_test_data_in_len[i],
7705 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7707 /* i can be used for running any PDCP case
7708 * In this case it is cplane 12-bit AES-ZUC DL encap
7710 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7711 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7712 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7713 RTE_CRYPTO_AUTH_OP_GENERATE,
7714 pdcp_test_data_in[i],
7715 pdcp_test_data_in_len[i],
7716 pdcp_test_data_out[i],
7717 pdcp_test_data_in_len[i]+4,
7722 test_PDCP_PROTO_all(void)
7724 struct crypto_testsuite_params *ts_params = &testsuite_params;
7725 struct crypto_unittest_params *ut_params = &unittest_params;
7726 struct rte_cryptodev_info dev_info;
7729 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7730 uint64_t feat_flags = dev_info.feature_flags;
7732 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7735 /* Set action type */
7736 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
7737 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
7740 if (security_proto_supported(ut_params->type,
7741 RTE_SECURITY_PROTOCOL_PDCP) < 0)
7744 status = test_PDCP_PROTO_cplane_encap_all();
7745 status += test_PDCP_PROTO_cplane_decap_all();
7746 status += test_PDCP_PROTO_uplane_encap_all();
7747 status += test_PDCP_PROTO_uplane_decap_all();
7748 status += test_PDCP_PROTO_SGL_in_place_32B();
7749 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7750 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7751 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7756 return TEST_SUCCESS;
7760 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
7762 struct crypto_testsuite_params *ts_params = &testsuite_params;
7763 struct crypto_unittest_params *ut_params = &unittest_params;
7764 uint8_t *plaintext, *ciphertext;
7766 int32_t cipher_len, crc_len;
7767 uint32_t crc_data_len;
7768 int ret = TEST_SUCCESS;
7770 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7771 rte_cryptodev_get_sec_ctx(
7772 ts_params->valid_devs[0]);
7774 /* Verify the capabilities */
7775 struct rte_security_capability_idx sec_cap_idx;
7776 const struct rte_security_capability *sec_cap;
7777 const struct rte_cryptodev_capabilities *crypto_cap;
7778 const struct rte_cryptodev_symmetric_capability *sym_cap;
7781 sec_cap_idx.action = ut_params->type;
7782 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7783 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
7785 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7786 if (sec_cap == NULL)
7789 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7790 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7791 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7792 crypto_cap->sym.xform_type ==
7793 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7794 crypto_cap->sym.cipher.algo ==
7795 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7796 sym_cap = &crypto_cap->sym;
7797 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7804 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7807 /* Setup source mbuf payload */
7808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7809 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7810 rte_pktmbuf_tailroom(ut_params->ibuf));
7812 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7813 d_td->ciphertext.len);
7815 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
7817 /* Setup cipher session parameters */
7818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7819 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
7820 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
7821 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
7822 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
7823 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
7824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7825 ut_params->cipher_xform.next = NULL;
7827 /* Setup DOCSIS session parameters */
7828 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
7830 struct rte_security_session_conf sess_conf = {
7831 .action_type = ut_params->type,
7832 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
7833 .docsis = ut_params->docsis_xform,
7834 .crypto_xform = &ut_params->cipher_xform,
7837 /* Create security session */
7838 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
7839 ts_params->session_priv_mpool);
7841 if (!ut_params->sec_session) {
7842 printf("TestCase %s(%d) line %d: %s\n",
7843 __func__, i, __LINE__, "failed to allocate session");
7848 /* Generate crypto op data structure */
7849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7851 if (!ut_params->op) {
7852 printf("TestCase %s(%d) line %d: %s\n",
7853 __func__, i, __LINE__,
7854 "failed to allocate symmetric crypto operation");
7859 /* Setup CRC operation parameters */
7860 crc_len = d_td->ciphertext.no_crc == false ?
7861 (d_td->ciphertext.len -
7862 d_td->ciphertext.crc_offset -
7863 RTE_ETHER_CRC_LEN) :
7865 crc_len = crc_len > 0 ? crc_len : 0;
7866 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
7867 ut_params->op->sym->auth.data.length = crc_len;
7868 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
7870 /* Setup cipher operation parameters */
7871 cipher_len = d_td->ciphertext.no_cipher == false ?
7872 (d_td->ciphertext.len -
7873 d_td->ciphertext.cipher_offset) :
7875 cipher_len = cipher_len > 0 ? cipher_len : 0;
7876 ut_params->op->sym->cipher.data.length = cipher_len;
7877 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
7879 /* Setup cipher IV */
7880 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
7881 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
7883 /* Attach session to operation */
7884 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7886 /* Set crypto operation mbufs */
7887 ut_params->op->sym->m_src = ut_params->ibuf;
7888 ut_params->op->sym->m_dst = NULL;
7890 /* Process crypto operation */
7891 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
7893 printf("TestCase %s(%d) line %d: %s\n",
7894 __func__, i, __LINE__,
7895 "failed to process security crypto op");
7900 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7901 printf("TestCase %s(%d) line %d: %s\n",
7902 __func__, i, __LINE__, "crypto op processing failed");
7907 /* Validate plaintext */
7908 plaintext = ciphertext;
7910 if (memcmp(plaintext, d_td->plaintext.data,
7911 d_td->plaintext.len - crc_data_len)) {
7912 printf("TestCase %s(%d) line %d: %s\n",
7913 __func__, i, __LINE__, "plaintext not as expected\n");
7914 rte_hexdump(stdout, "expected", d_td->plaintext.data,
7915 d_td->plaintext.len);
7916 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
7922 rte_crypto_op_free(ut_params->op);
7923 ut_params->op = NULL;
7925 if (ut_params->sec_session)
7926 rte_security_session_destroy(ctx, ut_params->sec_session);
7927 ut_params->sec_session = NULL;
7929 rte_pktmbuf_free(ut_params->ibuf);
7930 ut_params->ibuf = NULL;
7936 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
7938 struct crypto_testsuite_params *ts_params = &testsuite_params;
7939 struct crypto_unittest_params *ut_params = &unittest_params;
7940 uint8_t *plaintext, *ciphertext;
7942 int32_t cipher_len, crc_len;
7943 int ret = TEST_SUCCESS;
7945 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7946 rte_cryptodev_get_sec_ctx(
7947 ts_params->valid_devs[0]);
7949 /* Verify the capabilities */
7950 struct rte_security_capability_idx sec_cap_idx;
7951 const struct rte_security_capability *sec_cap;
7952 const struct rte_cryptodev_capabilities *crypto_cap;
7953 const struct rte_cryptodev_symmetric_capability *sym_cap;
7956 sec_cap_idx.action = ut_params->type;
7957 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7958 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
7960 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7961 if (sec_cap == NULL)
7964 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7965 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7966 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7967 crypto_cap->sym.xform_type ==
7968 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7969 crypto_cap->sym.cipher.algo ==
7970 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7971 sym_cap = &crypto_cap->sym;
7972 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7979 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7982 /* Setup source mbuf payload */
7983 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7985 rte_pktmbuf_tailroom(ut_params->ibuf));
7987 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7988 d_td->plaintext.len);
7990 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
7992 /* Setup cipher session parameters */
7993 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7994 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
7995 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7996 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
7997 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
7998 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
7999 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8000 ut_params->cipher_xform.next = NULL;
8002 /* Setup DOCSIS session parameters */
8003 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8005 struct rte_security_session_conf sess_conf = {
8006 .action_type = ut_params->type,
8007 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8008 .docsis = ut_params->docsis_xform,
8009 .crypto_xform = &ut_params->cipher_xform,
8012 /* Create security session */
8013 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8014 ts_params->session_priv_mpool);
8016 if (!ut_params->sec_session) {
8017 printf("TestCase %s(%d) line %d: %s\n",
8018 __func__, i, __LINE__, "failed to allocate session");
8023 /* Generate crypto op data structure */
8024 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8025 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8026 if (!ut_params->op) {
8027 printf("TestCase %s(%d) line %d: %s\n",
8028 __func__, i, __LINE__,
8029 "failed to allocate security crypto operation");
8034 /* Setup CRC operation parameters */
8035 crc_len = d_td->plaintext.no_crc == false ?
8036 (d_td->plaintext.len -
8037 d_td->plaintext.crc_offset -
8038 RTE_ETHER_CRC_LEN) :
8040 crc_len = crc_len > 0 ? crc_len : 0;
8041 ut_params->op->sym->auth.data.length = crc_len;
8042 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8044 /* Setup cipher operation parameters */
8045 cipher_len = d_td->plaintext.no_cipher == false ?
8046 (d_td->plaintext.len -
8047 d_td->plaintext.cipher_offset) :
8049 cipher_len = cipher_len > 0 ? cipher_len : 0;
8050 ut_params->op->sym->cipher.data.length = cipher_len;
8051 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8053 /* Setup cipher IV */
8054 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8055 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8057 /* Attach session to operation */
8058 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8060 /* Set crypto operation mbufs */
8061 ut_params->op->sym->m_src = ut_params->ibuf;
8062 ut_params->op->sym->m_dst = NULL;
8064 /* Process crypto operation */
8065 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8067 printf("TestCase %s(%d) line %d: %s\n",
8068 __func__, i, __LINE__,
8069 "failed to process security crypto op");
8074 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8075 printf("TestCase %s(%d) line %d: %s\n",
8076 __func__, i, __LINE__, "crypto op processing failed");
8081 /* Validate ciphertext */
8082 ciphertext = plaintext;
8084 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8085 printf("TestCase %s(%d) line %d: %s\n",
8086 __func__, i, __LINE__, "ciphertext not as expected\n");
8087 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8088 d_td->ciphertext.len);
8089 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8095 rte_crypto_op_free(ut_params->op);
8096 ut_params->op = NULL;
8098 if (ut_params->sec_session)
8099 rte_security_session_destroy(ctx, ut_params->sec_session);
8100 ut_params->sec_session = NULL;
8102 rte_pktmbuf_free(ut_params->ibuf);
8103 ut_params->ibuf = NULL;
8108 #define TEST_DOCSIS_COUNT(func) do { \
8110 if (ret == TEST_SUCCESS) { \
8111 printf("\t%2d)", n++); \
8112 printf("+++++ PASSED:" #func"\n"); \
8114 } else if (ret == -ENOTSUP) { \
8115 printf("\t%2d)", n++); \
8116 printf("~~~~~ UNSUPP:" #func"\n"); \
8119 printf("\t%2d)", n++); \
8120 printf("----- FAILED:" #func"\n"); \
8126 test_DOCSIS_PROTO_uplink_all(void)
8128 int p = 0, u = 0, f = 0, n = 0;
8130 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8131 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8132 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8133 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8134 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8135 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8136 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8137 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8138 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8139 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8140 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8141 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8142 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8143 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8144 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8145 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8146 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8147 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8148 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8149 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8150 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8151 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8152 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8153 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8154 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8155 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8158 printf("## %s: %d passed out of %d (%d unsupported)\n",
8165 test_DOCSIS_PROTO_downlink_all(void)
8167 int p = 0, u = 0, f = 0, n = 0;
8169 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8170 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8171 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8172 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8173 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8174 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8175 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8176 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8177 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8178 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8179 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8180 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8181 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8182 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8183 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8184 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8185 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8186 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8187 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8188 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8189 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8190 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8191 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8192 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8193 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8194 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8197 printf("## %s: %d passed out of %d (%d unsupported)\n",
8204 test_DOCSIS_PROTO_all(void)
8206 struct crypto_testsuite_params *ts_params = &testsuite_params;
8207 struct crypto_unittest_params *ut_params = &unittest_params;
8208 struct rte_cryptodev_info dev_info;
8211 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8212 uint64_t feat_flags = dev_info.feature_flags;
8214 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8217 /* Set action type */
8218 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8219 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8222 if (security_proto_supported(ut_params->type,
8223 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8226 status = test_DOCSIS_PROTO_uplink_all();
8227 status += test_DOCSIS_PROTO_downlink_all();
8232 return TEST_SUCCESS;
8237 test_AES_GCM_authenticated_encryption_test_case_1(void)
8239 return test_authenticated_encryption(&gcm_test_case_1);
8243 test_AES_GCM_authenticated_encryption_test_case_2(void)
8245 return test_authenticated_encryption(&gcm_test_case_2);
8249 test_AES_GCM_authenticated_encryption_test_case_3(void)
8251 return test_authenticated_encryption(&gcm_test_case_3);
8255 test_AES_GCM_authenticated_encryption_test_case_4(void)
8257 return test_authenticated_encryption(&gcm_test_case_4);
8261 test_AES_GCM_authenticated_encryption_test_case_5(void)
8263 return test_authenticated_encryption(&gcm_test_case_5);
8267 test_AES_GCM_authenticated_encryption_test_case_6(void)
8269 return test_authenticated_encryption(&gcm_test_case_6);
8273 test_AES_GCM_authenticated_encryption_test_case_7(void)
8275 return test_authenticated_encryption(&gcm_test_case_7);
8279 test_AES_GCM_authenticated_encryption_test_case_8(void)
8281 return test_authenticated_encryption(&gcm_test_case_8);
8285 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8287 return test_authenticated_encryption(&gcm_J0_test_case_1);
8291 test_AES_GCM_auth_encryption_test_case_192_1(void)
8293 return test_authenticated_encryption(&gcm_test_case_192_1);
8297 test_AES_GCM_auth_encryption_test_case_192_2(void)
8299 return test_authenticated_encryption(&gcm_test_case_192_2);
8303 test_AES_GCM_auth_encryption_test_case_192_3(void)
8305 return test_authenticated_encryption(&gcm_test_case_192_3);
8309 test_AES_GCM_auth_encryption_test_case_192_4(void)
8311 return test_authenticated_encryption(&gcm_test_case_192_4);
8315 test_AES_GCM_auth_encryption_test_case_192_5(void)
8317 return test_authenticated_encryption(&gcm_test_case_192_5);
8321 test_AES_GCM_auth_encryption_test_case_192_6(void)
8323 return test_authenticated_encryption(&gcm_test_case_192_6);
8327 test_AES_GCM_auth_encryption_test_case_192_7(void)
8329 return test_authenticated_encryption(&gcm_test_case_192_7);
8333 test_AES_GCM_auth_encryption_test_case_256_1(void)
8335 return test_authenticated_encryption(&gcm_test_case_256_1);
8339 test_AES_GCM_auth_encryption_test_case_256_2(void)
8341 return test_authenticated_encryption(&gcm_test_case_256_2);
8345 test_AES_GCM_auth_encryption_test_case_256_3(void)
8347 return test_authenticated_encryption(&gcm_test_case_256_3);
8351 test_AES_GCM_auth_encryption_test_case_256_4(void)
8353 return test_authenticated_encryption(&gcm_test_case_256_4);
8357 test_AES_GCM_auth_encryption_test_case_256_5(void)
8359 return test_authenticated_encryption(&gcm_test_case_256_5);
8363 test_AES_GCM_auth_encryption_test_case_256_6(void)
8365 return test_authenticated_encryption(&gcm_test_case_256_6);
8369 test_AES_GCM_auth_encryption_test_case_256_7(void)
8371 return test_authenticated_encryption(&gcm_test_case_256_7);
8375 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8377 return test_authenticated_encryption(&gcm_test_case_aad_1);
8381 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8383 return test_authenticated_encryption(&gcm_test_case_aad_2);
8387 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8389 struct aead_test_data tdata;
8392 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8393 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8394 tdata.iv.data[0] += 1;
8395 res = test_authenticated_encryption(&tdata);
8396 if (res == -ENOTSUP)
8398 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8399 return TEST_SUCCESS;
8403 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8405 struct aead_test_data tdata;
8408 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8409 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8410 tdata.plaintext.data[0] += 1;
8411 res = test_authenticated_encryption(&tdata);
8412 if (res == -ENOTSUP)
8414 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8415 return TEST_SUCCESS;
8419 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8421 struct aead_test_data tdata;
8424 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8425 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8426 tdata.ciphertext.data[0] += 1;
8427 res = test_authenticated_encryption(&tdata);
8428 if (res == -ENOTSUP)
8430 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8431 return TEST_SUCCESS;
8435 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8437 struct aead_test_data tdata;
8440 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8441 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8443 res = test_authenticated_encryption(&tdata);
8444 if (res == -ENOTSUP)
8446 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8447 return TEST_SUCCESS;
8451 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8453 struct aead_test_data tdata;
8454 uint8_t aad[gcm_test_case_7.aad.len];
8457 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8458 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8459 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8461 tdata.aad.data = aad;
8462 res = test_authenticated_encryption(&tdata);
8463 if (res == -ENOTSUP)
8465 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8466 return TEST_SUCCESS;
8470 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8472 struct aead_test_data tdata;
8475 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8476 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8477 tdata.auth_tag.data[0] += 1;
8478 res = test_authenticated_encryption(&tdata);
8479 if (res == -ENOTSUP)
8481 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8482 return TEST_SUCCESS;
8486 test_authenticated_decryption(const struct aead_test_data *tdata)
8488 struct crypto_testsuite_params *ts_params = &testsuite_params;
8489 struct crypto_unittest_params *ut_params = &unittest_params;
8495 /* Verify the capabilities */
8496 struct rte_cryptodev_sym_capability_idx cap_idx;
8497 const struct rte_cryptodev_symmetric_capability *capability;
8498 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8499 cap_idx.algo.aead = tdata->algo;
8500 capability = rte_cryptodev_sym_capability_get(
8501 ts_params->valid_devs[0], &cap_idx);
8502 if (capability == NULL)
8504 if (rte_cryptodev_sym_capability_check_aead(
8505 capability, tdata->key.len, tdata->auth_tag.len,
8506 tdata->aad.len, tdata->iv.len))
8509 /* Create AEAD session */
8510 retval = create_aead_session(ts_params->valid_devs[0],
8512 RTE_CRYPTO_AEAD_OP_DECRYPT,
8513 tdata->key.data, tdata->key.len,
8514 tdata->aad.len, tdata->auth_tag.len,
8519 /* alloc mbuf and set payload */
8520 if (tdata->aad.len > MBUF_SIZE) {
8521 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8522 /* Populate full size of add data */
8523 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8524 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8526 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8528 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8529 rte_pktmbuf_tailroom(ut_params->ibuf));
8531 /* Create AEAD operation */
8532 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8536 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8538 ut_params->op->sym->m_src = ut_params->ibuf;
8540 /* Process crypto operation */
8541 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8542 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8544 TEST_ASSERT_NOT_NULL(
8545 process_crypto_request(ts_params->valid_devs[0],
8546 ut_params->op), "failed to process sym crypto op");
8548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8549 "crypto op processing failed");
8551 if (ut_params->op->sym->m_dst)
8552 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8555 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8557 ut_params->op->sym->cipher.data.offset);
8559 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8562 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8564 tdata->plaintext.data,
8565 tdata->plaintext.len,
8566 "Plaintext data not as expected");
8568 TEST_ASSERT_EQUAL(ut_params->op->status,
8569 RTE_CRYPTO_OP_STATUS_SUCCESS,
8570 "Authentication failed");
8576 test_AES_GCM_authenticated_decryption_test_case_1(void)
8578 return test_authenticated_decryption(&gcm_test_case_1);
8582 test_AES_GCM_authenticated_decryption_test_case_2(void)
8584 return test_authenticated_decryption(&gcm_test_case_2);
8588 test_AES_GCM_authenticated_decryption_test_case_3(void)
8590 return test_authenticated_decryption(&gcm_test_case_3);
8594 test_AES_GCM_authenticated_decryption_test_case_4(void)
8596 return test_authenticated_decryption(&gcm_test_case_4);
8600 test_AES_GCM_authenticated_decryption_test_case_5(void)
8602 return test_authenticated_decryption(&gcm_test_case_5);
8606 test_AES_GCM_authenticated_decryption_test_case_6(void)
8608 return test_authenticated_decryption(&gcm_test_case_6);
8612 test_AES_GCM_authenticated_decryption_test_case_7(void)
8614 return test_authenticated_decryption(&gcm_test_case_7);
8618 test_AES_GCM_authenticated_decryption_test_case_8(void)
8620 return test_authenticated_decryption(&gcm_test_case_8);
8624 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8626 return test_authenticated_decryption(&gcm_J0_test_case_1);
8630 test_AES_GCM_auth_decryption_test_case_192_1(void)
8632 return test_authenticated_decryption(&gcm_test_case_192_1);
8636 test_AES_GCM_auth_decryption_test_case_192_2(void)
8638 return test_authenticated_decryption(&gcm_test_case_192_2);
8642 test_AES_GCM_auth_decryption_test_case_192_3(void)
8644 return test_authenticated_decryption(&gcm_test_case_192_3);
8648 test_AES_GCM_auth_decryption_test_case_192_4(void)
8650 return test_authenticated_decryption(&gcm_test_case_192_4);
8654 test_AES_GCM_auth_decryption_test_case_192_5(void)
8656 return test_authenticated_decryption(&gcm_test_case_192_5);
8660 test_AES_GCM_auth_decryption_test_case_192_6(void)
8662 return test_authenticated_decryption(&gcm_test_case_192_6);
8666 test_AES_GCM_auth_decryption_test_case_192_7(void)
8668 return test_authenticated_decryption(&gcm_test_case_192_7);
8672 test_AES_GCM_auth_decryption_test_case_256_1(void)
8674 return test_authenticated_decryption(&gcm_test_case_256_1);
8678 test_AES_GCM_auth_decryption_test_case_256_2(void)
8680 return test_authenticated_decryption(&gcm_test_case_256_2);
8684 test_AES_GCM_auth_decryption_test_case_256_3(void)
8686 return test_authenticated_decryption(&gcm_test_case_256_3);
8690 test_AES_GCM_auth_decryption_test_case_256_4(void)
8692 return test_authenticated_decryption(&gcm_test_case_256_4);
8696 test_AES_GCM_auth_decryption_test_case_256_5(void)
8698 return test_authenticated_decryption(&gcm_test_case_256_5);
8702 test_AES_GCM_auth_decryption_test_case_256_6(void)
8704 return test_authenticated_decryption(&gcm_test_case_256_6);
8708 test_AES_GCM_auth_decryption_test_case_256_7(void)
8710 return test_authenticated_decryption(&gcm_test_case_256_7);
8714 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8716 return test_authenticated_decryption(&gcm_test_case_aad_1);
8720 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8722 return test_authenticated_decryption(&gcm_test_case_aad_2);
8726 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8728 struct aead_test_data tdata;
8731 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8732 tdata.iv.data[0] += 1;
8733 res = test_authenticated_decryption(&tdata);
8734 if (res == -ENOTSUP)
8736 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8737 return TEST_SUCCESS;
8741 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8743 struct aead_test_data tdata;
8746 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8747 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8748 tdata.plaintext.data[0] += 1;
8749 res = test_authenticated_decryption(&tdata);
8750 if (res == -ENOTSUP)
8752 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8753 return TEST_SUCCESS;
8757 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8759 struct aead_test_data tdata;
8762 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8763 tdata.ciphertext.data[0] += 1;
8764 res = test_authenticated_decryption(&tdata);
8765 if (res == -ENOTSUP)
8767 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8768 return TEST_SUCCESS;
8772 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8774 struct aead_test_data tdata;
8777 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8779 res = test_authenticated_decryption(&tdata);
8780 if (res == -ENOTSUP)
8782 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8783 return TEST_SUCCESS;
8787 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8789 struct aead_test_data tdata;
8790 uint8_t aad[gcm_test_case_7.aad.len];
8793 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8794 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8796 tdata.aad.data = aad;
8797 res = test_authenticated_decryption(&tdata);
8798 if (res == -ENOTSUP)
8800 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8801 return TEST_SUCCESS;
8805 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8807 struct aead_test_data tdata;
8810 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8811 tdata.auth_tag.data[0] += 1;
8812 res = test_authenticated_decryption(&tdata);
8813 if (res == -ENOTSUP)
8815 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8816 return TEST_SUCCESS;
8820 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8822 struct crypto_testsuite_params *ts_params = &testsuite_params;
8823 struct crypto_unittest_params *ut_params = &unittest_params;
8826 uint8_t *ciphertext, *auth_tag;
8827 uint16_t plaintext_pad_len;
8829 /* Verify the capabilities */
8830 struct rte_cryptodev_sym_capability_idx cap_idx;
8831 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8832 cap_idx.algo.aead = tdata->algo;
8833 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8837 /* not supported with CPU crypto */
8838 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8841 /* Create AEAD session */
8842 retval = create_aead_session(ts_params->valid_devs[0],
8844 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8845 tdata->key.data, tdata->key.len,
8846 tdata->aad.len, tdata->auth_tag.len,
8851 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8852 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8854 /* clear mbuf payload */
8855 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8856 rte_pktmbuf_tailroom(ut_params->ibuf));
8857 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8858 rte_pktmbuf_tailroom(ut_params->obuf));
8860 /* Create AEAD operation */
8861 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8865 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8867 ut_params->op->sym->m_src = ut_params->ibuf;
8868 ut_params->op->sym->m_dst = ut_params->obuf;
8870 /* Process crypto operation */
8871 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8872 ut_params->op), "failed to process sym crypto op");
8874 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8875 "crypto op processing failed");
8877 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8879 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8880 ut_params->op->sym->cipher.data.offset);
8881 auth_tag = ciphertext + plaintext_pad_len;
8883 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8884 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8887 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8889 tdata->ciphertext.data,
8890 tdata->ciphertext.len,
8891 "Ciphertext data not as expected");
8893 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8895 tdata->auth_tag.data,
8896 tdata->auth_tag.len,
8897 "Generated auth tag not as expected");
8904 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8906 return test_authenticated_encryption_oop(&gcm_test_case_5);
8910 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8912 struct crypto_testsuite_params *ts_params = &testsuite_params;
8913 struct crypto_unittest_params *ut_params = &unittest_params;
8918 /* Verify the capabilities */
8919 struct rte_cryptodev_sym_capability_idx cap_idx;
8920 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8921 cap_idx.algo.aead = tdata->algo;
8922 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8926 /* not supported with CPU crypto */
8927 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8930 /* Create AEAD session */
8931 retval = create_aead_session(ts_params->valid_devs[0],
8933 RTE_CRYPTO_AEAD_OP_DECRYPT,
8934 tdata->key.data, tdata->key.len,
8935 tdata->aad.len, tdata->auth_tag.len,
8940 /* alloc mbuf and set payload */
8941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8942 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8945 rte_pktmbuf_tailroom(ut_params->ibuf));
8946 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8947 rte_pktmbuf_tailroom(ut_params->obuf));
8949 /* Create AEAD operation */
8950 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8956 ut_params->op->sym->m_src = ut_params->ibuf;
8957 ut_params->op->sym->m_dst = ut_params->obuf;
8959 /* Process crypto operation */
8960 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8961 ut_params->op), "failed to process sym crypto op");
8963 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8964 "crypto op processing failed");
8966 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8967 ut_params->op->sym->cipher.data.offset);
8969 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8972 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8974 tdata->plaintext.data,
8975 tdata->plaintext.len,
8976 "Plaintext data not as expected");
8978 TEST_ASSERT_EQUAL(ut_params->op->status,
8979 RTE_CRYPTO_OP_STATUS_SUCCESS,
8980 "Authentication failed");
8985 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8987 return test_authenticated_decryption_oop(&gcm_test_case_5);
8991 test_authenticated_encryption_sessionless(
8992 const struct aead_test_data *tdata)
8994 struct crypto_testsuite_params *ts_params = &testsuite_params;
8995 struct crypto_unittest_params *ut_params = &unittest_params;
8998 uint8_t *ciphertext, *auth_tag;
8999 uint16_t plaintext_pad_len;
9000 uint8_t key[tdata->key.len + 1];
9001 struct rte_cryptodev_info dev_info;
9003 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9004 uint64_t feat_flags = dev_info.feature_flags;
9006 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9007 printf("Device doesn't support Sessionless ops.\n");
9011 /* not supported with CPU crypto */
9012 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9015 /* Verify the capabilities */
9016 struct rte_cryptodev_sym_capability_idx cap_idx;
9017 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9018 cap_idx.algo.aead = tdata->algo;
9019 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9025 /* clear mbuf payload */
9026 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9027 rte_pktmbuf_tailroom(ut_params->ibuf));
9029 /* Create AEAD operation */
9030 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9034 /* Create GCM xform */
9035 memcpy(key, tdata->key.data, tdata->key.len);
9036 retval = create_aead_xform(ut_params->op,
9038 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9039 key, tdata->key.len,
9040 tdata->aad.len, tdata->auth_tag.len,
9045 ut_params->op->sym->m_src = ut_params->ibuf;
9047 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9048 RTE_CRYPTO_OP_SESSIONLESS,
9049 "crypto op session type not sessionless");
9051 /* Process crypto operation */
9052 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9053 ut_params->op), "failed to process sym crypto op");
9055 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9057 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9058 "crypto op status not success");
9060 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9062 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9063 ut_params->op->sym->cipher.data.offset);
9064 auth_tag = ciphertext + plaintext_pad_len;
9066 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9067 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9070 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9072 tdata->ciphertext.data,
9073 tdata->ciphertext.len,
9074 "Ciphertext data not as expected");
9076 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9078 tdata->auth_tag.data,
9079 tdata->auth_tag.len,
9080 "Generated auth tag not as expected");
9087 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9089 return test_authenticated_encryption_sessionless(
9094 test_authenticated_decryption_sessionless(
9095 const struct aead_test_data *tdata)
9097 struct crypto_testsuite_params *ts_params = &testsuite_params;
9098 struct crypto_unittest_params *ut_params = &unittest_params;
9102 uint8_t key[tdata->key.len + 1];
9103 struct rte_cryptodev_info dev_info;
9105 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9106 uint64_t feat_flags = dev_info.feature_flags;
9108 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9109 printf("Device doesn't support Sessionless ops.\n");
9113 /* not supported with CPU crypto */
9114 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9117 /* Verify the capabilities */
9118 struct rte_cryptodev_sym_capability_idx cap_idx;
9119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9120 cap_idx.algo.aead = tdata->algo;
9121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9125 /* alloc mbuf and set payload */
9126 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9128 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9129 rte_pktmbuf_tailroom(ut_params->ibuf));
9131 /* Create AEAD operation */
9132 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9136 /* Create AEAD xform */
9137 memcpy(key, tdata->key.data, tdata->key.len);
9138 retval = create_aead_xform(ut_params->op,
9140 RTE_CRYPTO_AEAD_OP_DECRYPT,
9141 key, tdata->key.len,
9142 tdata->aad.len, tdata->auth_tag.len,
9147 ut_params->op->sym->m_src = ut_params->ibuf;
9149 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9150 RTE_CRYPTO_OP_SESSIONLESS,
9151 "crypto op session type not sessionless");
9153 /* Process crypto operation */
9154 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9155 ut_params->op), "failed to process sym crypto op");
9157 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9159 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9160 "crypto op status not success");
9162 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9163 ut_params->op->sym->cipher.data.offset);
9165 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9168 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9170 tdata->plaintext.data,
9171 tdata->plaintext.len,
9172 "Plaintext data not as expected");
9174 TEST_ASSERT_EQUAL(ut_params->op->status,
9175 RTE_CRYPTO_OP_STATUS_SUCCESS,
9176 "Authentication failed");
9181 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9183 return test_authenticated_decryption_sessionless(
9188 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9190 return test_authenticated_encryption(&ccm_test_case_128_1);
9194 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9196 return test_authenticated_encryption(&ccm_test_case_128_2);
9200 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9202 return test_authenticated_encryption(&ccm_test_case_128_3);
9206 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9208 return test_authenticated_decryption(&ccm_test_case_128_1);
9212 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9214 return test_authenticated_decryption(&ccm_test_case_128_2);
9218 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9220 return test_authenticated_decryption(&ccm_test_case_128_3);
9224 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9226 return test_authenticated_encryption(&ccm_test_case_192_1);
9230 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9232 return test_authenticated_encryption(&ccm_test_case_192_2);
9236 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9238 return test_authenticated_encryption(&ccm_test_case_192_3);
9242 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9244 return test_authenticated_decryption(&ccm_test_case_192_1);
9248 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9250 return test_authenticated_decryption(&ccm_test_case_192_2);
9254 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9256 return test_authenticated_decryption(&ccm_test_case_192_3);
9260 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9262 return test_authenticated_encryption(&ccm_test_case_256_1);
9266 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9268 return test_authenticated_encryption(&ccm_test_case_256_2);
9272 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9274 return test_authenticated_encryption(&ccm_test_case_256_3);
9278 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9280 return test_authenticated_decryption(&ccm_test_case_256_1);
9284 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9286 return test_authenticated_decryption(&ccm_test_case_256_2);
9290 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9292 return test_authenticated_decryption(&ccm_test_case_256_3);
9298 struct crypto_testsuite_params *ts_params = &testsuite_params;
9299 struct rte_cryptodev_stats stats;
9301 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9304 /* Verify the capabilities */
9305 struct rte_cryptodev_sym_capability_idx cap_idx;
9306 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9307 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9308 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9311 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9312 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9313 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9317 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9321 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9322 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9323 &stats) == -ENODEV),
9324 "rte_cryptodev_stats_get invalid dev failed");
9325 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9326 "rte_cryptodev_stats_get invalid Param failed");
9328 /* Test expected values */
9329 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9330 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9332 "rte_cryptodev_stats_get failed");
9333 TEST_ASSERT((stats.enqueued_count == 1),
9334 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9335 TEST_ASSERT((stats.dequeued_count == 1),
9336 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9337 TEST_ASSERT((stats.enqueue_err_count == 0),
9338 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9339 TEST_ASSERT((stats.dequeue_err_count == 0),
9340 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9342 /* invalid device but should ignore and not reset device stats*/
9343 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9344 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9346 "rte_cryptodev_stats_get failed");
9347 TEST_ASSERT((stats.enqueued_count == 1),
9348 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9350 /* check that a valid reset clears stats */
9351 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9352 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9354 "rte_cryptodev_stats_get failed");
9355 TEST_ASSERT((stats.enqueued_count == 0),
9356 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9357 TEST_ASSERT((stats.dequeued_count == 0),
9358 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9360 return TEST_SUCCESS;
9363 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9364 struct crypto_unittest_params *ut_params,
9365 enum rte_crypto_auth_operation op,
9366 const struct HMAC_MD5_vector *test_case)
9370 memcpy(key, test_case->key.data, test_case->key.len);
9372 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9373 ut_params->auth_xform.next = NULL;
9374 ut_params->auth_xform.auth.op = op;
9376 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9378 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9379 ut_params->auth_xform.auth.key.length = test_case->key.len;
9380 ut_params->auth_xform.auth.key.data = key;
9382 ut_params->sess = rte_cryptodev_sym_session_create(
9383 ts_params->session_mpool);
9385 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9386 ut_params->sess, &ut_params->auth_xform,
9387 ts_params->session_priv_mpool);
9389 if (ut_params->sess == NULL)
9392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9394 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9395 rte_pktmbuf_tailroom(ut_params->ibuf));
9400 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9401 const struct HMAC_MD5_vector *test_case,
9402 uint8_t **plaintext)
9404 uint16_t plaintext_pad_len;
9406 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9408 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9411 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9413 memcpy(*plaintext, test_case->plaintext.data,
9414 test_case->plaintext.len);
9416 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9417 ut_params->ibuf, MD5_DIGEST_LEN);
9418 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9419 "no room to append digest");
9420 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9421 ut_params->ibuf, plaintext_pad_len);
9423 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9424 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9425 test_case->auth_tag.len);
9428 sym_op->auth.data.offset = 0;
9429 sym_op->auth.data.length = test_case->plaintext.len;
9431 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9432 ut_params->op->sym->m_src = ut_params->ibuf;
9438 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9440 uint16_t plaintext_pad_len;
9441 uint8_t *plaintext, *auth_tag;
9443 struct crypto_testsuite_params *ts_params = &testsuite_params;
9444 struct crypto_unittest_params *ut_params = &unittest_params;
9446 /* Verify the capabilities */
9447 struct rte_cryptodev_sym_capability_idx cap_idx;
9448 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9449 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9450 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9454 if (MD5_HMAC_create_session(ts_params, ut_params,
9455 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9458 /* Generate Crypto op data structure */
9459 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9460 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9461 TEST_ASSERT_NOT_NULL(ut_params->op,
9462 "Failed to allocate symmetric crypto operation struct");
9464 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9467 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9470 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9471 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9474 TEST_ASSERT_NOT_NULL(
9475 process_crypto_request(ts_params->valid_devs[0],
9477 "failed to process sym crypto op");
9479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9480 "crypto op processing failed");
9482 if (ut_params->op->sym->m_dst) {
9483 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9484 uint8_t *, plaintext_pad_len);
9486 auth_tag = plaintext + plaintext_pad_len;
9489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9491 test_case->auth_tag.data,
9492 test_case->auth_tag.len,
9493 "HMAC_MD5 generated tag not as expected");
9495 return TEST_SUCCESS;
9499 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9503 struct crypto_testsuite_params *ts_params = &testsuite_params;
9504 struct crypto_unittest_params *ut_params = &unittest_params;
9506 /* Verify the capabilities */
9507 struct rte_cryptodev_sym_capability_idx cap_idx;
9508 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9509 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9510 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9514 if (MD5_HMAC_create_session(ts_params, ut_params,
9515 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9519 /* Generate Crypto op data structure */
9520 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9521 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9522 TEST_ASSERT_NOT_NULL(ut_params->op,
9523 "Failed to allocate symmetric crypto operation struct");
9525 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9528 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9529 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9532 TEST_ASSERT_NOT_NULL(
9533 process_crypto_request(ts_params->valid_devs[0],
9535 "failed to process sym crypto op");
9537 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9538 "HMAC_MD5 crypto op processing failed");
9540 return TEST_SUCCESS;
9544 test_MD5_HMAC_generate_case_1(void)
9546 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9550 test_MD5_HMAC_verify_case_1(void)
9552 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9556 test_MD5_HMAC_generate_case_2(void)
9558 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9562 test_MD5_HMAC_verify_case_2(void)
9564 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9568 test_multi_session(void)
9570 struct crypto_testsuite_params *ts_params = &testsuite_params;
9571 struct crypto_unittest_params *ut_params = &unittest_params;
9573 struct rte_cryptodev_info dev_info;
9574 struct rte_cryptodev_sym_session **sessions;
9578 /* Verify the capabilities */
9579 struct rte_cryptodev_sym_capability_idx cap_idx;
9580 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9581 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9582 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9585 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9586 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9591 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9592 aes_cbc_key, hmac_sha512_key);
9595 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9597 sessions = rte_malloc(NULL,
9598 (sizeof(struct rte_cryptodev_sym_session *) *
9599 MAX_NB_SESSIONS) + 1, 0);
9601 /* Create multiple crypto sessions*/
9602 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9604 sessions[i] = rte_cryptodev_sym_session_create(
9605 ts_params->session_mpool);
9607 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9608 sessions[i], &ut_params->auth_xform,
9609 ts_params->session_priv_mpool);
9610 TEST_ASSERT_NOT_NULL(sessions[i],
9611 "Session creation failed at session number %u",
9614 /* Attempt to send a request on each session */
9615 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9619 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9620 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9622 "Failed to perform decrypt on request number %u.", i);
9623 /* free crypto operation structure */
9625 rte_crypto_op_free(ut_params->op);
9628 * free mbuf - both obuf and ibuf are usually the same,
9629 * so check if they point at the same address is necessary,
9630 * to avoid freeing the mbuf twice.
9632 if (ut_params->obuf) {
9633 rte_pktmbuf_free(ut_params->obuf);
9634 if (ut_params->ibuf == ut_params->obuf)
9635 ut_params->ibuf = 0;
9636 ut_params->obuf = 0;
9638 if (ut_params->ibuf) {
9639 rte_pktmbuf_free(ut_params->ibuf);
9640 ut_params->ibuf = 0;
9644 /* Next session create should fail */
9645 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9646 sessions[i], &ut_params->auth_xform,
9647 ts_params->session_priv_mpool);
9648 TEST_ASSERT_NULL(sessions[i],
9649 "Session creation succeeded unexpectedly!");
9651 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9652 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9654 rte_cryptodev_sym_session_free(sessions[i]);
9659 return TEST_SUCCESS;
9662 struct multi_session_params {
9663 struct crypto_unittest_params ut_params;
9664 uint8_t *cipher_key;
9666 const uint8_t *cipher;
9667 const uint8_t *digest;
9671 #define MB_SESSION_NUMBER 3
9674 test_multi_session_random_usage(void)
9676 struct crypto_testsuite_params *ts_params = &testsuite_params;
9677 struct rte_cryptodev_info dev_info;
9678 struct rte_cryptodev_sym_session **sessions;
9680 struct multi_session_params ut_paramz[] = {
9683 .cipher_key = ms_aes_cbc_key0,
9684 .hmac_key = ms_hmac_key0,
9685 .cipher = ms_aes_cbc_cipher0,
9686 .digest = ms_hmac_digest0,
9687 .iv = ms_aes_cbc_iv0
9690 .cipher_key = ms_aes_cbc_key1,
9691 .hmac_key = ms_hmac_key1,
9692 .cipher = ms_aes_cbc_cipher1,
9693 .digest = ms_hmac_digest1,
9694 .iv = ms_aes_cbc_iv1
9697 .cipher_key = ms_aes_cbc_key2,
9698 .hmac_key = ms_hmac_key2,
9699 .cipher = ms_aes_cbc_cipher2,
9700 .digest = ms_hmac_digest2,
9701 .iv = ms_aes_cbc_iv2
9706 /* Verify the capabilities */
9707 struct rte_cryptodev_sym_capability_idx cap_idx;
9708 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9709 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9710 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9713 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9714 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9715 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9719 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9721 sessions = rte_malloc(NULL,
9722 (sizeof(struct rte_cryptodev_sym_session *)
9723 * MAX_NB_SESSIONS) + 1, 0);
9725 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9726 sessions[i] = rte_cryptodev_sym_session_create(
9727 ts_params->session_mpool);
9729 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9730 sizeof(struct crypto_unittest_params));
9732 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9733 &ut_paramz[i].ut_params,
9734 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9736 /* Create multiple crypto sessions*/
9737 rte_cryptodev_sym_session_init(
9738 ts_params->valid_devs[0],
9740 &ut_paramz[i].ut_params.auth_xform,
9741 ts_params->session_priv_mpool);
9743 TEST_ASSERT_NOT_NULL(sessions[i],
9744 "Session creation failed at session number %u",
9750 for (i = 0; i < 40000; i++) {
9752 j = rand() % MB_SESSION_NUMBER;
9754 TEST_ASSERT_SUCCESS(
9755 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9757 &ut_paramz[j].ut_params,
9758 ts_params, ut_paramz[j].cipher,
9759 ut_paramz[j].digest,
9761 "Failed to perform decrypt on request number %u.", i);
9763 if (ut_paramz[j].ut_params.op)
9764 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9767 * free mbuf - both obuf and ibuf are usually the same,
9768 * so check if they point at the same address is necessary,
9769 * to avoid freeing the mbuf twice.
9771 if (ut_paramz[j].ut_params.obuf) {
9772 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9773 if (ut_paramz[j].ut_params.ibuf
9774 == ut_paramz[j].ut_params.obuf)
9775 ut_paramz[j].ut_params.ibuf = 0;
9776 ut_paramz[j].ut_params.obuf = 0;
9778 if (ut_paramz[j].ut_params.ibuf) {
9779 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9780 ut_paramz[j].ut_params.ibuf = 0;
9784 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9785 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9787 rte_cryptodev_sym_session_free(sessions[i]);
9792 return TEST_SUCCESS;
9795 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9796 0xab, 0xab, 0xab, 0xab,
9797 0xab, 0xab, 0xab, 0xab,
9798 0xab, 0xab, 0xab, 0xab};
9801 test_null_invalid_operation(void)
9803 struct crypto_testsuite_params *ts_params = &testsuite_params;
9804 struct crypto_unittest_params *ut_params = &unittest_params;
9807 /* This test is for NULL PMD only */
9808 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9809 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9812 /* Setup Cipher Parameters */
9813 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9814 ut_params->cipher_xform.next = NULL;
9816 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9817 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9819 ut_params->sess = rte_cryptodev_sym_session_create(
9820 ts_params->session_mpool);
9822 /* Create Crypto session*/
9823 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9824 ut_params->sess, &ut_params->cipher_xform,
9825 ts_params->session_priv_mpool);
9826 TEST_ASSERT(ret < 0,
9827 "Session creation succeeded unexpectedly");
9830 /* Setup HMAC Parameters */
9831 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9832 ut_params->auth_xform.next = NULL;
9834 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9835 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9837 ut_params->sess = rte_cryptodev_sym_session_create(
9838 ts_params->session_mpool);
9840 /* Create Crypto session*/
9841 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9842 ut_params->sess, &ut_params->auth_xform,
9843 ts_params->session_priv_mpool);
9844 TEST_ASSERT(ret < 0,
9845 "Session creation succeeded unexpectedly");
9847 return TEST_SUCCESS;
9851 #define NULL_BURST_LENGTH (32)
9854 test_null_burst_operation(void)
9856 struct crypto_testsuite_params *ts_params = &testsuite_params;
9857 struct crypto_unittest_params *ut_params = &unittest_params;
9859 unsigned i, burst_len = NULL_BURST_LENGTH;
9861 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9862 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9864 /* This test is for NULL PMD only */
9865 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9866 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9869 /* Setup Cipher Parameters */
9870 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9871 ut_params->cipher_xform.next = &ut_params->auth_xform;
9873 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9874 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9876 /* Setup HMAC Parameters */
9877 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9878 ut_params->auth_xform.next = NULL;
9880 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9881 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9883 ut_params->sess = rte_cryptodev_sym_session_create(
9884 ts_params->session_mpool);
9886 /* Create Crypto session*/
9887 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9888 ut_params->sess, &ut_params->cipher_xform,
9889 ts_params->session_priv_mpool);
9890 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9892 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9893 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9894 burst_len, "failed to generate burst of crypto ops");
9896 /* Generate an operation for each mbuf in burst */
9897 for (i = 0; i < burst_len; i++) {
9898 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9900 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9902 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9906 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9908 burst[i]->sym->m_src = m;
9911 /* Process crypto operation */
9912 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9913 0, burst, burst_len),
9915 "Error enqueuing burst");
9917 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9918 0, burst_dequeued, burst_len),
9920 "Error dequeuing burst");
9923 for (i = 0; i < burst_len; i++) {
9925 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9926 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9928 "data not as expected");
9930 rte_pktmbuf_free(burst[i]->sym->m_src);
9931 rte_crypto_op_free(burst[i]);
9934 return TEST_SUCCESS;
9938 generate_gmac_large_plaintext(uint8_t *data)
9942 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9943 memcpy(&data[i], &data[0], 32);
9947 create_gmac_operation(enum rte_crypto_auth_operation op,
9948 const struct gmac_test_data *tdata)
9950 struct crypto_testsuite_params *ts_params = &testsuite_params;
9951 struct crypto_unittest_params *ut_params = &unittest_params;
9952 struct rte_crypto_sym_op *sym_op;
9954 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9956 /* Generate Crypto op data structure */
9957 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9958 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9959 TEST_ASSERT_NOT_NULL(ut_params->op,
9960 "Failed to allocate symmetric crypto operation struct");
9962 sym_op = ut_params->op->sym;
9964 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9965 ut_params->ibuf, tdata->gmac_tag.len);
9966 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9967 "no room to append digest");
9969 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9970 ut_params->ibuf, plaintext_pad_len);
9972 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9973 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9974 tdata->gmac_tag.len);
9975 debug_hexdump(stdout, "digest:",
9976 sym_op->auth.digest.data,
9977 tdata->gmac_tag.len);
9980 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9981 uint8_t *, IV_OFFSET);
9983 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9985 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9987 sym_op->cipher.data.length = 0;
9988 sym_op->cipher.data.offset = 0;
9990 sym_op->auth.data.offset = 0;
9991 sym_op->auth.data.length = tdata->plaintext.len;
9996 static int create_gmac_session(uint8_t dev_id,
9997 const struct gmac_test_data *tdata,
9998 enum rte_crypto_auth_operation auth_op)
10000 uint8_t auth_key[tdata->key.len];
10002 struct crypto_testsuite_params *ts_params = &testsuite_params;
10003 struct crypto_unittest_params *ut_params = &unittest_params;
10005 memcpy(auth_key, tdata->key.data, tdata->key.len);
10007 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10008 ut_params->auth_xform.next = NULL;
10010 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10011 ut_params->auth_xform.auth.op = auth_op;
10012 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10013 ut_params->auth_xform.auth.key.length = tdata->key.len;
10014 ut_params->auth_xform.auth.key.data = auth_key;
10015 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10016 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10019 ut_params->sess = rte_cryptodev_sym_session_create(
10020 ts_params->session_mpool);
10022 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10023 &ut_params->auth_xform,
10024 ts_params->session_priv_mpool);
10026 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10032 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10034 struct crypto_testsuite_params *ts_params = &testsuite_params;
10035 struct crypto_unittest_params *ut_params = &unittest_params;
10039 uint8_t *auth_tag, *plaintext;
10040 uint16_t plaintext_pad_len;
10042 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10043 "No GMAC length in the source data");
10045 /* Verify the capabilities */
10046 struct rte_cryptodev_sym_capability_idx cap_idx;
10047 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10048 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10049 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10053 retval = create_gmac_session(ts_params->valid_devs[0],
10054 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10059 if (tdata->plaintext.len > MBUF_SIZE)
10060 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10062 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10063 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10064 "Failed to allocate input buffer in mempool");
10066 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10067 rte_pktmbuf_tailroom(ut_params->ibuf));
10069 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10071 * Runtime generate the large plain text instead of use hard code
10072 * plain text vector. It is done to avoid create huge source file
10073 * with the test vector.
10075 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10076 generate_gmac_large_plaintext(tdata->plaintext.data);
10078 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10079 plaintext_pad_len);
10080 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10082 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10083 debug_hexdump(stdout, "plaintext:", plaintext,
10084 tdata->plaintext.len);
10086 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10092 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10094 ut_params->op->sym->m_src = ut_params->ibuf;
10096 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10097 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10100 TEST_ASSERT_NOT_NULL(
10101 process_crypto_request(ts_params->valid_devs[0],
10102 ut_params->op), "failed to process sym crypto op");
10104 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10105 "crypto op processing failed");
10107 if (ut_params->op->sym->m_dst) {
10108 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10109 uint8_t *, plaintext_pad_len);
10111 auth_tag = plaintext + plaintext_pad_len;
10114 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10116 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10118 tdata->gmac_tag.data,
10119 tdata->gmac_tag.len,
10120 "GMAC Generated auth tag not as expected");
10126 test_AES_GMAC_authentication_test_case_1(void)
10128 return test_AES_GMAC_authentication(&gmac_test_case_1);
10132 test_AES_GMAC_authentication_test_case_2(void)
10134 return test_AES_GMAC_authentication(&gmac_test_case_2);
10138 test_AES_GMAC_authentication_test_case_3(void)
10140 return test_AES_GMAC_authentication(&gmac_test_case_3);
10144 test_AES_GMAC_authentication_test_case_4(void)
10146 return test_AES_GMAC_authentication(&gmac_test_case_4);
10150 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10152 struct crypto_testsuite_params *ts_params = &testsuite_params;
10153 struct crypto_unittest_params *ut_params = &unittest_params;
10155 uint32_t plaintext_pad_len;
10156 uint8_t *plaintext;
10158 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10159 "No GMAC length in the source data");
10161 /* Verify the capabilities */
10162 struct rte_cryptodev_sym_capability_idx cap_idx;
10163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10164 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10165 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10169 retval = create_gmac_session(ts_params->valid_devs[0],
10170 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10175 if (tdata->plaintext.len > MBUF_SIZE)
10176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10178 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10179 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10180 "Failed to allocate input buffer in mempool");
10182 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10183 rte_pktmbuf_tailroom(ut_params->ibuf));
10185 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10188 * Runtime generate the large plain text instead of use hard code
10189 * plain text vector. It is done to avoid create huge source file
10190 * with the test vector.
10192 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10193 generate_gmac_large_plaintext(tdata->plaintext.data);
10195 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10196 plaintext_pad_len);
10197 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10199 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10200 debug_hexdump(stdout, "plaintext:", plaintext,
10201 tdata->plaintext.len);
10203 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10209 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10211 ut_params->op->sym->m_src = ut_params->ibuf;
10213 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10214 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10217 TEST_ASSERT_NOT_NULL(
10218 process_crypto_request(ts_params->valid_devs[0],
10219 ut_params->op), "failed to process sym crypto op");
10221 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10222 "crypto op processing failed");
10229 test_AES_GMAC_authentication_verify_test_case_1(void)
10231 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10235 test_AES_GMAC_authentication_verify_test_case_2(void)
10237 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10241 test_AES_GMAC_authentication_verify_test_case_3(void)
10243 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10247 test_AES_GMAC_authentication_verify_test_case_4(void)
10249 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10252 struct test_crypto_vector {
10253 enum rte_crypto_cipher_algorithm crypto_algo;
10254 unsigned int cipher_offset;
10255 unsigned int cipher_len;
10268 const uint8_t *data;
10273 const uint8_t *data;
10277 enum rte_crypto_auth_algorithm auth_algo;
10278 unsigned int auth_offset;
10286 const uint8_t *data;
10296 static const struct test_crypto_vector
10297 hmac_sha1_test_crypto_vector = {
10298 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10300 .data = plaintext_hash,
10305 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10306 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10307 0xDE, 0xF4, 0xDE, 0xAD
10313 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10314 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10315 0x3F, 0x91, 0x64, 0x59
10321 static const struct test_crypto_vector
10322 aes128_gmac_test_vector = {
10323 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10325 .data = plaintext_hash,
10330 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10331 0x08, 0x09, 0x0A, 0x0B
10337 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10338 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10344 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10345 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10351 static const struct test_crypto_vector
10352 aes128cbc_hmac_sha1_test_vector = {
10353 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10354 .cipher_offset = 0,
10358 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10359 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10365 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10366 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10371 .data = plaintext_hash,
10375 .data = ciphertext512_aes128cbc,
10378 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10382 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10383 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10384 0xDE, 0xF4, 0xDE, 0xAD
10390 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10391 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10392 0x18, 0x8C, 0x1D, 0x32
10398 static const struct test_crypto_vector
10399 aes128cbc_hmac_sha1_aad_test_vector = {
10400 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10401 .cipher_offset = 8,
10405 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10406 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10412 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10413 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10418 .data = plaintext_hash,
10422 .data = ciphertext512_aes128cbc_aad,
10425 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10429 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10430 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10431 0xDE, 0xF4, 0xDE, 0xAD
10437 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
10438 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
10439 0x62, 0x0F, 0xFB, 0x10
10446 data_corruption(uint8_t *data)
10452 tag_corruption(uint8_t *data, unsigned int tag_offset)
10454 data[tag_offset] += 1;
10458 create_auth_session(struct crypto_unittest_params *ut_params,
10460 const struct test_crypto_vector *reference,
10461 enum rte_crypto_auth_operation auth_op)
10463 struct crypto_testsuite_params *ts_params = &testsuite_params;
10464 uint8_t auth_key[reference->auth_key.len + 1];
10466 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10468 /* Setup Authentication Parameters */
10469 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10470 ut_params->auth_xform.auth.op = auth_op;
10471 ut_params->auth_xform.next = NULL;
10472 ut_params->auth_xform.auth.algo = reference->auth_algo;
10473 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10474 ut_params->auth_xform.auth.key.data = auth_key;
10475 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10477 /* Create Crypto session*/
10478 ut_params->sess = rte_cryptodev_sym_session_create(
10479 ts_params->session_mpool);
10481 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10482 &ut_params->auth_xform,
10483 ts_params->session_priv_mpool);
10485 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10491 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10493 const struct test_crypto_vector *reference,
10494 enum rte_crypto_auth_operation auth_op,
10495 enum rte_crypto_cipher_operation cipher_op)
10497 struct crypto_testsuite_params *ts_params = &testsuite_params;
10498 uint8_t cipher_key[reference->cipher_key.len + 1];
10499 uint8_t auth_key[reference->auth_key.len + 1];
10501 memcpy(cipher_key, reference->cipher_key.data,
10502 reference->cipher_key.len);
10503 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10505 /* Setup Authentication Parameters */
10506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10507 ut_params->auth_xform.auth.op = auth_op;
10508 ut_params->auth_xform.auth.algo = reference->auth_algo;
10509 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10510 ut_params->auth_xform.auth.key.data = auth_key;
10511 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10513 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10514 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10515 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10517 ut_params->auth_xform.next = &ut_params->cipher_xform;
10519 /* Setup Cipher Parameters */
10520 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10521 ut_params->cipher_xform.next = NULL;
10522 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10523 ut_params->cipher_xform.cipher.op = cipher_op;
10524 ut_params->cipher_xform.cipher.key.data = cipher_key;
10525 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10526 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10527 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10530 /* Create Crypto session*/
10531 ut_params->sess = rte_cryptodev_sym_session_create(
10532 ts_params->session_mpool);
10534 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10535 &ut_params->auth_xform,
10536 ts_params->session_priv_mpool);
10538 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10544 create_auth_operation(struct crypto_testsuite_params *ts_params,
10545 struct crypto_unittest_params *ut_params,
10546 const struct test_crypto_vector *reference,
10547 unsigned int auth_generate)
10549 /* Generate Crypto op data structure */
10550 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10551 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10552 TEST_ASSERT_NOT_NULL(ut_params->op,
10553 "Failed to allocate pktmbuf offload");
10555 /* Set crypto operation data parameters */
10556 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10558 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10560 /* set crypto operation source mbuf */
10561 sym_op->m_src = ut_params->ibuf;
10564 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10565 ut_params->ibuf, reference->digest.len);
10567 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10568 "no room to append auth tag");
10570 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10571 ut_params->ibuf, reference->plaintext.len);
10574 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10576 memcpy(sym_op->auth.digest.data,
10577 reference->digest.data,
10578 reference->digest.len);
10580 debug_hexdump(stdout, "digest:",
10581 sym_op->auth.digest.data,
10582 reference->digest.len);
10584 sym_op->auth.data.length = reference->plaintext.len;
10585 sym_op->auth.data.offset = 0;
10591 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10592 struct crypto_unittest_params *ut_params,
10593 const struct test_crypto_vector *reference,
10594 unsigned int auth_generate)
10596 /* Generate Crypto op data structure */
10597 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10598 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10599 TEST_ASSERT_NOT_NULL(ut_params->op,
10600 "Failed to allocate pktmbuf offload");
10602 /* Set crypto operation data parameters */
10603 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10605 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10607 /* set crypto operation source mbuf */
10608 sym_op->m_src = ut_params->ibuf;
10611 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10612 ut_params->ibuf, reference->digest.len);
10614 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10615 "no room to append auth tag");
10617 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10618 ut_params->ibuf, reference->ciphertext.len);
10621 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10623 memcpy(sym_op->auth.digest.data,
10624 reference->digest.data,
10625 reference->digest.len);
10627 debug_hexdump(stdout, "digest:",
10628 sym_op->auth.digest.data,
10629 reference->digest.len);
10631 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10632 reference->iv.data, reference->iv.len);
10634 sym_op->cipher.data.length = 0;
10635 sym_op->cipher.data.offset = 0;
10637 sym_op->auth.data.length = reference->plaintext.len;
10638 sym_op->auth.data.offset = 0;
10644 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10645 struct crypto_unittest_params *ut_params,
10646 const struct test_crypto_vector *reference,
10647 unsigned int auth_generate)
10649 /* Generate Crypto op data structure */
10650 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10651 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10652 TEST_ASSERT_NOT_NULL(ut_params->op,
10653 "Failed to allocate pktmbuf offload");
10655 /* Set crypto operation data parameters */
10656 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10658 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10660 /* set crypto operation source mbuf */
10661 sym_op->m_src = ut_params->ibuf;
10664 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10665 ut_params->ibuf, reference->digest.len);
10667 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10668 "no room to append auth tag");
10670 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10671 ut_params->ibuf, reference->ciphertext.len);
10674 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10676 memcpy(sym_op->auth.digest.data,
10677 reference->digest.data,
10678 reference->digest.len);
10680 debug_hexdump(stdout, "digest:",
10681 sym_op->auth.digest.data,
10682 reference->digest.len);
10684 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10685 reference->iv.data, reference->iv.len);
10687 sym_op->cipher.data.length = reference->cipher_len;
10688 sym_op->cipher.data.offset = reference->cipher_offset;
10690 sym_op->auth.data.length = reference->plaintext.len;
10691 sym_op->auth.data.offset = reference->auth_offset;
10697 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10698 struct crypto_unittest_params *ut_params,
10699 const struct test_crypto_vector *reference)
10701 return create_auth_operation(ts_params, ut_params, reference, 0);
10705 create_auth_verify_GMAC_operation(
10706 struct crypto_testsuite_params *ts_params,
10707 struct crypto_unittest_params *ut_params,
10708 const struct test_crypto_vector *reference)
10710 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10714 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10715 struct crypto_unittest_params *ut_params,
10716 const struct test_crypto_vector *reference)
10718 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10722 test_authentication_verify_fail_when_data_corruption(
10723 struct crypto_testsuite_params *ts_params,
10724 struct crypto_unittest_params *ut_params,
10725 const struct test_crypto_vector *reference,
10726 unsigned int data_corrupted)
10730 uint8_t *plaintext;
10732 /* Verify the capabilities */
10733 struct rte_cryptodev_sym_capability_idx cap_idx;
10734 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10735 cap_idx.algo.auth = reference->auth_algo;
10736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10740 /* Create session */
10741 retval = create_auth_session(ut_params,
10742 ts_params->valid_devs[0],
10744 RTE_CRYPTO_AUTH_OP_VERIFY);
10748 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10749 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10750 "Failed to allocate input buffer in mempool");
10752 /* clear mbuf payload */
10753 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10754 rte_pktmbuf_tailroom(ut_params->ibuf));
10756 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10757 reference->plaintext.len);
10758 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10759 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10761 debug_hexdump(stdout, "plaintext:", plaintext,
10762 reference->plaintext.len);
10764 /* Create operation */
10765 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10770 if (data_corrupted)
10771 data_corruption(plaintext);
10773 tag_corruption(plaintext, reference->plaintext.len);
10775 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10776 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10778 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10779 RTE_CRYPTO_OP_STATUS_SUCCESS,
10780 "authentication not failed");
10782 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10784 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10791 test_authentication_verify_GMAC_fail_when_corruption(
10792 struct crypto_testsuite_params *ts_params,
10793 struct crypto_unittest_params *ut_params,
10794 const struct test_crypto_vector *reference,
10795 unsigned int data_corrupted)
10798 uint8_t *plaintext;
10800 /* Verify the capabilities */
10801 struct rte_cryptodev_sym_capability_idx cap_idx;
10802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10803 cap_idx.algo.auth = reference->auth_algo;
10804 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10808 /* Create session */
10809 retval = create_auth_cipher_session(ut_params,
10810 ts_params->valid_devs[0],
10812 RTE_CRYPTO_AUTH_OP_VERIFY,
10813 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10817 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10818 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10819 "Failed to allocate input buffer in mempool");
10821 /* clear mbuf payload */
10822 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10823 rte_pktmbuf_tailroom(ut_params->ibuf));
10825 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10826 reference->plaintext.len);
10827 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10828 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10830 debug_hexdump(stdout, "plaintext:", plaintext,
10831 reference->plaintext.len);
10833 /* Create operation */
10834 retval = create_auth_verify_GMAC_operation(ts_params,
10841 if (data_corrupted)
10842 data_corruption(plaintext);
10844 tag_corruption(plaintext, reference->aad.len);
10846 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10847 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10849 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10850 RTE_CRYPTO_OP_STATUS_SUCCESS,
10851 "authentication not failed");
10853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10855 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10862 test_authenticated_decryption_fail_when_corruption(
10863 struct crypto_testsuite_params *ts_params,
10864 struct crypto_unittest_params *ut_params,
10865 const struct test_crypto_vector *reference,
10866 unsigned int data_corrupted)
10870 uint8_t *ciphertext;
10872 /* Verify the capabilities */
10873 struct rte_cryptodev_sym_capability_idx cap_idx;
10874 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10875 cap_idx.algo.auth = reference->auth_algo;
10876 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10879 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10880 cap_idx.algo.cipher = reference->crypto_algo;
10881 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10885 /* Create session */
10886 retval = create_auth_cipher_session(ut_params,
10887 ts_params->valid_devs[0],
10889 RTE_CRYPTO_AUTH_OP_VERIFY,
10890 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10894 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10895 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10896 "Failed to allocate input buffer in mempool");
10898 /* clear mbuf payload */
10899 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10900 rte_pktmbuf_tailroom(ut_params->ibuf));
10902 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10903 reference->ciphertext.len);
10904 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10905 memcpy(ciphertext, reference->ciphertext.data,
10906 reference->ciphertext.len);
10908 /* Create operation */
10909 retval = create_cipher_auth_verify_operation(ts_params,
10916 if (data_corrupted)
10917 data_corruption(ciphertext);
10919 tag_corruption(ciphertext, reference->ciphertext.len);
10921 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10922 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10924 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10925 RTE_CRYPTO_OP_STATUS_SUCCESS,
10926 "authentication not failed");
10928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10930 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10937 test_authenticated_encryt_with_esn(
10938 struct crypto_testsuite_params *ts_params,
10939 struct crypto_unittest_params *ut_params,
10940 const struct test_crypto_vector *reference)
10944 uint8_t *authciphertext, *plaintext, *auth_tag;
10945 uint16_t plaintext_pad_len;
10946 uint8_t cipher_key[reference->cipher_key.len + 1];
10947 uint8_t auth_key[reference->auth_key.len + 1];
10949 /* Verify the capabilities */
10950 struct rte_cryptodev_sym_capability_idx cap_idx;
10951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10952 cap_idx.algo.auth = reference->auth_algo;
10953 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10956 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10957 cap_idx.algo.cipher = reference->crypto_algo;
10958 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10962 /* Create session */
10963 memcpy(cipher_key, reference->cipher_key.data,
10964 reference->cipher_key.len);
10965 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10967 /* Setup Cipher Parameters */
10968 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10969 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10970 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10971 ut_params->cipher_xform.cipher.key.data = cipher_key;
10972 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10973 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10974 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10976 ut_params->cipher_xform.next = &ut_params->auth_xform;
10978 /* Setup Authentication Parameters */
10979 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10980 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10981 ut_params->auth_xform.auth.algo = reference->auth_algo;
10982 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10983 ut_params->auth_xform.auth.key.data = auth_key;
10984 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10985 ut_params->auth_xform.next = NULL;
10987 /* Create Crypto session*/
10988 ut_params->sess = rte_cryptodev_sym_session_create(
10989 ts_params->session_mpool);
10991 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10993 &ut_params->cipher_xform,
10994 ts_params->session_priv_mpool);
10996 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10998 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10999 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11000 "Failed to allocate input buffer in mempool");
11002 /* clear mbuf payload */
11003 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11004 rte_pktmbuf_tailroom(ut_params->ibuf));
11006 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11007 reference->plaintext.len);
11008 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11009 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11011 /* Create operation */
11012 retval = create_cipher_auth_operation(ts_params,
11019 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11020 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11023 ut_params->op = process_crypto_request(
11024 ts_params->valid_devs[0], ut_params->op);
11026 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11028 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11029 "crypto op processing failed");
11031 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11033 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11034 ut_params->op->sym->auth.data.offset);
11035 auth_tag = authciphertext + plaintext_pad_len;
11036 debug_hexdump(stdout, "ciphertext:", authciphertext,
11037 reference->ciphertext.len);
11038 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11040 /* Validate obuf */
11041 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11043 reference->ciphertext.data,
11044 reference->ciphertext.len,
11045 "Ciphertext data not as expected");
11047 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11049 reference->digest.data,
11050 reference->digest.len,
11051 "Generated digest not as expected");
11053 return TEST_SUCCESS;
11058 test_authenticated_decrypt_with_esn(
11059 struct crypto_testsuite_params *ts_params,
11060 struct crypto_unittest_params *ut_params,
11061 const struct test_crypto_vector *reference)
11065 uint8_t *ciphertext;
11066 uint8_t cipher_key[reference->cipher_key.len + 1];
11067 uint8_t auth_key[reference->auth_key.len + 1];
11069 /* Verify the capabilities */
11070 struct rte_cryptodev_sym_capability_idx cap_idx;
11071 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11072 cap_idx.algo.auth = reference->auth_algo;
11073 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11076 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11077 cap_idx.algo.cipher = reference->crypto_algo;
11078 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11082 /* Create session */
11083 memcpy(cipher_key, reference->cipher_key.data,
11084 reference->cipher_key.len);
11085 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11087 /* Setup Authentication Parameters */
11088 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11089 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11090 ut_params->auth_xform.auth.algo = reference->auth_algo;
11091 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11092 ut_params->auth_xform.auth.key.data = auth_key;
11093 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11094 ut_params->auth_xform.next = &ut_params->cipher_xform;
11096 /* Setup Cipher Parameters */
11097 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11098 ut_params->cipher_xform.next = NULL;
11099 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11100 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11101 ut_params->cipher_xform.cipher.key.data = cipher_key;
11102 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11103 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11104 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11106 /* Create Crypto session*/
11107 ut_params->sess = rte_cryptodev_sym_session_create(
11108 ts_params->session_mpool);
11110 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11112 &ut_params->auth_xform,
11113 ts_params->session_priv_mpool);
11115 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11117 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11118 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11119 "Failed to allocate input buffer in mempool");
11121 /* clear mbuf payload */
11122 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11123 rte_pktmbuf_tailroom(ut_params->ibuf));
11125 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11126 reference->ciphertext.len);
11127 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11128 memcpy(ciphertext, reference->ciphertext.data,
11129 reference->ciphertext.len);
11131 /* Create operation */
11132 retval = create_cipher_auth_verify_operation(ts_params,
11139 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11140 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11143 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11146 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11147 TEST_ASSERT_EQUAL(ut_params->op->status,
11148 RTE_CRYPTO_OP_STATUS_SUCCESS,
11149 "crypto op processing passed");
11151 ut_params->obuf = ut_params->op->sym->m_src;
11152 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11158 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11159 const struct aead_test_data *tdata,
11160 void *digest_mem, uint64_t digest_phys)
11162 struct crypto_testsuite_params *ts_params = &testsuite_params;
11163 struct crypto_unittest_params *ut_params = &unittest_params;
11165 const unsigned int auth_tag_len = tdata->auth_tag.len;
11166 const unsigned int iv_len = tdata->iv.len;
11167 unsigned int aad_len = tdata->aad.len;
11168 unsigned int aad_len_pad = 0;
11170 /* Generate Crypto op data structure */
11171 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11172 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11173 TEST_ASSERT_NOT_NULL(ut_params->op,
11174 "Failed to allocate symmetric crypto operation struct");
11176 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11178 sym_op->aead.digest.data = digest_mem;
11180 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11181 "no room to append digest");
11183 sym_op->aead.digest.phys_addr = digest_phys;
11185 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11186 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11188 debug_hexdump(stdout, "digest:",
11189 sym_op->aead.digest.data,
11193 /* Append aad data */
11194 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11195 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11196 uint8_t *, IV_OFFSET);
11198 /* Copy IV 1 byte after the IV pointer, according to the API */
11199 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11201 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11203 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11204 ut_params->ibuf, aad_len);
11205 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11206 "no room to prepend aad");
11207 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11210 memset(sym_op->aead.aad.data, 0, aad_len);
11211 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11212 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11214 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11215 debug_hexdump(stdout, "aad:",
11216 sym_op->aead.aad.data, aad_len);
11218 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11219 uint8_t *, IV_OFFSET);
11221 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11223 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11225 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11226 ut_params->ibuf, aad_len_pad);
11227 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11228 "no room to prepend aad");
11229 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11232 memset(sym_op->aead.aad.data, 0, aad_len);
11233 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11235 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11236 debug_hexdump(stdout, "aad:",
11237 sym_op->aead.aad.data, aad_len);
11240 sym_op->aead.data.length = tdata->plaintext.len;
11241 sym_op->aead.data.offset = aad_len_pad;
11246 #define SGL_MAX_NO 16
11249 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11250 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11252 struct crypto_testsuite_params *ts_params = &testsuite_params;
11253 struct crypto_unittest_params *ut_params = &unittest_params;
11254 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11257 int to_trn_tbl[SGL_MAX_NO];
11259 unsigned int trn_data = 0;
11260 uint8_t *plaintext, *ciphertext, *auth_tag;
11261 struct rte_cryptodev_info dev_info;
11263 /* Verify the capabilities */
11264 struct rte_cryptodev_sym_capability_idx cap_idx;
11265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11266 cap_idx.algo.aead = tdata->algo;
11267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11271 /* OOP not supported with CPU crypto */
11272 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11275 /* Detailed check for the particular SGL support flag */
11276 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11278 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11279 if (sgl_in && (!(dev_info.feature_flags &
11280 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11283 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11284 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11285 tdata->plaintext.len;
11286 if (sgl_in && !sgl_out) {
11287 if (!(dev_info.feature_flags &
11288 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11290 } else if (!sgl_in && sgl_out) {
11291 if (!(dev_info.feature_flags &
11292 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11294 } else if (sgl_in && sgl_out) {
11295 if (!(dev_info.feature_flags &
11296 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11301 if (fragsz > tdata->plaintext.len)
11302 fragsz = tdata->plaintext.len;
11304 uint16_t plaintext_len = fragsz;
11305 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11307 if (fragsz_oop > tdata->plaintext.len)
11308 frag_size_oop = tdata->plaintext.len;
11311 void *digest_mem = NULL;
11313 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11315 if (tdata->plaintext.len % fragsz != 0) {
11316 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11319 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11324 * For out-op-place we need to alloc another mbuf
11327 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11328 rte_pktmbuf_append(ut_params->obuf,
11329 frag_size_oop + prepend_len);
11330 buf_oop = ut_params->obuf;
11333 /* Create AEAD session */
11334 retval = create_aead_session(ts_params->valid_devs[0],
11336 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11337 tdata->key.data, tdata->key.len,
11338 tdata->aad.len, tdata->auth_tag.len,
11343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11345 /* clear mbuf payload */
11346 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11347 rte_pktmbuf_tailroom(ut_params->ibuf));
11349 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11352 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11354 trn_data += plaintext_len;
11356 buf = ut_params->ibuf;
11359 * Loop until no more fragments
11362 while (trn_data < tdata->plaintext.len) {
11364 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11365 (tdata->plaintext.len - trn_data) : fragsz;
11367 to_trn_tbl[ecx++] = to_trn;
11369 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11372 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11373 rte_pktmbuf_tailroom(buf));
11376 if (oop && !fragsz_oop) {
11377 buf_last_oop = buf_oop->next =
11378 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11379 buf_oop = buf_oop->next;
11380 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11381 0, rte_pktmbuf_tailroom(buf_oop));
11382 rte_pktmbuf_append(buf_oop, to_trn);
11385 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11388 memcpy(plaintext, tdata->plaintext.data + trn_data,
11390 trn_data += to_trn;
11391 if (trn_data == tdata->plaintext.len) {
11394 digest_mem = rte_pktmbuf_append(buf_oop,
11395 tdata->auth_tag.len);
11397 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11398 tdata->auth_tag.len);
11402 uint64_t digest_phys = 0;
11404 ut_params->ibuf->nb_segs = segs;
11407 if (fragsz_oop && oop) {
11411 if (frag_size_oop == tdata->plaintext.len) {
11412 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11413 tdata->auth_tag.len);
11415 digest_phys = rte_pktmbuf_iova_offset(
11417 tdata->plaintext.len + prepend_len);
11420 trn_data = frag_size_oop;
11421 while (trn_data < tdata->plaintext.len) {
11424 (tdata->plaintext.len - trn_data <
11426 (tdata->plaintext.len - trn_data) :
11429 to_trn_tbl[ecx++] = to_trn;
11431 buf_last_oop = buf_oop->next =
11432 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11433 buf_oop = buf_oop->next;
11434 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11435 0, rte_pktmbuf_tailroom(buf_oop));
11436 rte_pktmbuf_append(buf_oop, to_trn);
11438 trn_data += to_trn;
11440 if (trn_data == tdata->plaintext.len) {
11441 digest_mem = rte_pktmbuf_append(buf_oop,
11442 tdata->auth_tag.len);
11446 ut_params->obuf->nb_segs = segs;
11450 * Place digest at the end of the last buffer
11453 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11454 if (oop && buf_last_oop)
11455 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11457 if (!digest_mem && !oop) {
11458 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11459 + tdata->auth_tag.len);
11460 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11461 tdata->plaintext.len);
11464 /* Create AEAD operation */
11465 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11466 tdata, digest_mem, digest_phys);
11471 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11473 ut_params->op->sym->m_src = ut_params->ibuf;
11475 ut_params->op->sym->m_dst = ut_params->obuf;
11477 /* Process crypto operation */
11478 if (oop == IN_PLACE &&
11479 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11480 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11482 TEST_ASSERT_NOT_NULL(
11483 process_crypto_request(ts_params->valid_devs[0],
11484 ut_params->op), "failed to process sym crypto op");
11486 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11487 "crypto op processing failed");
11490 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11491 uint8_t *, prepend_len);
11493 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11494 uint8_t *, prepend_len);
11498 fragsz = fragsz_oop;
11500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11502 tdata->ciphertext.data,
11504 "Ciphertext data not as expected");
11506 buf = ut_params->op->sym->m_src->next;
11508 buf = ut_params->op->sym->m_dst->next;
11510 unsigned int off = fragsz;
11514 ciphertext = rte_pktmbuf_mtod(buf,
11517 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11519 tdata->ciphertext.data + off,
11521 "Ciphertext data not as expected");
11523 off += to_trn_tbl[ecx++];
11527 auth_tag = digest_mem;
11528 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11530 tdata->auth_tag.data,
11531 tdata->auth_tag.len,
11532 "Generated auth tag not as expected");
11538 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11540 return test_authenticated_encryption_SGL(
11541 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11545 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11547 return test_authenticated_encryption_SGL(
11548 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11552 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11554 return test_authenticated_encryption_SGL(
11555 &gcm_test_case_8, OUT_OF_PLACE, 400,
11556 gcm_test_case_8.plaintext.len);
11560 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11562 /* This test is not for OPENSSL PMD */
11563 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11564 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11567 return test_authenticated_encryption_SGL(
11568 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11572 test_authentication_verify_fail_when_data_corrupted(
11573 struct crypto_testsuite_params *ts_params,
11574 struct crypto_unittest_params *ut_params,
11575 const struct test_crypto_vector *reference)
11577 return test_authentication_verify_fail_when_data_corruption(
11578 ts_params, ut_params, reference, 1);
11582 test_authentication_verify_fail_when_tag_corrupted(
11583 struct crypto_testsuite_params *ts_params,
11584 struct crypto_unittest_params *ut_params,
11585 const struct test_crypto_vector *reference)
11587 return test_authentication_verify_fail_when_data_corruption(
11588 ts_params, ut_params, reference, 0);
11592 test_authentication_verify_GMAC_fail_when_data_corrupted(
11593 struct crypto_testsuite_params *ts_params,
11594 struct crypto_unittest_params *ut_params,
11595 const struct test_crypto_vector *reference)
11597 return test_authentication_verify_GMAC_fail_when_corruption(
11598 ts_params, ut_params, reference, 1);
11602 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11603 struct crypto_testsuite_params *ts_params,
11604 struct crypto_unittest_params *ut_params,
11605 const struct test_crypto_vector *reference)
11607 return test_authentication_verify_GMAC_fail_when_corruption(
11608 ts_params, ut_params, reference, 0);
11612 test_authenticated_decryption_fail_when_data_corrupted(
11613 struct crypto_testsuite_params *ts_params,
11614 struct crypto_unittest_params *ut_params,
11615 const struct test_crypto_vector *reference)
11617 return test_authenticated_decryption_fail_when_corruption(
11618 ts_params, ut_params, reference, 1);
11622 test_authenticated_decryption_fail_when_tag_corrupted(
11623 struct crypto_testsuite_params *ts_params,
11624 struct crypto_unittest_params *ut_params,
11625 const struct test_crypto_vector *reference)
11627 return test_authenticated_decryption_fail_when_corruption(
11628 ts_params, ut_params, reference, 0);
11632 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11634 return test_authentication_verify_fail_when_data_corrupted(
11635 &testsuite_params, &unittest_params,
11636 &hmac_sha1_test_crypto_vector);
11640 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11642 return test_authentication_verify_fail_when_tag_corrupted(
11643 &testsuite_params, &unittest_params,
11644 &hmac_sha1_test_crypto_vector);
11648 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11650 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11651 &testsuite_params, &unittest_params,
11652 &aes128_gmac_test_vector);
11656 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11658 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11659 &testsuite_params, &unittest_params,
11660 &aes128_gmac_test_vector);
11664 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11666 return test_authenticated_decryption_fail_when_data_corrupted(
11669 &aes128cbc_hmac_sha1_test_vector);
11673 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11675 return test_authenticated_decryption_fail_when_tag_corrupted(
11678 &aes128cbc_hmac_sha1_test_vector);
11682 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11684 return test_authenticated_encryt_with_esn(
11687 &aes128cbc_hmac_sha1_aad_test_vector);
11691 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11693 return test_authenticated_decrypt_with_esn(
11696 &aes128cbc_hmac_sha1_aad_test_vector);
11700 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
11702 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
11706 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
11708 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
11711 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11713 /* global AESNI worker IDs for the scheduler test */
11714 uint8_t aesni_ids[2];
11717 test_scheduler_attach_slave_op(void)
11719 struct crypto_testsuite_params *ts_params = &testsuite_params;
11720 uint8_t sched_id = ts_params->valid_devs[0];
11721 uint32_t nb_devs, i, nb_devs_attached = 0;
11723 char vdev_name[32];
11725 /* create 2 AESNI_MB if necessary */
11726 nb_devs = rte_cryptodev_device_count_by_driver(
11727 rte_cryptodev_driver_id_get(
11728 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11730 for (i = nb_devs; i < 2; i++) {
11731 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11732 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11734 ret = rte_vdev_init(vdev_name, NULL);
11736 TEST_ASSERT(ret == 0,
11737 "Failed to create instance %u of"
11739 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11743 /* attach 2 AESNI_MB cdevs */
11744 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11746 struct rte_cryptodev_info info;
11747 unsigned int session_size;
11749 rte_cryptodev_info_get(i, &info);
11750 if (info.driver_id != rte_cryptodev_driver_id_get(
11751 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11754 session_size = rte_cryptodev_sym_get_private_session_size(i);
11756 * Create the session mempool again, since now there are new devices
11757 * to use the mempool.
11759 if (ts_params->session_mpool) {
11760 rte_mempool_free(ts_params->session_mpool);
11761 ts_params->session_mpool = NULL;
11763 if (ts_params->session_priv_mpool) {
11764 rte_mempool_free(ts_params->session_priv_mpool);
11765 ts_params->session_priv_mpool = NULL;
11768 if (info.sym.max_nb_sessions != 0 &&
11769 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11770 RTE_LOG(ERR, USER1,
11771 "Device does not support "
11772 "at least %u sessions\n",
11774 return TEST_FAILED;
11777 * Create mempool with maximum number of sessions,
11778 * to include the session headers
11780 if (ts_params->session_mpool == NULL) {
11781 ts_params->session_mpool =
11782 rte_cryptodev_sym_session_pool_create(
11784 MAX_NB_SESSIONS, 0, 0, 0,
11786 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11787 "session mempool allocation failed");
11791 * Create mempool with maximum number of sessions,
11792 * to include device specific session private data
11794 if (ts_params->session_priv_mpool == NULL) {
11795 ts_params->session_priv_mpool = rte_mempool_create(
11796 "test_sess_mp_priv",
11799 0, 0, NULL, NULL, NULL,
11800 NULL, SOCKET_ID_ANY,
11803 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11804 "session mempool allocation failed");
11807 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11808 ts_params->qp_conf.mp_session_private =
11809 ts_params->session_priv_mpool;
11811 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
11814 TEST_ASSERT(ret == 0,
11815 "Failed to attach device %u of pmd : %s", i,
11816 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11818 aesni_ids[nb_devs_attached] = (uint8_t)i;
11820 nb_devs_attached++;
11827 test_scheduler_detach_slave_op(void)
11829 struct crypto_testsuite_params *ts_params = &testsuite_params;
11830 uint8_t sched_id = ts_params->valid_devs[0];
11834 for (i = 0; i < 2; i++) {
11835 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
11837 TEST_ASSERT(ret == 0,
11838 "Failed to detach device %u", aesni_ids[i]);
11845 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11847 struct crypto_testsuite_params *ts_params = &testsuite_params;
11848 uint8_t sched_id = ts_params->valid_devs[0];
11850 return rte_cryptodev_scheduler_mode_set(sched_id,
11855 test_scheduler_mode_roundrobin_op(void)
11857 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11858 0, "Failed to set roundrobin mode");
11864 test_scheduler_mode_multicore_op(void)
11866 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11867 0, "Failed to set multicore mode");
11873 test_scheduler_mode_failover_op(void)
11875 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11876 0, "Failed to set failover mode");
11882 test_scheduler_mode_pkt_size_distr_op(void)
11884 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11885 0, "Failed to set pktsize mode");
11890 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11891 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11892 .setup = testsuite_setup,
11893 .teardown = testsuite_teardown,
11894 .unit_test_cases = {
11896 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11897 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11898 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11899 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11900 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11901 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11904 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11905 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11906 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11907 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11908 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11909 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11912 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11913 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11914 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11915 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11916 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11917 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11920 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11921 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11922 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11923 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11924 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11925 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11927 TEST_CASES_END() /**< NULL terminate unit test array */
11931 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11933 static struct unit_test_suite cryptodev_testsuite = {
11934 .suite_name = "Crypto Unit Test Suite",
11935 .setup = testsuite_setup,
11936 .teardown = testsuite_teardown,
11937 .unit_test_cases = {
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_device_configure_invalid_dev_id),
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_queue_pair_descriptor_setup),
11942 TEST_CASE_ST(ut_setup, ut_teardown,
11943 test_device_configure_invalid_queue_pair_ids),
11945 TEST_CASE_ST(ut_setup, ut_teardown,
11946 test_multi_session),
11947 TEST_CASE_ST(ut_setup, ut_teardown,
11948 test_multi_session_random_usage),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_null_invalid_operation),
11952 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
11954 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
11955 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
11956 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
11957 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
11958 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
11959 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
11960 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
11961 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
11962 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11964 /** AES CCM Authenticated Encryption 128 bits key */
11965 TEST_CASE_ST(ut_setup, ut_teardown,
11966 test_AES_CCM_authenticated_encryption_test_case_128_1),
11967 TEST_CASE_ST(ut_setup, ut_teardown,
11968 test_AES_CCM_authenticated_encryption_test_case_128_2),
11969 TEST_CASE_ST(ut_setup, ut_teardown,
11970 test_AES_CCM_authenticated_encryption_test_case_128_3),
11972 /** AES CCM Authenticated Decryption 128 bits key*/
11973 TEST_CASE_ST(ut_setup, ut_teardown,
11974 test_AES_CCM_authenticated_decryption_test_case_128_1),
11975 TEST_CASE_ST(ut_setup, ut_teardown,
11976 test_AES_CCM_authenticated_decryption_test_case_128_2),
11977 TEST_CASE_ST(ut_setup, ut_teardown,
11978 test_AES_CCM_authenticated_decryption_test_case_128_3),
11980 /** AES CCM Authenticated Encryption 192 bits key */
11981 TEST_CASE_ST(ut_setup, ut_teardown,
11982 test_AES_CCM_authenticated_encryption_test_case_192_1),
11983 TEST_CASE_ST(ut_setup, ut_teardown,
11984 test_AES_CCM_authenticated_encryption_test_case_192_2),
11985 TEST_CASE_ST(ut_setup, ut_teardown,
11986 test_AES_CCM_authenticated_encryption_test_case_192_3),
11988 /** AES CCM Authenticated Decryption 192 bits key*/
11989 TEST_CASE_ST(ut_setup, ut_teardown,
11990 test_AES_CCM_authenticated_decryption_test_case_192_1),
11991 TEST_CASE_ST(ut_setup, ut_teardown,
11992 test_AES_CCM_authenticated_decryption_test_case_192_2),
11993 TEST_CASE_ST(ut_setup, ut_teardown,
11994 test_AES_CCM_authenticated_decryption_test_case_192_3),
11996 /** AES CCM Authenticated Encryption 256 bits key */
11997 TEST_CASE_ST(ut_setup, ut_teardown,
11998 test_AES_CCM_authenticated_encryption_test_case_256_1),
11999 TEST_CASE_ST(ut_setup, ut_teardown,
12000 test_AES_CCM_authenticated_encryption_test_case_256_2),
12001 TEST_CASE_ST(ut_setup, ut_teardown,
12002 test_AES_CCM_authenticated_encryption_test_case_256_3),
12004 /** AES CCM Authenticated Decryption 256 bits key*/
12005 TEST_CASE_ST(ut_setup, ut_teardown,
12006 test_AES_CCM_authenticated_decryption_test_case_256_1),
12007 TEST_CASE_ST(ut_setup, ut_teardown,
12008 test_AES_CCM_authenticated_decryption_test_case_256_2),
12009 TEST_CASE_ST(ut_setup, ut_teardown,
12010 test_AES_CCM_authenticated_decryption_test_case_256_3),
12012 /** AES GCM Authenticated Encryption */
12013 TEST_CASE_ST(ut_setup, ut_teardown,
12014 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12015 TEST_CASE_ST(ut_setup, ut_teardown,
12016 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12017 TEST_CASE_ST(ut_setup, ut_teardown,
12018 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12019 TEST_CASE_ST(ut_setup, ut_teardown,
12020 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12021 TEST_CASE_ST(ut_setup, ut_teardown,
12022 test_AES_GCM_authenticated_encryption_test_case_1),
12023 TEST_CASE_ST(ut_setup, ut_teardown,
12024 test_AES_GCM_authenticated_encryption_test_case_2),
12025 TEST_CASE_ST(ut_setup, ut_teardown,
12026 test_AES_GCM_authenticated_encryption_test_case_3),
12027 TEST_CASE_ST(ut_setup, ut_teardown,
12028 test_AES_GCM_authenticated_encryption_test_case_4),
12029 TEST_CASE_ST(ut_setup, ut_teardown,
12030 test_AES_GCM_authenticated_encryption_test_case_5),
12031 TEST_CASE_ST(ut_setup, ut_teardown,
12032 test_AES_GCM_authenticated_encryption_test_case_6),
12033 TEST_CASE_ST(ut_setup, ut_teardown,
12034 test_AES_GCM_authenticated_encryption_test_case_7),
12035 TEST_CASE_ST(ut_setup, ut_teardown,
12036 test_AES_GCM_authenticated_encryption_test_case_8),
12037 TEST_CASE_ST(ut_setup, ut_teardown,
12038 test_AES_GCM_J0_authenticated_encryption_test_case_1),
12040 /** AES GCM Authenticated Decryption */
12041 TEST_CASE_ST(ut_setup, ut_teardown,
12042 test_AES_GCM_authenticated_decryption_test_case_1),
12043 TEST_CASE_ST(ut_setup, ut_teardown,
12044 test_AES_GCM_authenticated_decryption_test_case_2),
12045 TEST_CASE_ST(ut_setup, ut_teardown,
12046 test_AES_GCM_authenticated_decryption_test_case_3),
12047 TEST_CASE_ST(ut_setup, ut_teardown,
12048 test_AES_GCM_authenticated_decryption_test_case_4),
12049 TEST_CASE_ST(ut_setup, ut_teardown,
12050 test_AES_GCM_authenticated_decryption_test_case_5),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_AES_GCM_authenticated_decryption_test_case_6),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_AES_GCM_authenticated_decryption_test_case_7),
12055 TEST_CASE_ST(ut_setup, ut_teardown,
12056 test_AES_GCM_authenticated_decryption_test_case_8),
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_AES_GCM_J0_authenticated_decryption_test_case_1),
12060 /** AES GCM Authenticated Encryption 192 bits key */
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_AES_GCM_auth_encryption_test_case_192_1),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_AES_GCM_auth_encryption_test_case_192_2),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_AES_GCM_auth_encryption_test_case_192_3),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_AES_GCM_auth_encryption_test_case_192_4),
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_AES_GCM_auth_encryption_test_case_192_5),
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_AES_GCM_auth_encryption_test_case_192_6),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_AES_GCM_auth_encryption_test_case_192_7),
12076 /** AES GCM Authenticated Decryption 192 bits key */
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_AES_GCM_auth_decryption_test_case_192_1),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_AES_GCM_auth_decryption_test_case_192_2),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_AES_GCM_auth_decryption_test_case_192_3),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_AES_GCM_auth_decryption_test_case_192_4),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_AES_GCM_auth_decryption_test_case_192_5),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_AES_GCM_auth_decryption_test_case_192_6),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_AES_GCM_auth_decryption_test_case_192_7),
12092 /** AES GCM Authenticated Encryption 256 bits key */
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_AES_GCM_auth_encryption_test_case_256_1),
12095 TEST_CASE_ST(ut_setup, ut_teardown,
12096 test_AES_GCM_auth_encryption_test_case_256_2),
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_AES_GCM_auth_encryption_test_case_256_3),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_AES_GCM_auth_encryption_test_case_256_4),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_AES_GCM_auth_encryption_test_case_256_5),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_AES_GCM_auth_encryption_test_case_256_6),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_AES_GCM_auth_encryption_test_case_256_7),
12108 /** AES GCM Authenticated Decryption 256 bits key */
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_AES_GCM_auth_decryption_test_case_256_1),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_AES_GCM_auth_decryption_test_case_256_2),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_AES_GCM_auth_decryption_test_case_256_3),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_AES_GCM_auth_decryption_test_case_256_4),
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_AES_GCM_auth_decryption_test_case_256_5),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_AES_GCM_auth_decryption_test_case_256_6),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_AES_GCM_auth_decryption_test_case_256_7),
12124 /** AES GCM Authenticated Encryption big aad size */
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_AES_GCM_auth_encryption_test_case_aad_1),
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_AES_GCM_auth_encryption_test_case_aad_2),
12130 /** AES GCM Authenticated Decryption big aad size */
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_AES_GCM_auth_decryption_test_case_aad_1),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_AES_GCM_auth_decryption_test_case_aad_2),
12136 /** Out of place tests */
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12142 /** Session-less tests */
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12148 /** AES GMAC Authentication */
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_AES_GMAC_authentication_test_case_1),
12151 TEST_CASE_ST(ut_setup, ut_teardown,
12152 test_AES_GMAC_authentication_verify_test_case_1),
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_AES_GMAC_authentication_test_case_2),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_AES_GMAC_authentication_verify_test_case_2),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_AES_GMAC_authentication_test_case_3),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_AES_GMAC_authentication_verify_test_case_3),
12161 TEST_CASE_ST(ut_setup, ut_teardown,
12162 test_AES_GMAC_authentication_test_case_4),
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_AES_GMAC_authentication_verify_test_case_4),
12165 /** Chacha20-Poly1305 */
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_chacha20_poly1305_encrypt_test_case_rfc8439),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_chacha20_poly1305_decrypt_test_case_rfc8439),
12170 /** SNOW 3G encrypt only (UEA2) */
12171 TEST_CASE_ST(ut_setup, ut_teardown,
12172 test_snow3g_encryption_test_case_1),
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 test_snow3g_encryption_test_case_2),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_snow3g_encryption_test_case_3),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_snow3g_encryption_test_case_4),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_snow3g_encryption_test_case_5),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_snow3g_encryption_test_case_1_oop),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_snow3g_encryption_test_case_1_oop_sgl),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_snow3g_encryption_test_case_1_offset_oop),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_snow3g_decryption_test_case_1_oop),
12191 /** SNOW 3G generate auth, then encrypt (UEA2) */
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_snow3g_auth_cipher_test_case_1),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_snow3g_auth_cipher_test_case_2),
12196 TEST_CASE_ST(ut_setup, ut_teardown,
12197 test_snow3g_auth_cipher_test_case_2_oop),
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_snow3g_auth_cipher_part_digest_enc),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_snow3g_auth_cipher_part_digest_enc_oop),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_snow3g_auth_cipher_test_case_3_sgl),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_snow3g_auth_cipher_part_digest_enc_sgl),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12211 /** SNOW 3G decrypt (UEA2), then verify auth */
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_snow3g_auth_cipher_verify_test_case_1),
12214 TEST_CASE_ST(ut_setup, ut_teardown,
12215 test_snow3g_auth_cipher_verify_test_case_2),
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_snow3g_auth_cipher_verify_test_case_2_oop),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_snow3g_auth_cipher_verify_part_digest_enc),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12226 TEST_CASE_ST(ut_setup, ut_teardown,
12227 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12231 /** SNOW 3G decrypt only (UEA2) */
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_snow3g_decryption_test_case_1),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_snow3g_decryption_test_case_2),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_snow3g_decryption_test_case_3),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_snow3g_decryption_test_case_4),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_snow3g_decryption_test_case_5),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_snow3g_decryption_with_digest_test_case_1),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_snow3g_hash_generate_test_case_1),
12246 TEST_CASE_ST(ut_setup, ut_teardown,
12247 test_snow3g_hash_generate_test_case_2),
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_snow3g_hash_generate_test_case_3),
12250 /* Tests with buffers which length is not byte-aligned */
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_snow3g_hash_generate_test_case_4),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_snow3g_hash_generate_test_case_5),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_snow3g_hash_generate_test_case_6),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_snow3g_hash_verify_test_case_1),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_snow3g_hash_verify_test_case_2),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_snow3g_hash_verify_test_case_3),
12263 /* Tests with buffers which length is not byte-aligned */
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_snow3g_hash_verify_test_case_4),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_snow3g_hash_verify_test_case_5),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_snow3g_hash_verify_test_case_6),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_snow3g_cipher_auth_test_case_1),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_snow3g_auth_cipher_with_digest_test_case_1),
12275 /** ZUC encrypt only (EEA3) */
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_zuc_encryption_test_case_1),
12278 TEST_CASE_ST(ut_setup, ut_teardown,
12279 test_zuc_encryption_test_case_2),
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_zuc_encryption_test_case_3),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_zuc_encryption_test_case_4),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_zuc_encryption_test_case_5),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_zuc_encryption_test_case_6_sgl),
12289 /** ZUC authenticate (EIA3) */
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_zuc_hash_generate_test_case_1),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_zuc_hash_generate_test_case_2),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_zuc_hash_generate_test_case_3),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_zuc_hash_generate_test_case_4),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_zuc_hash_generate_test_case_5),
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_zuc_hash_generate_test_case_6),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_zuc_hash_generate_test_case_7),
12304 TEST_CASE_ST(ut_setup, ut_teardown,
12305 test_zuc_hash_generate_test_case_8),
12307 /** ZUC alg-chain (EEA3/EIA3) */
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 test_zuc_cipher_auth_test_case_1),
12310 TEST_CASE_ST(ut_setup, ut_teardown,
12311 test_zuc_cipher_auth_test_case_2),
12313 /** ZUC generate auth, then encrypt (EEA3) */
12314 TEST_CASE_ST(ut_setup, ut_teardown,
12315 test_zuc_auth_cipher_test_case_1),
12316 TEST_CASE_ST(ut_setup, ut_teardown,
12317 test_zuc_auth_cipher_test_case_1_oop),
12318 TEST_CASE_ST(ut_setup, ut_teardown,
12319 test_zuc_auth_cipher_test_case_1_sgl),
12320 TEST_CASE_ST(ut_setup, ut_teardown,
12321 test_zuc_auth_cipher_test_case_1_oop_sgl),
12323 /** ZUC decrypt (EEA3), then verify auth */
12324 TEST_CASE_ST(ut_setup, ut_teardown,
12325 test_zuc_auth_cipher_verify_test_case_1),
12326 TEST_CASE_ST(ut_setup, ut_teardown,
12327 test_zuc_auth_cipher_verify_test_case_1_oop),
12328 TEST_CASE_ST(ut_setup, ut_teardown,
12329 test_zuc_auth_cipher_verify_test_case_1_sgl),
12330 TEST_CASE_ST(ut_setup, ut_teardown,
12331 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12333 /** HMAC_MD5 Authentication */
12334 TEST_CASE_ST(ut_setup, ut_teardown,
12335 test_MD5_HMAC_generate_case_1),
12336 TEST_CASE_ST(ut_setup, ut_teardown,
12337 test_MD5_HMAC_verify_case_1),
12338 TEST_CASE_ST(ut_setup, ut_teardown,
12339 test_MD5_HMAC_generate_case_2),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_MD5_HMAC_verify_case_2),
12343 /** KASUMI hash only (UIA1) */
12344 TEST_CASE_ST(ut_setup, ut_teardown,
12345 test_kasumi_hash_generate_test_case_1),
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_kasumi_hash_generate_test_case_2),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_kasumi_hash_generate_test_case_3),
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_kasumi_hash_generate_test_case_4),
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_kasumi_hash_generate_test_case_5),
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_kasumi_hash_generate_test_case_6),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_kasumi_hash_verify_test_case_1),
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_kasumi_hash_verify_test_case_2),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_kasumi_hash_verify_test_case_3),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_kasumi_hash_verify_test_case_4),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_kasumi_hash_verify_test_case_5),
12368 /** KASUMI encrypt only (UEA1) */
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_kasumi_encryption_test_case_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_kasumi_encryption_test_case_1_sgl),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_kasumi_encryption_test_case_1_oop),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_kasumi_encryption_test_case_1_oop_sgl),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_kasumi_encryption_test_case_2),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_kasumi_encryption_test_case_3),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_kasumi_encryption_test_case_4),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_kasumi_encryption_test_case_5),
12386 /** KASUMI decrypt only (UEA1) */
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_kasumi_decryption_test_case_1),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_kasumi_decryption_test_case_2),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_kasumi_decryption_test_case_3),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_kasumi_decryption_test_case_4),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_kasumi_decryption_test_case_5),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_kasumi_decryption_test_case_1_oop),
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_kasumi_cipher_auth_test_case_1),
12403 /** KASUMI generate auth, then encrypt (F8) */
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_kasumi_auth_cipher_test_case_1),
12406 TEST_CASE_ST(ut_setup, ut_teardown,
12407 test_kasumi_auth_cipher_test_case_2),
12408 TEST_CASE_ST(ut_setup, ut_teardown,
12409 test_kasumi_auth_cipher_test_case_2_oop),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_kasumi_auth_cipher_test_case_2_sgl),
12412 TEST_CASE_ST(ut_setup, ut_teardown,
12413 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12415 /** KASUMI decrypt (F8), then verify auth */
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_kasumi_auth_cipher_verify_test_case_1),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_kasumi_auth_cipher_verify_test_case_2),
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_kasumi_auth_cipher_verify_test_case_2_oop),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12427 /** ESN Testcase */
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12433 /** Negative tests */
12434 TEST_CASE_ST(ut_setup, ut_teardown,
12435 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12436 TEST_CASE_ST(ut_setup, ut_teardown,
12437 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12440 TEST_CASE_ST(ut_setup, ut_teardown,
12441 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12450 TEST_CASE_ST(ut_setup, ut_teardown,
12451 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 authentication_verify_AES128_GMAC_fail_data_corrupt),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12471 /** Mixed CIPHER + HASH algorithms */
12472 /** AUTH AES CMAC + CIPHER AES CTR */
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12483 TEST_CASE_ST(ut_setup, ut_teardown,
12484 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12490 /** AUTH ZUC + CIPHER SNOW3G */
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_auth_zuc_cipher_snow_test_case_1),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_verify_auth_zuc_cipher_snow_test_case_1),
12495 /** AUTH AES CMAC + CIPHER SNOW3G */
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_auth_aes_cmac_cipher_snow_test_case_1),
12498 TEST_CASE_ST(ut_setup, ut_teardown,
12499 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12500 /** AUTH ZUC + CIPHER AES CTR */
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_auth_zuc_cipher_aes_ctr_test_case_1),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12505 /** AUTH SNOW3G + CIPHER AES CTR */
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_auth_snow_cipher_aes_ctr_test_case_1),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12510 /** AUTH SNOW3G + CIPHER ZUC */
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_auth_snow_cipher_zuc_test_case_1),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_verify_auth_snow_cipher_zuc_test_case_1),
12515 /** AUTH AES CMAC + CIPHER ZUC */
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_auth_aes_cmac_cipher_zuc_test_case_1),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12521 /** AUTH NULL + CIPHER SNOW3G */
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_auth_null_cipher_snow_test_case_1),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_verify_auth_null_cipher_snow_test_case_1),
12526 /** AUTH NULL + CIPHER ZUC */
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 test_auth_null_cipher_zuc_test_case_1),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_verify_auth_null_cipher_zuc_test_case_1),
12531 /** AUTH SNOW3G + CIPHER NULL */
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 test_auth_snow_cipher_null_test_case_1),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 test_verify_auth_snow_cipher_null_test_case_1),
12536 /** AUTH ZUC + CIPHER NULL */
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_auth_zuc_cipher_null_test_case_1),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_verify_auth_zuc_cipher_null_test_case_1),
12541 /** AUTH NULL + CIPHER AES CTR */
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_auth_null_cipher_aes_ctr_test_case_1),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12546 /** AUTH AES CMAC + CIPHER NULL */
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_auth_aes_cmac_cipher_null_test_case_1),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12552 #ifdef RTE_LIBRTE_SECURITY
12553 TEST_CASE_ST(ut_setup_security, ut_teardown,
12554 test_PDCP_PROTO_all),
12555 TEST_CASE_ST(ut_setup_security, ut_teardown,
12556 test_DOCSIS_PROTO_all),
12558 TEST_CASES_END() /**< NULL terminate unit test array */
12562 static struct unit_test_suite cryptodev_virtio_testsuite = {
12563 .suite_name = "Crypto VIRTIO Unit Test Suite",
12564 .setup = testsuite_setup,
12565 .teardown = testsuite_teardown,
12566 .unit_test_cases = {
12567 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12569 TEST_CASES_END() /**< NULL terminate unit test array */
12573 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12574 .suite_name = "Crypto CAAM JR Unit Test Suite",
12575 .setup = testsuite_setup,
12576 .teardown = testsuite_teardown,
12577 .unit_test_cases = {
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_device_configure_invalid_dev_id),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_multi_session),
12583 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12584 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12585 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12586 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12587 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12589 TEST_CASES_END() /**< NULL terminate unit test array */
12593 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12594 .suite_name = "Crypto Device Marvell Component Test Suite",
12595 .setup = testsuite_setup,
12596 .teardown = testsuite_teardown,
12597 .unit_test_cases = {
12598 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_multi_session_random_usage),
12601 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12602 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12603 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12604 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12605 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12607 /** Negative tests */
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12617 TEST_CASES_END() /**< NULL terminate unit test array */
12621 static struct unit_test_suite cryptodev_ccp_testsuite = {
12622 .suite_name = "Crypto Device CCP Unit Test Suite",
12623 .setup = testsuite_setup,
12624 .teardown = testsuite_teardown,
12625 .unit_test_cases = {
12626 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_multi_session_random_usage),
12629 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12630 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12631 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12632 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12633 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12635 /** Negative tests */
12636 TEST_CASE_ST(ut_setup, ut_teardown,
12637 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12638 TEST_CASE_ST(ut_setup, ut_teardown,
12639 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12645 TEST_CASES_END() /**< NULL terminate unit test array */
12650 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12652 gbl_driver_id = rte_cryptodev_driver_id_get(
12653 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12655 if (gbl_driver_id == -1) {
12656 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
12657 return TEST_SKIPPED;
12660 return unit_test_suite_runner(&cryptodev_testsuite);
12664 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12666 gbl_driver_id = rte_cryptodev_driver_id_get(
12667 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12669 if (gbl_driver_id == -1) {
12670 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
12671 return TEST_FAILED;
12674 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12678 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12680 gbl_driver_id = rte_cryptodev_driver_id_get(
12681 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12683 if (gbl_driver_id == -1) {
12684 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
12685 return TEST_SKIPPED;
12688 return unit_test_suite_runner(&cryptodev_testsuite);
12692 test_cryptodev_cpu_aesni_mb(void)
12695 enum rte_security_session_action_type at;
12697 gbl_driver_id = rte_cryptodev_driver_id_get(
12698 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12700 if (gbl_driver_id == -1) {
12701 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
12702 return TEST_SKIPPED;
12705 at = gbl_action_type;
12706 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12707 rc = unit_test_suite_runner(&cryptodev_testsuite);
12708 gbl_action_type = at;
12713 test_cryptodev_openssl(void)
12715 gbl_driver_id = rte_cryptodev_driver_id_get(
12716 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12718 if (gbl_driver_id == -1) {
12719 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
12720 return TEST_SKIPPED;
12723 return unit_test_suite_runner(&cryptodev_testsuite);
12727 test_cryptodev_aesni_gcm(void)
12729 gbl_driver_id = rte_cryptodev_driver_id_get(
12730 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12732 if (gbl_driver_id == -1) {
12733 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
12734 return TEST_SKIPPED;
12737 return unit_test_suite_runner(&cryptodev_testsuite);
12741 test_cryptodev_cpu_aesni_gcm(void)
12744 enum rte_security_session_action_type at;
12746 gbl_driver_id = rte_cryptodev_driver_id_get(
12747 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12749 if (gbl_driver_id == -1) {
12750 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
12751 return TEST_SKIPPED;
12754 at = gbl_action_type;
12755 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12756 rc = unit_test_suite_runner(&cryptodev_testsuite);
12757 gbl_action_type = at;
12762 test_cryptodev_null(void)
12764 gbl_driver_id = rte_cryptodev_driver_id_get(
12765 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12767 if (gbl_driver_id == -1) {
12768 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
12769 return TEST_SKIPPED;
12772 return unit_test_suite_runner(&cryptodev_testsuite);
12776 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12778 gbl_driver_id = rte_cryptodev_driver_id_get(
12779 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12781 if (gbl_driver_id == -1) {
12782 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
12783 return TEST_SKIPPED;
12786 return unit_test_suite_runner(&cryptodev_testsuite);
12790 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12792 gbl_driver_id = rte_cryptodev_driver_id_get(
12793 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12795 if (gbl_driver_id == -1) {
12796 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
12797 return TEST_SKIPPED;
12800 return unit_test_suite_runner(&cryptodev_testsuite);
12804 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12806 gbl_driver_id = rte_cryptodev_driver_id_get(
12807 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12809 if (gbl_driver_id == -1) {
12810 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
12811 return TEST_SKIPPED;
12814 return unit_test_suite_runner(&cryptodev_testsuite);
12818 test_cryptodev_armv8(void)
12820 gbl_driver_id = rte_cryptodev_driver_id_get(
12821 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12823 if (gbl_driver_id == -1) {
12824 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
12825 return TEST_SKIPPED;
12828 return unit_test_suite_runner(&cryptodev_testsuite);
12832 test_cryptodev_mrvl(void)
12834 gbl_driver_id = rte_cryptodev_driver_id_get(
12835 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12837 if (gbl_driver_id == -1) {
12838 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
12839 return TEST_SKIPPED;
12842 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12845 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12848 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12850 gbl_driver_id = rte_cryptodev_driver_id_get(
12851 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12853 if (gbl_driver_id == -1) {
12854 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
12855 return TEST_SKIPPED;
12858 if (rte_cryptodev_driver_id_get(
12859 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12860 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
12861 return TEST_SKIPPED;
12863 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12866 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12871 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12873 gbl_driver_id = rte_cryptodev_driver_id_get(
12874 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12876 if (gbl_driver_id == -1) {
12877 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
12878 return TEST_SKIPPED;
12881 return unit_test_suite_runner(&cryptodev_testsuite);
12885 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12887 gbl_driver_id = rte_cryptodev_driver_id_get(
12888 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12890 if (gbl_driver_id == -1) {
12891 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
12892 return TEST_SKIPPED;
12895 return unit_test_suite_runner(&cryptodev_testsuite);
12899 test_cryptodev_ccp(void)
12901 gbl_driver_id = rte_cryptodev_driver_id_get(
12902 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12904 if (gbl_driver_id == -1) {
12905 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
12906 return TEST_FAILED;
12909 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12913 test_cryptodev_octeontx(void)
12915 gbl_driver_id = rte_cryptodev_driver_id_get(
12916 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12917 if (gbl_driver_id == -1) {
12918 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
12919 return TEST_FAILED;
12921 return unit_test_suite_runner(&cryptodev_testsuite);
12925 test_cryptodev_octeontx2(void)
12927 gbl_driver_id = rte_cryptodev_driver_id_get(
12928 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
12929 if (gbl_driver_id == -1) {
12930 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
12931 return TEST_FAILED;
12933 return unit_test_suite_runner(&cryptodev_testsuite);
12937 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12939 gbl_driver_id = rte_cryptodev_driver_id_get(
12940 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
12942 if (gbl_driver_id == -1) {
12943 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
12944 return TEST_FAILED;
12947 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
12951 test_cryptodev_nitrox(void)
12953 gbl_driver_id = rte_cryptodev_driver_id_get(
12954 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
12956 if (gbl_driver_id == -1) {
12957 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
12958 return TEST_FAILED;
12961 return unit_test_suite_runner(&cryptodev_testsuite);
12965 test_cryptodev_bcmfs(void)
12967 gbl_driver_id = rte_cryptodev_driver_id_get(
12968 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
12970 if (gbl_driver_id == -1) {
12971 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
12972 return TEST_FAILED;
12975 return unit_test_suite_runner(&cryptodev_testsuite);
12978 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
12979 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
12980 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
12981 test_cryptodev_cpu_aesni_mb);
12982 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
12983 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
12984 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
12985 test_cryptodev_cpu_aesni_gcm);
12986 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
12987 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
12988 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
12989 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
12990 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
12991 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
12992 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
12993 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
12994 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
12995 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
12996 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
12997 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
12998 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
12999 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
13000 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);